Hi!

Claes L wrote:
> My colleges and I are looking for a way to have an EJB in the jBoss to get
> messages from a jms message queue (from a SonicMQ jms, to be precise, we
> don’t use the spydermq). We don’t want beans that’s up and running all the
> time listening to the queue so we are looking for ways to make something
> else call the bean, passing the message in the function call instead.
>    The approach we have taken is to let a mBean start a jms-queue-listening
> object in a separate running thread. Then when a message arrives to a queue,
> the queue listener gets a ‘onMessage()’-event and simply calls the EJB as an
> ordinary EJB-client. It seem to work – up to the point when the listener
> makes the ‘bean = home.create();’. Before that it apparently manages to get
> a reference to the ejb-home interface (the code is not interrupted that far
> anyway).

Your basic approach seems right.

> The error cast is: "java.lang.ClassCastException: $Proxy9"
> 
>    If the listeners are run as standalone programs they work as thought. And
> if there are two instances of jBoss – they seem to be able to call the ejb’s
> on the other jBoss instance.
> 
> Could somebody tell me if it’s possible to make a call within the jBoss
> instance to an EJB in it - and in that case how?

This is most likely a classloader issue. Your MBean has the EJB remote
interface, but the EJB does too. So, when you get the proxy it will
implement the interface class from the EJB. Hence, the classcast
exception.

If you use the "Optimize calls" flag, you could try to turn it off. That
will cause the proxies to be copied even if you are in the same JVM,
which will make the proxies use the right interface class.

/Rickard

-- 
Rickard Öberg

Email: [EMAIL PROTECTED]
http://www.telkel.com
http://www.jboss.org
http://www.dreambean.com


--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Problems?:           [EMAIL PROTECTED]

Reply via email to