java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory when running bundle in 6.2.1

Solution Unverified - Updated -

Issue

I need to define a JMS Connection Factory in Blueprint for connecting to WebLogic.
This requires the following Blueprint configuration:

  <bean id="jmsIn" class="org.apache.camel.component.jms.JmsComponent">
    <property name="connectionFactory" ref="jmsInConnectionFactory" />
  </bean>

  <!-- JNDI lookup for remote connection factory -->
  <!-- Defines the Client connection to the JNDI Server -->
  <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
    <property name="environment">
      <props>
        <prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop>
        <prop key="java.naming.provider.url" value="t3://localhost:7001" />
        <prop key="java.naming.security.principal" value="XXX" />
       <prop key="java.naming.security.credentials" value="XXX" />
      </props>
    </property>
  </bean>

  <!-- Gets a Weblogic JMS Connection factory object from JDNI Server by jndiName -->
  <bean id="jmsInConnectionFactoryJndiLookupFactory" class="org.springframework.jndi.JndiObjectFactoryBean" init-method="afterPropertiesSet">
    <property name="jndiTemplate" ref="jndiTemplate" />
    <property name="jndiName" value="dummyConnectionFactory" />
    <property name="proxyInterface" value="javax.jms.ConnectionFactory" />  
  </bean>

<bean id="jmsInConnectionFactory" factory-ref="jmsInConnectionFactoryJndiLookupFactory" factory-method="getObject" />

However this configuration fails at runtime with

Caused by: javax.naming.NoInitialContextException: Cannot instantiate class: weblogic.jndi.WLInitialContextFactory [Root exception is java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)[:1.6.0_65]
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)[:1.6.0_65]
at javax.naming.InitialContext.init(InitialContext.java:223)[:1.6.0_65]
at javax.naming.InitialContext.<init>(InitialContext.java:197)[:1.6.0_65]
at org.springframework.jndi.JndiTemplate.createInitialContext(JndiTemplate.java:136)[121:org.apache.servicemix.bundles.spring-context:3.2.8.RELEASE_1]
at org.springframework.jndi.JndiTemplate.getContext(JndiTemplate.java:103)[121:org.apache.servicemix.bundles.spring-context:3.2.8.RELEASE_1]
at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:85)[121:org.apache.servicemix.bundles.spring-context:3.2.8.RELEASE_1]
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)[121:org.apache.servicemix.bundles.spring-context:3.2.8.RELEASE_1]
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)[121:org.apache.servicemix.bundles.spring-context:3.2.8.RELEASE_1]
at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
...
Caused by: java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)[:1.6.0_65]
at java.security.AccessController.doPrivileged(Native Method)[:1.6.0_65]
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)[:1.6.0_65]
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)[:1.6.0_65]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)[:1.6.0_65]
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)[:1.6.0_65]
at java.lang.Class.forName0(Native Method)[:1.6.0_65]
at java.lang.Class.forName(Class.java:249)[:1.6.0_65]
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:46)[:1.6.0_65]
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)[:1.6.0_65]
... 69 more

Environment

  • JBoss Fuse 6.2.1
  • JBoss Fuse 6.2.0
  • Jboss Fuse 7.x
    Check suggested solution#2 on this note, for Fuse 7, here

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content