JMS Fun in JEE Wonderland

Recently I had to dig into JMS to implement some asynchronous behaviour in our current application.
I haven’t used JMS thus far, but it looked quite promising and straightforward to me.
I got the ConnectionFactory and queues working quite fast and the first messages appeared in my queue. Horray!
To consume those messages I had to implement a MessageListener which looked something like this

name = "MyQueueListener",
mappedName ="jms/MyQueue",
activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")}

public class MyQueueListener implements MessageListener {

private IMyStalelessSessionBean myStalelessSessionBean;

public MyQueueListener () {}

public void onMessage(Message message) {
//Consume my message

public void IMyStalelessSessionBean (IMyStalelessSessionBean myStalelessSessionBean ) {
this.myStalelessSessionBean = myStalelessSessionBean ;

Looked quite ok to me, deployment on the Weblogic server went well. So I should be ready to rock!
But, after I put something meaningful in my queue, onMessage() was not called, instead I was greeted by:

#### <> <> <> java.lang.IllegalArgumentException: argument type mismatch.
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at com.bea.core.repackaged.springframework.util.ReflectionUtils.invokeMethod(
at com.bea.core.repackaged.springframework.jee.inject.MethodInjection.apply(
at com.bea.core.repackaged.springframework.jee.inject.Jsr250Metadata.applyInjections(
at com.bea.core.repackaged.springframework.jee.inject.Jsr250Metadata.inject(
at weblogic.ejb.container.injection.EjbComponentCreatorImpl.injection(
at weblogic.ejb.container.injection.EjbComponentCreatorImpl.getBean(
at weblogic.ejb.container.manager.BaseEJBManager.createNewBeanInstance(
at weblogic.ejb.container.manager.BaseEJBManager.allocateBean(
at weblogic.ejb.container.manager.MessageDrivenManager.createBean(
at weblogic.ejb.container.pool.MessageDrivenPool.createBean(
at weblogic.ejb.container.pool.MessageDrivenPool.getBean(
at weblogic.ejb.container.internal.MDListener.execute(
at weblogic.ejb.container.internal.MDListener.transactionalOnMessage(
at weblogic.ejb.container.internal.MDListener.onMessage(
at weblogic.jms.client.JMSSession.onMessage(
at weblogic.jms.client.JMSSession.execute(
at weblogic.jms.client.JMSSession$

IllegalArgumentException while calling onMessage! WTF! I was quite lost!
Tweaked the @MessageDriven-annotation and doublechecked the correct signature of onMessage. But no success!
After a while I set an ExceptionBreakpoint for IllegalArgumentException and found myself in the middle of JEE internals. Reflection all the way!

Eventually I found the culprit:
The stateless session bean I wanted to be injected seemed to be null.
Removed that code temporarily. And bang! onMessage was called. After fixing the injection everthing worked well.

But to cut a long story short:
What does an IllegalArgumentException do to help me under that circumstances. My mistake had no obvious connection to the onMessage-method.
Something more meaningful would be highly appreciated and would have saved me a lot of time.
But still it is always a little fun to me, to finally get my head around something like that ;)

Hinterlasse eine Antwort