Reputation: 11
So we are migrating a project written in EJB 2.1 to EJB 3.1 in parts. To start with, we have picked up 1 ejb and incorporating 3.1 changes in it, without touching other exisitng 2.1 beans. Apart from other EJB 3.1 changes, we also changed the version of existing ejb-jar.xml to version="3.1" as without changing it, the EJB 3.1 beans were not binding.
However, after the version has been changed to 3.1, the EJB beans written in 2.1 cannot be looked up and the exception is :
"javax.naming.NameNotFoundException:
Name "ejb/ejb/gov/michigan/access/business/services/ABTransactionManagedEJBLocalHome"
not found in context "local:"".
Is it possible to have both 2.1 & 3.1 components together in an application? If yes, what configurations would I have to make to support it? Have read a lot of material online and also tried a lot of stuffs, but nothing seems to work.
Upvotes: 0
Views: 902
Reputation: 33936
By "2.1 components", I assume you mean the EJB is exposing a home/component interface, and by "3.1 components", I assume you mean the EJB is exposing a business interface. (Note that EJB modules are versioned, but EJB components are not. An EJB can expose both home/component interfaces and business interfaces, and they can be exposed via annotations or XML.)
In WebSphere Application Server, the "local:" context is an internal detail of EJB 2.x modules, and the EJB container does not bind to this context in EJB 3.0 (and later) modules. However, as of v7.0, the EJB container does bind to the "ejblocal:" context for all module versions. See the CNTR0167I messages in SystemOut.log to determine the correct (non-internal) JNDI lookup name.
Upvotes: 0
Reputation: 6939
The answer for your first question is clear: Yes, you can use them within one application. We have ourselves an application which is quite some years old now and still has some parts written in J2EE and newer ones in Java EE, both within 1 EAR file.
Concerning your exception, I can't say what exactly it is, but it looks like using a wrong context for lookup. Sadly, this is container specific, so maybe it helps to look for container specific documentation on how to do the lookup. For JBOss you'll find an example here.
Upvotes: 1