EJB Module Private to an Enterprise App

Hello sorry if this question seems basic, I am using NB 5.5 and Sun App Server 9.0. Suppose I have an EJB module called "SharedModule" that provides core functionality and is intended to be used by multiple developers in an organization by allowing them to "plug it in" to their Enterprise App.

Developer A creates an Enterprise App in NB called "AppA" and adds "SharedModule" as a module for the app then deploys to the server.

Developer B creates an Enterprise App in NB called "AppB" and adds "SharedModule" as a module for the app then deploys to the same server.

Developer B's deployment fails because of JNDI name conflict due to Developer A's deployment of "SharedModule".

Setting aside for a moment whether or not the above scenario is a good use of EJB modules, is there a way to configure either the App Server or on the NB side to declare an EJB module "private" to a particular Enterprise App so the server will set up boundaries between to the 2 applications to avoid all conflicts between them? Thank you

[1051 byte] By [bryan4587a] at [2007-11-26 20:01:12]
# 1
OK it appears the above will work as long as the beans in the shared module do not have remote interfaces
bryan4587a at 2007-7-9 22:59:32 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

Hi Bryan,

This can be made to work with Remote interfaces as well. Global JNDI names are considered

a deployment-time piece of configuration.All you would need to do is make sure the Remote

JNDI name for each of the applications is unique.

This is why in the Java EE programming

model there's a level of indirection between the portable java:comp/env names that

components should use to lookup resources and global JNDI names.It allows the application

to be deployed multiple times or to different application servers without having to change any

application code or standard deployment descriptors.That's why we always recommend against

the use of global JNDI names within the application code itself.

Here's a presentation on this topic :

https://glassfish.dev.java.net/javaee5/ejb/compdependencies_xmlforum_nov15.pdf

--ken

ksaksa at 2007-7-9 22:59:32 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

Hi Ken, thank you, very informative link. I guess there is a way to go before the naming conflicts can be avoided with little or no developer intervention in config files? I guess I am looking for the functionality (and maybe it is there, I just haven't looked hard enough) where you can assemble an enterprise app calling it "MyApp" assume the following structure:

App.ear "MyApp"

\some-war.war

\some-ejb-module.jar

This is the type functionality I was hoping for:

When you deploy the ear to the server, the server will create a namspace for the application "MyApp" and assign jndi names for all the objects relative to the application namespace. So assume in some-ejb-module.jar there is a session bean called "MyBean1" the server assigns it's remote interface the global lookup name "java:comp/env/MyApp/MyBean1"

So in your servlet or webservice inside the .war when you have

@EJB(name="MyBean1") it will resolve to "java:comp/env/MyApp/MyBean1" since the servlet and the bean are part of the same application

This type of structure would allow the second to developer to deploy his application "MySecondApp" to the same server with no modification to any deployment files and not have any global conflicts with the first app and have the same code his servlet resolve to "java:comp/env/MySecondApp/MyBean1"

thanks!

bryan4587a at 2007-7-9 22:59:32 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...