我正在使用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:无法刷新目的地'CamelTest'的JMS连接 - 在5000毫秒重试。原因:JndiObjectTargetSource无法获取 新目标对象;嵌套异常是 javax.naming.NameNotFoundException:在尝试查找时 jms / ConnectionFactory in /app/webapp/camelweblogic.war/1720653836;剩下的名字 'JMS /连接工厂'
完整的痕迹是:
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
答案 0 :(得分:1)
使用WLST创建域时,如何将连接工厂的JNDI名称设置为?通常,您会在域设置脚本(.py)中看到类似的内容:
cf = create('ConnectionFactoryName', "ConnectionFactory") cf.setName('ConnectionFactoryName') cf.setJNDIName('ConnectionFactoryJNDIName')
在这种情况下,您只需使用
<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中。如果您没有自定义名称,则添加自定义名称可能很有用。