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?
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.