This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Best way to invoke remote EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Best way to invoke remote EJB" Watch "Best way to invoke remote EJB" New topic
Author

Best way to invoke remote EJB

Scott Gifford
Greenhorn

Joined: Mar 26, 2013
Posts: 9
I am trying to improve my understanding of remote EJB invocation.

I have code like this working, which does a remote JNDI lookup on my server:


But that seems way to complicated, and hardcodes a lot of application-specific data into my application; for example, if I wanted to use a different server or renumber my network, I would have to modify my application then recompile and redeploy.

I have seen some solutions that use "jndi.properties", but so far I haven't gotten any to work, and at any rate this would still require me to recompile and redeploy to change anything.

Is there a simpler way of doing this that doesn't require hardcoding my network details into my app? Or is this the best I can do?

Thanks!

-----Scott.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10240
    
168

The jndi.properties is the typical way to externalize that information. What problems did you run into while using that file? Also where is this lookup happening from? A standalone client application?

[My Blog] [JavaRanch Journal]
Scott Gifford
Greenhorn

Joined: Mar 26, 2013
Posts: 9
Jaikiran Pai wrote:The jndi.properties is the typical way to externalize that information. What problems did you run into while using that file?

I could not figure out where to put the file so it would be recognized, and I wasn't able to find clear documentation of where it should go, or any good way to troubleshoot.
Also where is this lookup happening from? A standalone client application?

A servlet.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10240
    
168

Scott Gifford wrote:
Jaikiran Pai wrote:The jndi.properties is the typical way to externalize that information. What problems did you run into while using that file?

I could not figure out where to put the file so it would be recognized, and I wasn't able to find clear documentation of where it should go, or any good way to troubleshoot.


It should be in the classpath of the invoking application. Since you say you are invoking it from a servlet, try placing the jndi.properties in the .war/WEB-INF/classes folder since the resources in that folder are available in the classpath of the application.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Best way to invoke remote EJB