Announcement Announcement Module
Collapse

Spring Dynamic Modules forum decommissioned in favor of Eclipse Gemini Blueprint

With the official first release of Eclipse Gemini Blueprint shipped, the migration of the Spring Dynamic Modules code base to the Eclipse Foundation, as part of the Gemini project, has been completed.

As such, this forum has been decommissioned in favour of the Eclipse Gemini forums.
See more
See less
CNFE when using spring jms bundle Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • CNFE when using spring jms bundle

    Hi,

    I have started to integrate messaging in our platform based on OSGi (equinox, spring dm 1.2.1). When I am trying to create JMS context the JNDI lookup fails since initial context is not getting loaded due to CNFE for the initial context factory.

    The spring configuration for my messaging beans is

    Code:
    	<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
    	    <property name="environment">
    	      <props>
    	        <prop key="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</prop>
    	        <prop key="java.naming.provider.url">tcp://localhost:61616</prop>
    	      </props>
    	    </property>
    	</bean>
    	<bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiTemplate"><ref bean="jndiTemplate"/></property>
    		<property name="jndiName"><value>ConnectionFactory</value></property>
    	</bean>
    As can be seen above, I am testing using ActiveMQ and the initial context can be set using the class org.apache.activemq.jndi.ActiveMQInitialContextFac tory. The package org.apache.activemq.jndi is imported in my bundle as dependency where the above spring configuration is present. I also checked that the dependency for this package is getting resolved fine at runtime and my app bundle comes up fine. However during access to the JMS template bean I get CNFE exception.

    Code:
    Caused by: javax.naming.NoInitialContextException: Cannot instantiate class: org.apache.activemq.jndi.ActiveMQInitialContextFactory [Root exception is java.lang.ClassNotFoundException: org.apache.activemq.jndi.ActiveMQInitialContextFactory]
    	at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
    	at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
    	at javax.naming.InitialContext.init(InitialContext.java:223)
    	at javax.naming.InitialContext.<init>(InitialContext.java:197)
    	at org.springframework.jndi.JndiTemplate.createInitialContext(JndiTemplate.java:136)
    	at org.springframework.jndi.JndiTemplate.getContext(JndiTemplate.java:103)
    	at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:85)
    	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.jms.support.destination.JndiDestinationResolver.resolveDestinationName(JndiDestinationResolver.java:111)
    	... 80 more
    Caused by: java.lang.ClassNotFoundException: org.apache.activemq.jndi.ActiveMQInitialContextFactory
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    	at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:592)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    	at java.lang.Class.forName0(Native Method)
    	at java.lang.Class.forName(Class.java:247)
    	at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:46)
    	at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)
    	... 90 more
    Now, I am not sure how is this going to work unless I put the activemq jar itself in the JRE endorsed folder.

    Kindly throw some light.

    Regards,
    Shashi

  • #2
    Can somebody pls reply?

    Regards,
    Shashi

    Comment


    • #3
      Hello All,

      I could resolve this after adding dependency for org.apache.activemq.jndi package in my web bundle from where the request was actually initiated.

      Thanks,
      Shashi

      Comment

      Working...
      X