我正在使用 WebLogic Server:12.1.1.0、Spring 3.2.11.RELEASE 和 Camel 2.13.4。
我的 WebLogic 上有一个 ConnectionFactory。 JNDI 名称是:jms/ConnectionFactory
。我使用 servlet 打印服务器中的所有 JNDI 名称,并在 jms
子上下文中找到它。
Spring配置是:
<bean id="jndiFactoryBean" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jms/ConnectionFactory"/>
<property name="jndiTemplate" ref="jndiTemplate"/>
<property name="lookupOnStartup" value="false"/>
<property name="proxyInterface" value="javax.jms.ConnectionFactory"/>
</bean>
我得到错误:
GRAVE: Could not refresh JMS Connection for destination 'CamelTest' - retrying in 5000 ms. Cause: JndiObjectTargetSource failed to obtain new target object; nested exception is javax.naming.NameNotFoundException: While trying to look up jms/ConnectionFactory in /app/webapp/camelweblogic.war/1720653836.; remaining name 'jms/ConnectionFactory'
完整的轨迹是:
Caused by: javax.naming.NameNotFoundException: While trying to lookup 'jms.ConnectionFactory' didn't find subcontext 'jms'. Resolved '' [Root exception is javax.naming.NameNotFoundException: While trying to lookup 'jms.ConnectionFactory' didn't find subcontext 'jms'. Resolved '']; remaining name 'jms/ConnectionFactory'
at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:237)
at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:464)
at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:272)
at weblogic.jndi.internal.ServerNamingNode_1211_WLStub.lookup(Unknown Source)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:418)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:406)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154)
at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)
at org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:231)
at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:217)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1573)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1511)
... 86 more
我也已经尝试过使用以下 JNDI 名称:
java:jms/ConnectionFactory
,java:ConnectionFactory
,连接工厂
,java:comp/env/jms/ConnectionFactory
最佳答案
当您使用 WLST 创建域时,您将连接工厂的 JNDI 名称设置为什么?通常,您会在域设置脚本 (.py) 中看到类似这样的内容:
cf = create('ConnectionFactoryName', "ConnectionFactory") cf.setName('ConnectionFactoryName') cf.setJNDIName('ConnectionFactoryJNDIName')
In this case you would simply use
<bean id="jndiFactoryBean" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="ConnectionFactoryJNDIName"/>
<property name="jndiTemplate" ref="jndiTemplate"/>
<property name="lookupOnStartup" value="false"/>
<property name="proxyInterface" value="javax.jms.ConnectionFactory"/>
</bean>
在你的 Spring bean 中。如果您没有自定义名称,添加一个可能会很有值(value)。
关于java - JMS ConnectionFactory 上的 WebLogic NameNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29827550/