java javax.naming.NamingException:无法创建 ActiveMQConnectionFactory 的资源实例
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13295137/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
javax.naming.NamingException: Cannot create resource instance of ActiveMQConnectionFactory
提问by Long Thai
I know that this question has been asked many times, but I still have an exception even after following all the answers. My configs are:
我知道这个问题已经被问过很多次了,但即使在遵循所有答案之后我仍然有一个例外。我的配置是:
context.xml
上下文.xml
<Context>
<Resource
name="jms/ProdConnectionFactory"
description="Prod JMS Connection Factory"
auth="Container"
userName=""
password=""
type="org.apache.activemq.ActiveMQConnectionFactory"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
brokerURL="tcp://jmshost:61616"
brokerName="ProdActiveMQBroker"
/>
</Context>
web.xml
网页.xml
<web-app>
<resource-ref>
<description>Prod Connection Factory</description>
<res-ref-name>jms/ProdConnectionFactory</res-ref-name>
<res-type>org.apache.activemq.ActiveMQConnectionFactory</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
Java code:
爪哇代码:
Context context = new InitialContext();
ActiveMQConnectionFactory factory = (ActiveMQConnectionFactory) context.lookup("java:comp/env/jms/ProdConnectionFactory");
And the exception that I receive is:
我收到的例外是:
javax.naming.NamingException: Cannot create resource instance
at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:143)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
Can anyone take a look and let me know where I'm wrong. Thanks
任何人都可以看看,让我知道我错在哪里。谢谢
L
升
采纳答案by Long Thai
The reason is described here: appname.xml is different than context.xml, i.e. it contains less resources defined in context.xml. appname.xml should be updated everytime a application is redeployed, but there's an issues in redeployment which leaves appname.xml unchanged. The issue is fixed after I update appname.xml
原因在这里描述:appname.xml 与context.xml 不同,即它包含的context.xml 中定义的资源较少。每次重新部署应用程序时都应更新 appname.xml,但在重新部署时存在一个问题,使 appname.xml 保持不变。更新 appname.xml 后问题已解决
L
升