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

@MessageDriven(
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
}

@EJB(beanName="MyStalelessSessionBean")
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(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.bea.core.repackaged.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:121)
at com.bea.core.repackaged.springframework.jee.inject.MethodInjection.apply(MethodInjection.java:47)
at com.bea.core.repackaged.springframework.jee.inject.Jsr250Metadata.applyInjections(Jsr250Metadata.java:233)
at com.bea.core.repackaged.springframework.jee.inject.Jsr250Metadata.inject(Jsr250Metadata.java:218)
at weblogic.ejb.container.injection.EjbComponentCreatorImpl.injection(EjbComponentCreatorImpl.java:131)
at weblogic.ejb.container.injection.EjbComponentCreatorImpl.getBean(EjbComponentCreatorImpl.java:74)
at weblogic.ejb.container.manager.BaseEJBManager.createNewBeanInstance(BaseEJBManager.java:216)
at weblogic.ejb.container.manager.BaseEJBManager.allocateBean(BaseEJBManager.java:233)
at weblogic.ejb.container.manager.MessageDrivenManager.createBean(MessageDrivenManager.java:286)
at weblogic.ejb.container.pool.MessageDrivenPool.createBean(MessageDrivenPool.java:165)
at weblogic.ejb.container.pool.MessageDrivenPool.getBean(MessageDrivenPool.java:90)
at weblogic.ejb.container.internal.MDListener.execute(MDListener.java:434)
at weblogic.ejb.container.internal.MDListener.transactionalOnMessage(MDListener.java:371)
at weblogic.ejb.container.internal.MDListener.onMessage(MDListener.java:327)
at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:4072)
at weblogic.jms.client.JMSSession.execute(JMSSession.java:3964)
at weblogic.jms.client.JMSSession$UseForRunnable.run(JMSSession.java:4490)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:464)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:200)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:172)

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