This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Best way to invoke remote EJB

 
Scott Gifford
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Scott Gifford
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic