I'm replacing activemq-all 5.18.6 with activemq-broker and activemq-client. I've found a side effect in my Java servlets that javax.jms.ConnectionFactory has to be replaced in the servlet XML and the Java code with org.apache.activemq.ActiveMQConnectionFactory. However, this leads to a runtime error in the Catalina log:
WARNING [main] XmlWebApplicationContext.refresh Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'JMSConnectionFactory' defined in ServletContext resoure [/WEB-INF/JmsProcessing-servlet.xml]: Invocation of init method failed; nested exception is javax.naming.NamingException: Unexpected exception resolving reference [Root exception is java.lang.IllegalArgumentException: The local resource link [ConnectionFactory] that refers to global resource [jms/ConnectionFactory] was expected to return an instance of [org.apache.activemq.ActiveMQConnectionFactory] but returned an instance of [org.apache.activemq.ActiveMQConnectionFactory]]
I have verified that org.apache.activemq.ActiveMQConnectionFactory is being referenced in all relevant locations so it's not a simple typo.
context.xml:
<?xml....?>
<Context docBase="JmsProcessing" reloadable="true">
<ResourceLink name="jdbc/dev" global="jdbc/dev" type="javax.sql.DataSource" />
<ResourceLink name="jms/ConnectionFactory"
global="jms/ConnectionFactory"
type="org.apache.activemq.ActiveMQConnectionFactory" />
<!-- was type="javax.jms.ConnectionFactory" -->
</Context>
JmsProcessing-servlet.xml:
<?xml ... ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
org/springframework/beans/factory/xml/spring-beans-2.5.xsd
spring-beans-2.5.xsd">
<bean id="JMSConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:comp/env/jms/ConnectionFactory</value>
</property>
</bean>
<bean name="processingBean" class="com.custom.processing.impl.JmsProcessor">
<property name="connectionFactory" ref="JMSConnectionFactory" />
</bean>
</beans>
I'm using Spring 4.3.18, building in Java 17, running in Java 11 on RH9.
I found activemq-client-5.18.6.jar in two locations. From the install directory, they are
tomcat/lib/activemq-client-5.18.6.jartomcat/webapps/JmsProcessing/WEB-INF/lib/activemq-client-5.18.6.jar
I suspect the jar needs to be in the webapp-specific directory and not the Tomcat lib directory, but I could have this backwards.
diff- it said they were identical. Third, a search in vi found both. I'm trying to get Tomcat to tell me what classpath it's actually using at runtime, because multiple instances of the same class is quite possible.javax.jms.ConnectionFactorybut actual instance wasorg....ActiveMQConnectionFactory. I had come across something saying I should only have needed to change the XML files, not the code.....