Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is the main method client code for loacl interface in EJB?

 
rameshmca rk
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is it possible to create EJB and make look up in the same machine?How?Could you give me the sample code?

Thanks and regards,
Ramesh RK
 
Dale DeMott
Ranch Hand
Posts: 515
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you talking about having an EJB call itself. If so, yes. As for how, I'm working on that now. I'm working on having an EJB basically call itself in order to enclose a transaction. I'm not done w/it yet though.
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by rameshmca rk:
Is it possible to create EJB and make look up in the same machine?


You mean you want to lookup a bean(deployed in a JVM) from a client which resides in the same JVM? That's what local interfaces are meant for. As far as the code is concerned, it would be the same as the one you would use to lookup a remote bean - only the jndi name needs to be changed to the name at which the localhome is bound.
 
rameshmca rk
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you jaikiran,
you have said a bean can call itself.How can we look up localhome using JNDI name inside the main method client?Could you give me the complete code for look up with property setting?

Thanks and regards,
Ramesh RK
 
Sumit Malik
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rameshmca Rk,

I hope this code snippet would help you up for calling local interface from JBOSS AS


See there are two ways for jndi setting. You can put jndi.properties file in you classpath or you can hard code jndi values in code. First approach is the good practice and easier to maintain code values.

If you have deployed your bean on other Application server other Jboss then you need to pass those interface values and context factory setting while doing jndi lookup.

I hope above code would give you more insight for calling ejb...

Cheers !!!
Sumit Malik
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic