wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes What is the main method client code for loacl interface in EJB? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "What is the main method client code for loacl interface in EJB?" Watch "What is the main method client code for loacl interface in EJB?" New topic
Author

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

rameshmca rk
Greenhorn

Joined: Jan 27, 2007
Posts: 17
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

Joined: Nov 02, 2000
Posts: 515
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.


By failing to prepare, you are preparing to fail.<br />Benjamin Franklin (1706 - 1790)
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10069
    
163

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.


[My Blog] [JavaRanch Journal]
rameshmca rk
Greenhorn

Joined: Jan 27, 2007
Posts: 17
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

Joined: Jan 05, 2007
Posts: 84
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


If at first you don't succeed, don't try skydiving
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: What is the main method client code for loacl interface in EJB?