0

I use Maven, WebSphere 6.x, RAD 8.x and got a maven web project.

I tried to add a MDB to the web project. I placed the MDB under src/main/java and placed ejb-jar.xml and the websphere binding under WEB-INF directly

When I deploy the web project I don't see the MDB getting deployed.

How can I fix this?

Should I add something in web.xml informing the web app that it has an EJB?

I asked a different question Here where i created a MDB project separately and tried to depend on classes inside a web project and got a response that I could deploy my EJB as part of a web app itself.

The MDB deploys properly when deployed as a separate ejb project. But the dependencies on the web project are unable to be found by the EJB project during runtime. Its throwing No Class Found exception.

So please help me on one of these 2

1) How to create EJB inside WAR and make the WAR understand that it has an EJB? - in this case the war is not recognizing the ejb

or

2)How to make a stand alone EJB project identify classes from inside a web project? - in this case the ejb is not recognizing the war classes

Community
  • 1
  • 1
juniorbansal
  • 1,249
  • 8
  • 31
  • 51

1 Answers1

1

It is not possible to create EJB inside WAR in WebSphere 6.1 as it is using Java EE 1.4. You will need to upgrade to WebSphere 8.x for that.

For WebSphere 6.1 you need to package war and ejb in single ear and change classloader settings for your application. After you deploy application, in the console go to Enterprise Applications > yourApp > Class loader and in the WAR class loader policy set Single class loader for application (these names are from 8.5 but you should have something very similar in 6.1, I dont have 6.1 console at hand as it very old and no longer supported).

For details see Configuring application class loaders

Gas
  • 17,601
  • 4
  • 46
  • 93
  • 1
    I would up-mark your answer if it was not for your suggestion to mess with the class loader. I'm pretty sure that you cannot configure WAS 6.x to make WAR classes accessible to classes in the EAR (not to mention it's impact on portability). The OP needs to move all the dependent classes into the EJB jar or a jar in the EAR/lib directory. – Steve C Mar 19 '15 at 13:32
  • 1
    @SteveC Check [this](http://www-01.ibm.com/support/knowledgecenter/SSAW57_6.1.0/com.ibm.websphere.nd.doc/info/ae/ae/trun_classload_entapp.html?cp=SSAW57_6.1.0%2F1-7-6-2) - "Setting the value to Single class loader for application causes the application class loader to load the Web module contents as well as the EJB modules, shared libraries, RAR files, and dependency JAR files associated to the application." And regarding portability - OP is asking for solution for ancient specific WAS. – Gas Mar 19 '15 at 13:44
  • 1
    Yeah - Ok. Just flag the portability issue. I've done many WAS->JBoss/Wildfly migrations and this would be quite a problem – Steve C Mar 19 '15 at 14:02
  • @Gas - Thank You.As you advised in the other thread I have added everything into ejb and made the web dependent on ejb.Now facing some issue in writing a test client.Posted that here.http://stackoverflow.com/questions/29202105/java-class-not-found-in-rad-8-5-client-to-post-message-to-websphere-q – juniorbansal Mar 23 '15 at 03:19