2012-11-08 43 views
1

我知道這個問題已被多次詢問,但即使在遵循所有答案之後,我仍然有一個例外。我CONFIGS是:javax.naming.NamingException:無法創建ActiveMQConnectionFactory的資源實例

的context.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) 

任何人都可以看看,讓我知道我錯了。感謝

大號

回答

0

的理由進行說明here:appname.xml比context.xml中不同,即,其含有的context.xml定義更少的資源。每次重新部署應用程序時都應更新appname.xml,但重新部署時會出現問題,使appname.xml保持不變。我更新appname.xml後問題得到修復

L

+0

什麼需要在appname.xml中更新? –

+0

我需要將context.xml中定義的資源添加到appname.xml中 –