Search code examples
springactivemq-classicjndi

Spring JNDI datasource not recognized after upgrade to ActiveMQ 5.6.0


I tested a ActiveMQ 5.5.0 (fuse version) app in AMQ 5.6.0 and noticed that our Spring JNDI configured Oracle datasources aren't being found.

The only thing I changed in my applications was the pom.xml versions of AMQ/Spring (to match the 5.6 versions). Otherwise, I'm using the identical application code and configuration (activemq.xml, jndi.xml, etc), but my Spring JDBC DAOs (v3.0.5) are failing to find them.

No errors in the logs otherwise, just this Spring Application Context initialization error...

javax.naming.NameNotFoundException; remaining name 'jdbc/myDataSource'

here is the relevant Spring jndi config (conf/jndi.xml, included in conf/activemq.xml)...

<bean id="jndi" class="org.apache.xbean.spring.jndi.SpringInitialContextFactory" 
    factory-method="makeInitialContext" scope="singleton">
    <property name="entries" ref="jndiEntries" />
</bean>
<util:map id="jndiEntries">
    <entry key="jdbc/myDataSource">
    <bean id="myDBCPDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="oracle.jdbc.OracleDriver" />
        ...

then my application references it like this...

<bean id="myDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName">
        <value>jdbc/myDataSource</value>
    </property>
</bean>

<bean id="messageDAO" class="com.mycompany.MessageDAOImpl">
    <property name="dataSource" ref="myDataSource" />
</bean>

That said, I tested without using JNDI (instead just hardcoded the datasource in my app) and everything works as expected. So that should rule out everything except the Spring JNDI registration/lookup of the datasource, etc.

So, what am I missing?


Solution

  • I found the issue, I added a jndi.properties file under the /conf directory containing the following and it works fine now (didn't need this under AMQ 5.5...strange)...

    java.naming.factory.initial = org.apache.xbean.spring.jndi.SpringInitialContextFactory