4

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?

Pascal Thivent
  • 535,937
  • 127
  • 1,027
  • 1,106
Travis Dixon
  • 915
  • 2
  • 8
  • 10

2 Answers2

1

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/

KarlP
  • 4,959
  • 2
  • 24
  • 40
Travis Dixon
  • 915
  • 2
  • 8
  • 10
0

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

Arjan Tijms
  • 36,666
  • 12
  • 105
  • 134
  • That seems to get me some of the way, however now my ejb clients are being denied due to not having adequate roles. From the error message I can see it's picking up the correct username, but not mapping to the roles. It's using the FileRegistrySample that comes with websphere in my dev environment, and the same configuration worked fine with the old ejb2 setup. Have they done something different with authentication? – Travis Dixon Jun 16 '09 at 02:14