gpt4 book ai didi

javax.naming.NamingException : Cannot create resource instance of ActiveMQConnectionFactory

转载 作者:行者123 更新时间:2023-12-01 05:01:51 25 4
gpt4 key购买 nike

我知道这个问题已经被问过很多次了,但即使在遵循所有答案之后我仍然有一个异常(exception)。我的配置是:

上下文.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

<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代码:

Context context = new InitialContext();
ActiveMQConnectionFactory factory = (ActiveMQConnectionFactory) context.lookup("java:comp/env/jms/ProdConnectionFactory");

我收到的异常是:

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)

任何人都可以看一下并让我知道我错在哪里。谢谢

L

最佳答案

原因描述here :appname.xml 与 context.xml 不同,即它包含 context.xml 中定义的较少资源。每次重新部署应用程序时都应更新 appname.xml,但重新部署时存在问题,导致 appname.xml 保持不变。更新 appname.xml 后问题已解决

L

关于javax.naming.NamingException : Cannot create resource instance of ActiveMQConnectionFactory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13295137/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com