我正在使用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>
我收到错误:
严重:无法刷新目标“ CamelTest”的JMS连接-
在5000毫秒内重试。原因:JndiObjectTargetSource无法获取
新的目标对象;嵌套异常为
javax.naming.NameNotFoundException:尝试查找时
jms / ConnectionFactory在
/app/webapp/camelweblogic.war/1720653836 .;剩余的名字
'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
,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中。如果您没有自定义名称,则添加一个可能很有价值。