XNSIO
  About   Slides   Home  

 
Managed Chaos
Naresh Jain's Random Thoughts on Software Development and Adventure Sports
     
`
 
RSS Feed
Recent Thoughts
Tags
Recent Comments

JNDI binding conflict issues

Trying to deploy 2 applications [EARs] on the same application server and having JNDI binding conflict issues?

If you are using Websphere, this might help.

1. Remove all JNDI name bindings from Web and EJB modules (ibm-web-bnd.xmi and ibm-ejb-jar-bnd.xmi) from both your applications
2. Change all EJB resource reference names to match the EJB name in the DD, prefixed by ejb. For example the ejb-jar shows:

ejb-name>LoginBean /ejb-name>
home>com.xyz.abc.LoginHome /home>

The EJB reference in the Web or EJB DD using this bean should be named:
ejb/LoginBean

This is actually quite intuitive compared to setting up the JNDI names in the bindings.

3. Updated the redeploy script with the following
AdminApp.install(application, ‘[-server server1 usedefaultbindings defaultbinding.ejbjndi.prefix ‘+jndiPrefix+‘]‘)

Using the -defaultbindings and the jndiPrefix=ejb/app1 defaults the EJB JNDI names to: ejb/app1/LoginBean and the lookup works properly from web

All this appears to work nicely and prevents any non-EJB names from being prefixed (which results in JMS connection factory and/or destination lookup failures). In addition, it has the nice side-effect that we do not have to specific any EJB JNDI names as part of the applications DDs.

Another interesting thing I found was if we provide a binding file with the appropriate JNDI names defined in it,
AdminApp.install(application, ‘[-server server1 usedefaultbindings defaultbinding.ejbjndi.prefix ‘+jndiPrefix+‘]‘)
does not overwrite the JNDI names. It leaves it the way we had defined in our bnd file and everything works the way it used to work before. For modules which do not have the bnd files, they will now be deployed with the prefixed JNDI name.

Bingo!

P.S: usedefaultbindings defaultbinding = should be read as dash usedefaultbindings dash defaultbinding


    Licensed under
Creative Commons License