Need to specify class name in environment or system property, or as an applet parameter, or in an ap

原创 2012年03月28日 16:33:53
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(
NamingManager.java:645)
    at javax.naming.InitialContext.getDefaultInitCtx(
InitialContext.java:288)
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(
InitialContext.java:325)
    at javax.naming.InitialContext.lookup(
InitialContext.java:392)
    at Chat.<init>(
Chat.java:56)

    at Chat.main(Chat.java:22)


这是《Java消息服务》里第二章的程序编译出的错,哥可是完完整整按照书本指示来做的。问题的缘由是没有找到jndi.properties文件。

我可在工程所在目录(即有.classpath),src目录下都放了jndi.properties,可还是用eclipse编译总是出错。

但是命令行执行:javac Chat.java却可以执行,且编译成功 & 运行成功。

eclipse怎么了???

不过如果非要在eclipse下编译执行的话,这暂时有个解决方法,可以不用jdni.properties文件,用下面的方法:

  Properties p = new Properties();
		p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
		p.put(Context.PROVIDER_URL, "tcp://localhost:61616");
		p.put(Context.SECURITY_PRINCIPAL, "system");
		p.put(Context.SECURITY_CREDENTIALS, "manager");
		p.put("connectionFactoryNames", "topicCF");
		p.put("topic.topic1", "jms.topic1");


有解决方案了再更新。


有新发现:

真的让人很囧,网上查了那么多都说jndi.properties应该放在src目录下,可是放在bin目录下才是王道,至少编译成了。(我是指在eclipse里)

不懂eclipse,不懂classpath

——2012-3-28 21:25:12更新

环境:

OS: Windows XPsp3

Eclipse SDK: Version: 3.5.2 Build id: M20100211-1343

ActiveMQ 5.4.3



版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

hibernate配置文件hibernate.cfg.xml和.hbm.xml的详细解释

原文地址:http://blog.csdn.net/qiaqia609/article/details/9456489 -标准的XML文件的起始行,version='1.0'表明XML的版本,enc...

javax.naming.NoInitialContextException: Need to specify class name in environment or system property

javax.naming.NoInitialContextException: Need to specify class name in environment or system property...

EJB3.0异常总结--- Need to specify class name in environment or system property,

异常:  Need to specify class name in environment or system property, or     as an applet paramet...

javax.naming.NoInitialContextException: Need to specify class name in XXX解决

环境 MyEclipse 8.6 + JBoss 6.0 + JDK 1.6.13 + EJB 3.0   问题 运行EJB程序,出现如下异常:   javax.naming.NoInitialCon...

If you are behind an HTTP proxy, please configure the proxy settings either in IDE or Gradle.(AS报错)

If you are behind an HTTP proxy, please configure the proxy settings either in IDE or Gradle.问题解决方案

Bean property 'RegDao' is not writable or has an invalid setter method. Does the parameter type of t

Bean property 'RegDao' is not writable or has an invalid setter method. Does the parameter type of t...

IntelliSense: PCH warning: header stop cannot be in a macro or #if block. An intellisense PCH file

今天在vs2010写了点代码,居然报了“IntelliSense: PCH warning: header stop cannot be in a macro or #if block.  An in...

Facebook面试题 find the peek or valley index in an array

Given an input array in which A[i] = A[i - 1] -1/+1. And there is only one peek or one valley in the...

经典错误重现->Java RunTime Environment (JRE) or Java Development Kit (JDK) must be available in order to

经常碰到这种错误,错误代码如下: Java RunTime Environment (JRE) or Java Development Kit (JDK) must be available in o...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)