2
votes

I am using WebLogic Server: 12.1.1.0, Spring 3.2.11.RELEASE and Camel 2.13.4.

I have a ConnectionFactory on my WebLogic. The JNDI name is: jms/ConnectionFactory. I used a servlet to print all JNDI names in the server and found it inside the jms subcontext.

The Spring configuration is:

<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>

I get the error:

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'

The full trace is:

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

I have also already tried using the following JNDI names:

  • java:jms/ConnectionFactory,
  • java:ConnectionFactory,
  • ConnectionFactory,
  • java:comp/env/jms/ConnectionFactory
1
How did you create the datasource in weblogic? What are the settings and jndi name?Display Name is missing
@DisplayNameismissing the datasource has been created using the web console. The jndi name is jms/ConnectionFactory. Which settings should I see?Vitaly Olegovitch
One easy thing to check, did you target your datasource to the server you want it to run on? If you forgot to actually target the datasource this could happen. Also have a look at this in case you're editing the weblogic.xml file: stackoverflow.com/questions/21355945/…Display Name is missing
I have the same error. Did you find any solution?dikkini
@dikkini unfortunately, the only solution I know is avoiding using Spring on WebLogic. Use a servlet cointainer like Tomcat or Jetty.Vitaly Olegovitch

1 Answers

1
votes

When you create the domain using WLST, what do you set the JNDI name of the connection factory to? Typically you will see something like this in your domain setup script (.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>

in your Spring bean. If you don't have a custom name it may be of value to add one.