• Post Reply Bookmark Topic Watch Topic
  • New Topic

JNDI/EJB deployment help

 
Alan Peltz
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a stateless session bean (we will call it StatelessSB) which uses some entity beans (we will call one of them EntityBean). When we build, these beans get put into projectEjb.jar and that jar gets put into project.ear (along with project.jar and deploymentDescrpitor.xml). Project is a fine application and works wonderfully. Now I have something called OtherProject which would benefit greatly from using StatelessSB. I can include projectEjb.jar and make a new deploymentDescriptor.xml in OtherProject, but, since I already deployed Project to my server, I get a message that says that StatelessSB is �already registered�. I could change the deployment descriptors in OtherProject to register StatelessSB under a different name, but then there is a problem. StatelessSB calls EntityBean, so the JNDI lookup for EntityBean would have to be unique per project too, which really defeats the purpose of reuse.
So what do I do? I could make some sort of configuration file where I could put a prefix that I put on every JNDI name for every project (this would be insane). I have thought about registering each project under a different namespace. I don�t really know how to do that, but I think I could figure it out. I feel like I am missing a piece to the puzzle. I could just have OtherProject dependent on Project, so it wouldn�t run without it. I have considered deploying all EJBs separately. I�m not sure what is the best solution.
That�s where I am. Any help would be greatly appreciated. If I can clarify anything, let me know. Thanks!!
 
Tim Holloway
Bartender
Posts: 18408
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the EJB is truly independent of both projects, for neatness' sake, I'd put it into an EAR all its own and have the two webapp EARs reference it. If one webapp is critically involved with the EJB, then the other webapp should call into the first one.
Your web.xml file allows avoiding the hard-coding of resource names into you webapp program code. There's a specific type of entry where you associate the webapp's local JNDI reference name with the actual external JNDI name. Many containers (Tomcat for one) allow yet another level of aliasing and/or overriding so that you have complete flexibility in JNDI mapping of EJBs and other resources.
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim's suggestions and more can be found in this article.
Kyle
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!