Search code examples
ejbjndiwar

EJB Portability


I was talking to a friend about the portability of web applications (.war files) from application server to application server. Specifically, if I had a .war file that contained my business logic, my ejb jar, and my 'web' components, like html/css/js.

He seemed to suggest that I could deploy the war to a jboss server just as easily as I could a glassfish server without having to modify the code.

My comment was that I don't think that's correct, because if, for example, In one of my servlets I'm doing an EJB lookup, the exported JNDI name might vary from server vendor to server vendor. So if I deploy an EJB to a jboss server, the JNDI name that I use to look it up might be slightly different than if I have it deployed on a glassfish server, so the JNDI lookup string is going to be different.

Is that not true? Is the JNDI naming convention standard? I'm still learning.


Solution

  • You are right, sometimes you can have problems like that. For example most application servers use java:comp/UserTransaction as a JNDI for UserTransaction interface, but in JBoss AS7 the JNDI is java:jboss/UserTransaction.

    On the other hand you can have JNDI names as configurable parameters in your application and porting should be easier.

    To summarize there is a chance that your application will be ported to another server without any changes, but you can't take it for granted. Usually when you have problem like that it's not an easy one.