Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] JMS Listener/Reader no longer works with ActiveMQ #6111

Closed
fallensieg opened this issue Feb 21, 2024 · 10 comments
Closed

[BUG] JMS Listener/Reader no longer works with ActiveMQ #6111

fallensieg opened this issue Feb 21, 2024 · 10 comments
Labels
bug Something isn't working

Comments

@fallensieg
Copy link

fallensieg commented Feb 21, 2024

Describe the bug
JMS Sender/Listener channels no longer work with ActiveMQ.

To Reproduce
I have several JMS Sender / Listener channels with ActiveMQ (5.15.11) working fine in Mirth 4.0.1
Now I'm trying to upgrade Mirth to 4.4.2 and when I try to send a message to ActiveMQ I get the error:
org.apache.activemq.ActiveMQConnectionFactory cannot be cast to javax.jms.ConnectionFactory

imatge.png

I've tried to downgrade to Mirth 4.3 and the error is the same, but with Mirth 4.2 it works again. Have also tired upgrading to 4.5, same problem.
Am I doing something wrong, or could it be a bug from Mirth 4.3 and above?
Anyone knows a workaround for this issue?

Expected behavior
JMS Listener and Sender can read/write messages against ActiveMQ.

Actual behavior
Channels will not even start with the following error message

Caused by: java.lang.ClassCastException: class org.apache.activemq.ActiveMQConnectionFactory cannot be cast to class javax.jms.ConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory is in unnamed module of loader com.mirth.connect.server.util.ChildFirstURLClassLo ader @17f0d6e; javax.jms.ConnectionFactory is in unnamed module of loader java.net.URLClassLoader @3970ed7e) at com.mirth.connect.connectors.jms.JmsClient.start(J msClient.java:129)

Environment (please complete the following information):

  • OS: Windows 10
  • Java: OpenJDK 11
  • Connect Version : anything above 4.0.1

Workaround(s)
Would be intered in knowing.

Additional context
Add any other context about the problem here.

@fallensieg fallensieg added the bug Something isn't working label Feb 21, 2024
@fallensieg fallensieg changed the title [BUG] Your Issue Title [BUG] JMS Listener/Reader no longer works with ActiveMQ Feb 21, 2024
@pacmano1
Copy link
Collaborator

Maybe upload a sample channel?

@ab-mg-23
Copy link

The problem is using a resource to load the ActiveMQ Client library and commit fd3b7b2 changing the child classloader to take effect before the cast from the concrete ActiveMQConnectionFactory to the ConnectionFactory interface. The interface definition is in a different classloader than the concrete definition, so Java throws an error on the cast. If you move the client JAR and dependencies into server-lib/jms that should load everything from the same classloader as a workaround, but then run the risk of classpath issues with dependencies.

@fallensieg
Copy link
Author

Thank you @ab-mg-23. That was exactly the issue and doing what you've suggested has resolved my problem.

@hae-andrew-young
Copy link

Adding this for reference. More people are seeing this issue. https://forums.mirthproject.io/forum/mirth-connect/support/184548-jms-sender-and-activemq

@hae-andrew-young
Copy link

If you move the client JAR and dependencies into server-lib/jms that should load everything from the same classloader as a workaround, but then run the risk of classpath issues with dependencies.

This didn't work for me. Still getting the ClassCastException

@frankparth8
Copy link

frankparth8 commented Jun 9, 2024

Getting this exact same error. Tried copying jars into server-lib/jms with no success.

Using the following jars: jakarta.jms-api-3.0.0 & activemq-client-6.1.2
@fallensieg Can you please let me know which exact jars you used that worked?

Attached a screenshot of the channel settings as well! This is on Mirth 4.5.0 with a Windows 2022 Datacenter hosted by AWS.

What testing was performed before this PR was approved and change was released?
channelSettings

@ab-mg-23
Copy link

@frankparth8 You'll need to use the ActiveMQ 5.18.x version of the client. The 6.X baseline moved from javax.jms to jakarta.jms for the API definition but Mirth still uses the JMS 1.1 API.

@frankparth8
Copy link

@ab-mg-23 That seems to have done the trick! I used 5.18.4 to avoid a security issue. Also had to add hawtbuf/1.11 due to another issue that was there. Thanks for the help!

@frankparth8
Copy link

frankparth8 commented Jun 13, 2024 via email

@lmillergithub
Copy link
Collaborator

In 4.3.0 we added the ability to specify whether resources should load classes "child-first" or "parent-first". Previously, all resource classloaders loaded "parent-first". This meant that when a user attempted to use a class that is already included with Mirth Connect, such as a PostgreSQL driver, the class was loaded from the parent classloader instead of loading the custom version that the user wanted. The user can now achieve the desired behavior using a "child-first" classloader. We have also made "child-first" the default option. I was able to get around this error by selecting the 'Load Parent-First' on the resource tab for the activeMQ resource.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants