Question

The EJB3 spec indicates that EJB2 and EJB3 can co-exist in a single application.

I wish to migrate my EJB2 stateless session beans to EJB3 stateless session beans.
This question does not relate to JPA at all (that is a separate piece of work to be carried out in the future)

I'm running on websphere 6.1 with the EJB3 feature pack installed and patched and the profile is augmented (an ejb3 sample app confirms that it works)

What changes do I need to make to my code, web.xml, application.xml, ejb-jar.xml and other websphere specific bindings to convert a SINGLE ejb from 2 to 3?

Was it helpful?

Solution

I'm going to have a crack at answering my own question as I go along.
Here's how I got through it

The following xml files used to have doctypes, but must now have namespaces:

myApp.ear/META-INF/application.xml

<application version="5" xmlns="http://java.sun.com/xml/ns/javaee"
                         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee  http://java.sun.com/xml/ns/javaee/application_5.xsd">

myApp.ear/web.war/WEB-INF/web.xml

 <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
                        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

myApp.ear/ejb.jar/META-INF/ejb-jar.xml

<ejb-jar id="ejb-jar_ID" version="3.0" 
            xmlns="http://java.sun.com/xml/ns/javaee" 
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
            xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">

The following changes have been made to web.xml

  • taglib elements are now under a jsp-config element

  • the display-name element has been removed from filter elements and servlet elements

Remove myApp.ear/ejb.jar/META-INF/ibm-ejb-jar-bnd.xmi

JNDI lookups change all your local ejb jndi lookups to use ejblocal:[classname]

I also removed my jdbc resource ref from ejb-jar.xml mappings and am using a global lookup instead

The security problem I was having was because I removed ibm-application-bnd.xmi where it binds users and groups to roles/

OTHER TIPS

You need to put Java EE xml namespaces in the three xml files you mentioned to start with. Then I think you remove your WAS binding files and use a different jndi lookup

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top