users@glassfish.java.net

Re: deploy multiple instances of the same application in one Glassfish serv

From: <glassfish_at_javadesktop.org>
Date: Fri, 04 Apr 2008 09:28:59 PST

Yea, unfortunately the EJB Remote names are a flat namespace that encompasses the entire server, so there can't be any duplicates.

The solution is that you need to do two things.

One, you need to tweak the ejb-jar.xml for each different deploy. Here you can effectively rename each interface when its deployed to the server.

The other thing you need to do is rely solely on the local java:comp/env for your JNDI look ups for the remote beans, and then map them appropriately to the new names that you define in your ejb-jar.xml.

Typically, the "easy way" is to look up remote interfaces directly by their remote name, as this you can get "for free" with no configuration.

But, those are mapping to the global name space. Using java:comp/env you can use the local namespace. Now, the nice thing about using the java:comp/env is that the names stay the same, so your application code does not change. The only thing that changes between Developer1's deploy and Developer2's deploy is the ejb-jar.xml. I also don't know if when you load an ejb via it's interface name, whether that's a global or local reference.

This has been a long term feature of EJB, but it's just rarely used and most folks don't have the issue you do. But the capability is there. Perhaps someone more knowledgable will post with a specific example of how to do this.
[Message sent by forum member 'whartung' (whartung)]

http://forums.java.net/jive/thread.jspa?messageID=267773