You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Adrianos Dadis <ad...@gmail.com> on 2012/03/21 19:39:56 UTC

EJB and RSS Component in JBoss 7

Hi all,

I am trying to use RSS and EJB components together, inside new JBoss 7.1. I
want the RSS component to consume some data from a real rss location and
call an EJB with this data (using the EJB component).

I have written 2 different routes that both of them call the same EJB, using
its "name" value [@Stateless(name="MyEJBServiceImplName")]. 
1) SimpleRoute1:
from("direct:myroute1").log("I got:
${body}").to("ejb:java:module/MyEJBServiceImplName?method=echo");

2) PollRoute2:
from("rss:http://sample.com/feed/?consumer.delay=30000").log("I got:
${body}").to("ejb:java:module/MyEJBServiceImplName?method=echo");

Both Camel context and EJB are in the same WAR. As you can see both Routes
try to call the same EJB.

I trigger SimpleRoute1, within another EJB, using the following code:
myCamelContext.createProducerTemplate().requestBody("direct:myroute1", msg);
This works and my "MyEJBServiceImplName" is called successfully.

The PollRoute2 is triggered by itself as RSS component extends
"ScheduledPollConsumer". This route fails with the following exception:
org.apache.camel.NoSuchBeanException: No bean could be found in the registry
for: java:module/MyEJBServiceImplName

When SimpleRoute1 is invoked by another EJB, the JNDI Context contains the
EJB that I want to call. But when PollRoute2 triggered, the JNDI Context
does not contain the same EJB. Both Routes and both EJBs are in the same WAR
file. The difference is that the first time the method
"org.apache.camel.impl.JndiRegistry.createContext()" returns a JNDI Context
that contains all the EJB of the WAR, but on the PollRoute2 case, the same
method returns another Context that does NOT contain any EJB of the WAR.

Do you have any idea why is this happening?
The only thing that I suspect is the JBoss Modules, which have changed the
Classloading procedure in JBoss. 

Notes: The prefix "java:module/" before EJB name ("
java:module/MyEJBServiceImplName") is correct. This is how JBoss works.

Environment:
JDK: HotSpot 1.6.0_26
Camel: 2.9
JBoss AS: 7.1
OS: GNU/Linux Debian wheezy


Thanks in advance,
Adrianos Dadis.
--
Democracy requires Free Software

--
View this message in context: http://camel.465427.n5.nabble.com/EJB-and-RSS-Component-in-JBoss-7-tp5583762p5583762.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: EJB and RSS Component in JBoss 7

Posted by Adrianos Dadis <ad...@gmail.com>.
Hi Claus,

> Have you configured the EjbComponent to specify the JndiContext
> it need to lookup the EJBs?

Yes in both scenarios.
In case of 1st scenario (SimpleRoute1), the EJB invocation succeed even if I
do not set the JNDI context via EjbComponent.setContext(...), because the
EJBs is "visible" in the "default" JNDI context, as there is another EJB
invocation before SimpleRoute1 is fired.
In case of 2nd scenario (PollRoute2), where no EJB invocation involved
before PollRoute2 is fired, the "default" JNDI context is different (and
does not include any EJB) !!!

> And in the old EJB days you needed to have container specific
> deployment configuration files.
I have used EJB Component in old Camel, so I am not very familiar with such
a case. Can you give me an example of JBoss (eg. 4.2.x) ? (if you have)

I am afraid that this is a JBoss 7 problem. I will try the "container
specific deployment configuration file" solution, and afterwards I will
communicate with JBoss guys to check what is going on here. I am pretty sure
that JBoss Modules magic has a few problems here (bugs are everywhere, even
in my room :) ).

Claus thanks a lot for your time.

Regards,
Adrianos Dadis.
--
Democracy requires Free Software

--
View this message in context: http://camel.465427.n5.nabble.com/EJB-and-RSS-Component-in-JBoss-7-tp5583762p5589847.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: EJB and RSS Component in JBoss 7

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Sad to hear that using EJBs is still a **** in 2012.

Have you configured the EjbComponent to specify the JndiContext it
need to lookup the EJBs?
http://camel.apache.org/ejb

And in the old EJB days you needed to have container specific
deployment configuration files.
I assume this is no longer needed, but you never know if there is
something there you can do.



On Wed, Mar 21, 2012 at 7:39 PM, Adrianos  Dadis <ad...@gmail.com> wrote:
> Hi all,
>
> I am trying to use RSS and EJB components together, inside new JBoss 7.1. I
> want the RSS component to consume some data from a real rss location and
> call an EJB with this data (using the EJB component).
>
> I have written 2 different routes that both of them call the same EJB, using
> its "name" value [@Stateless(name="MyEJBServiceImplName")].
> 1) SimpleRoute1:
> from("direct:myroute1").log("I got:
> ${body}").to("ejb:java:module/MyEJBServiceImplName?method=echo");
>
> 2) PollRoute2:
> from("rss:http://sample.com/feed/?consumer.delay=30000").log("I got:
> ${body}").to("ejb:java:module/MyEJBServiceImplName?method=echo");
>
> Both Camel context and EJB are in the same WAR. As you can see both Routes
> try to call the same EJB.
>
> I trigger SimpleRoute1, within another EJB, using the following code:
> myCamelContext.createProducerTemplate().requestBody("direct:myroute1", msg);
> This works and my "MyEJBServiceImplName" is called successfully.
>
> The PollRoute2 is triggered by itself as RSS component extends
> "ScheduledPollConsumer". This route fails with the following exception:
> org.apache.camel.NoSuchBeanException: No bean could be found in the registry
> for: java:module/MyEJBServiceImplName
>
> When SimpleRoute1 is invoked by another EJB, the JNDI Context contains the
> EJB that I want to call. But when PollRoute2 triggered, the JNDI Context
> does not contain the same EJB. Both Routes and both EJBs are in the same WAR
> file. The difference is that the first time the method
> "org.apache.camel.impl.JndiRegistry.createContext()" returns a JNDI Context
> that contains all the EJB of the WAR, but on the PollRoute2 case, the same
> method returns another Context that does NOT contain any EJB of the WAR.
>
> Do you have any idea why is this happening?
> The only thing that I suspect is the JBoss Modules, which have changed the
> Classloading procedure in JBoss.
>
> Notes: The prefix "java:module/" before EJB name ("
> java:module/MyEJBServiceImplName") is correct. This is how JBoss works.
>
> Environment:
> JDK: HotSpot 1.6.0_26
> Camel: 2.9
> JBoss AS: 7.1
> OS: GNU/Linux Debian wheezy
>
>
> Thanks in advance,
> Adrianos Dadis.
> --
> Democracy requires Free Software
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/EJB-and-RSS-Component-in-JBoss-7-tp5583762p5583762.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/