• Post Reply Bookmark Topic Watch Topic
  • New Topic

@EJB annotation DI for an Actual Remote Client

 
Jose Campana
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there true believers !

I've been training myself about EJB 3. and I have a question, I believe the subject sums it up well, But still... I will describe it again so that you guys are able to acquire a better context.

I have noticed that Servlets typically are the clients for EJBs that are deployed to the same Java EE Server Solution. But what happens when The Client Servlet and the invoked EJB reside in different Servers?

Is there a way to configure the @EJB annotation so that it knows during Runtime where to look for the EJB ?

It'd be nice if someone could provide a code example of how this works.

Thanks in advance for all your comments.

Have a nice day,

Jose
 
Henrik Axelsson
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jose,

I'm pretty sure that you can only use DI if the apps are running in the same server. If you need to access the beans externally you will have to use other means.

Not sure what app server you are using but here is an FAQ on how to do it with glassfish https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#nonJavaEEwebcontainerRemoteEJB

I don't have much EJB experience but I am trying to achieve a similar thing and have encountered problems...

Good luck with it.

Henrik
 
Reza Rahman
author
Ranch Hand
Posts: 580
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jose,

Yes, this is very possible. Here is how to do it in GlassFish: http://forums.java.net/jive/message.jspa?messageID=320940. Most major vendors should have similar capabilities.

Be advised, however - I have not attempted this myself. The last time I've had to actually use a remote EJB tier from another Java EE application was in the EJB 2.x time-frame. That being said, I doubt the capability has changed much since it has been a much touted EJB feature for quite some time. In the worst case scenario, you can always simply use look-ups.

Best regards,
Reza
 
Jose Campana
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good morning Guys !

I will give it a shot. I think it's extremely weird if the @EJB annotation would only work for components that reside in the same server.
A question about that:

Wouldn't that make the @Remote annotation Pointless ? I mean, If I plan to use it in conjunction with the @EJB annotation.
I hope you guys see my point, because I believe @Remote means the web or enterprise component will access(or inject it in this case?) the component marked with it from a 'Remote' Server, isn't it?

Have a nice day !

And thanks for the replies.
Sincerely,

Jose
 
Reza Rahman
author
Ranch Hand
Posts: 580
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jose,

Not sure what you are getting at exactly. As I said, you can use @EJB to access remote EJBs and you may always use older style look-ups to remote server JNDI contexts to access remote EJBs as well.

That being said, I do believe @Remote has limited practical usage since most business tiers are not remoted these days. This is, for example, why this is not a large priority for most vendors or the EJB 3.1 EG.

Best regards,
Reza
 
Jose Campana
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Reza,

I'm incredibly honored to know it is you, the author of EJB 3 in Action Him/Herself ! who is replying to my questions.

What I was getting at - exactly - is that to me, It would seem non-sense to have a Bean that uses the @Remote annotation, when in most cases (as you accurately put) Clients AND Beans will LIVE inside the same Server Heap.

But I'm just a humble developer. I maybe Totally wrong, and in that case I deserve to be schooled.

Please let me know what do you think about this.

And of course, I could always use old-fashioned JNDI-lookups. In fact that's what I've been doing from my JSE apps.

Once again, What an Honor.

Have a nice day,

Jose
 
Reza Rahman
author
Ranch Hand
Posts: 580
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jose,

Firstly, thanks for the kind words. As such, the priviledge is mine. I'm no bigshot and feel very fortunate to be in a position to be of help to anyone else.

Are you aware EJB 3 (and even EJB 2) supports @Local in addition to @Remote for intra-VM invocation? Indeed, the default interface type for EJB 3 is local, not remote...that being said, @Remote has it's place (truly distributed Java EE applications, traditional thick client applications, RIA applications, CORBA interoperable applications, etc).

Best regards,
Reza
 
Rahul Bangwathia
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
I am new to EJB3. I am using Eclipse Europa(Java 5 compiler). I am trying to create HelloWorld program using EJB3. Can you please tell me that how can I resolve annotations ?
I am trying to use annotation like @Stateless..@Remote..
Also I downloaded JBOSS 5.0 unzipped it. Set JAVA_HOME ..JBOSS_HOME but server is till not started after clicking on run.bat
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rahul,

Your's a completely different question and is not related to what the original poster started this thread for. Please open a new thread to discuss your issue
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!