R.Kaka
R.Kaka

Reputation: 167

How to deploy EJB project and JPA project in EAR project

I create 2 projects one is EJB and one is JPA. JPA project define entities classes, and persistent.xml. EBJ project import JPA project, I defined EJB session bean to connect database by entity manager. please refer below image for details. But when running on Jboss 7, error happend.

enter image description here

03:23:59,546 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC00001: Failed to start service jboss.deployment.subunit."TestApps.ear"."TestEJB.jar".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."TestApps.ear"."TestEJB.jar".POST_MODULE: Failed to p
rocess phase POST_MODULE of subdeployment "TestEJB.jar" of deployment "TestApps.ear"
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) [rt.jar:1.6.0_22]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.6.0_22]
        at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_22]
Caused by: java.lang.RuntimeException: Error getting reflective information for class com.ejb.services.LotUpdatManagerBean with ClassLoader ModuleClassLoader for Module "deployment.TestApps.ear.TestEJB.jar:main" from Service Module Loader
        at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:70) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
        at org.jboss.as.ee.metadata.MethodAnnotationAggregator.runtimeAnnotationInformation(MethodAnnotationAggregator.java:58)
        at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.handleAnnotations(InterceptorAnnotationProcessor.java:85)
        at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.processComponentConfig(InterceptorAnnotationProcessor.java:70)
        at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.deploy(InterceptorAnnotationProcessor.java:55)
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
        ... 5 more
Caused by: java.lang.NoClassDefFoundError: com/test/model/LotUpdates
        at java.lang.Class.getDeclaredMethods0(Native Method) [rt.jar:1.6.0_22]
        at java.lang.Class.privateGetDeclaredMethods(Unknown Source) [rt.jar:1.6.0_22]
        at java.lang.Class.getDeclaredMethods(Unknown Source) [rt.jar:1.6.0_22]
        at org.jboss.as.server.deployment.reflect.ClassReflectionIndex.<init>(ClassReflectionIndex.java:65) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
        at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:66) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
        ... 10 more
Caused by: java.lang.ClassNotFoundException: com.test.model.LotUpdates from [Module "deployment.TestApps.ear.TestEJB.jar:main" from Service Module Loader]
        at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
        at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
        at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
        at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)
        at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
        at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
        ... 15 more

03:23:59,762 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "TestApps.ear" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.deployment.subunit.\"TestApps.ear\".\"TestEJB.jar\".POST_MODULE" => "org.jboss.msc.service.StartExce
ption in service jboss.deployment.subunit.\"TestApps.ear\".\"TestEJB.jar\".POST_MODULE: Failed to process phase POST_MODULE of subdeployment \"TestEJB.jar\" of deployment \"TestApps.ear\""}}
03:23:59,765 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015877: Stopped deployment TestEJB.jar in 2ms
03:23:59,767 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015877: Stopped deployment TestApps.ear in 4ms
03:23:59,768 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014777:   Services which failed to start:      service jboss.deployment.subunit."TestApps.ear"."TestEJB.jar".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."TestApps.ear"."TestEJB.jar".POST_MODULE: Failed to process phase POST_MODULE of subdeployment "TestE
JB.jar" of deployment "TestApps.ear"

I'm failed. Anyone can correct me, Show me the way to deploy(jpa project and ejb project in same ear).

Upvotes: 0

Views: 2796

Answers (3)

R.Kaka
R.Kaka

Reputation: 167

I did the same with eclipse on Ubuntu. EAR file contain ejb.jar and jpa.jar which jpa.jar is in *.ear/lib/ . Jboss 7 can deployed the ear packed. I think the root cause is jpa classes are built and packaged in jpa.jar, so that ejb.jar can load its.

Upvotes: 0

Gas
Gas

Reputation: 18020

You have 2 potential options:

  • if you TestJpa.jar is in ear\lib folder it should be visible by default in ejb module (ensure that EAR is in 6.0 version)
  • manually add via Deployment Assembly in EJB project, the JPA project - should result in changes in the manifest file for EJB module.

If you correctly configure it, using either way you should see the JPA project in the EJB Module > EAR Libraries in Eclipse, without need to add it as project in the Build Path

Upvotes: 1

JBA
JBA

Reputation: 2844

As follow up to our discussion in the comments i provide this "answer" as a first hook on what could possible have gone wrong.

Regarding the EAR structure The structure of the package types EAR, WAR and JAR are well defined and must be followed to generate enterprise archives (EARs) that later will run on application servers like JBoss.

You will find any required information on packaging under https://docs.oracle.com/javaee/6/tutorial/doc/bnaby.html (Note this is for Java EE 6).

Basicially thats the way to go and i wont be able to help you much more :(

But as requested in the comments i will try to point out some especially important points were linking happens and must be absolutly correct according to the above packaging conventions (i can tell you right away that our JPA-Modules for example are located in the lib-folder as well).

So if i open one of our (working) EARs i will see the following content inside it:

  • lib
  • META-INF
  • our-ejb-part.jar
  • our-website-application.war
  • our-webservice-application.war

Our ejb-part.jar for example does not contain any Java code at all. It however contains a META-INF folder with descriptors such as ejb-jar.xml and some propertie-files under a properties folder as well. It also defines the classpath inside the MANIFEST.MF. (I havent worked with JBoss for years - we currently use IBM Websphere hence we have -bnd.xml/-ext.xml deployment descriptors located in the META-INF folder as well ... i am not aware if Jboss needs similar deployment informations). There is nothing more to see here.

Forget about the two Web-Modules for now- you dont seem to have any web-part in the form of a .war file (which itself must follow certain package requirements as defined in the oracle documentation).

But Note that if you have ANY EJB- or WEB-Modules they must be listed in the application.xml file located in the META-INF file (not the META-INF folder of the ejb but in the META-INF folder of the EAR located on the same level as /lib, /our-ejb-part.jar, etc.). Also note that inside that META-INF directory we again have the two Websphere deployment descriptors as well as a empty MANIFEST.MF).

Finally we have the lib folder that contains all of our EAR-Dependencies (and most of the Web-Part dependencies) are located at. That is the location we keep our JPA-, Commons-, Service-, Service-Implementations-, etc. Modules of a component (rather than having them inside the ejb-part.jar ... but i cant consider if this is a good practise).

So comming back to your situation there could be lots of things going wrong - i recommend you add a print-screen of the contents of your final *.ear file rather than the above eclipse view to probably get further advices. The main problem of that eclipse view is that at least i dont know how exactly your final .ear file will look like (There is for example only the WEB-INF folder with the application.xml located under EAR Content.

Sorry i wont be a help from here on since i dont have any JBoss knowledge (the log may imply whats wrong on a even more detailed level than i can interpret ... i currently just know your EAR likely wont contain the class LotUpdates or it may be there but isnt added to the classpath properly)

Upvotes: 0

Related Questions