File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Murach's Java Servlets and JSP this week in the Servlets 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: 9913
    
158

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: 9913
    
158

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.
 
jQuery in Action, 2nd edition
 
subject: Best way to invoke remote EJB
 
Similar Threads
EJB3 Remote Performance problem
client application connecting to local server after failing to connect to remote server
Accessing Remote EJB 3: Best Practice
glassfish to JBoss communication through RMI
Ed Roman - Mastering EJB's