5 Replies Latest reply on Jun 18, 2014 9:19 AM by smarlow

    How to disable JPA in wildfly for a module?

    rsoika

      Hi,

      I have a question about a deployment situation which was a little bit unexpected to me and maybe this is an issue for WildFly.

      I develop the workflow project www.imxis.org. This project contains a JEE component library (imixs-workflow-engine.jar  - github) containing a set of EJB Entities and also local/remote EJB Session Beans. Typically this libary is bundled into a Web or an EAR application to add the worklfow engine behavior. The library contains no persistence.xml or no ejb-jar.xml file because its the stuff of the application to decide how the components should be used in a enterprise application.

      Typically a Web Application defines its own persistence.xml to deploy the persisctenc-unit and ejb-jar.xml to define the behavior of the session beans.

       

      Wildfly is perfectly suited because it does not require any additional proprietary EJB deployment descriptors like GlassFish (Thanks for this great JEE Server!).

      But a problem for WildFly seems to be a scenario when no JPA is needed. This can happen when a application only need the remote interfaces for the Session Beans contained in the component library. Then the web client connect remotely to another instance of the workflow engine. So in this case I need no deployment of the EJBs or JPA entities because I use only the remote interface in the web client.

       

      This means for GlassFish that my Web module has not ejb-jar.xml and not persitence.xml. Everything woks fine. But when I try to deploy the same war into WildFly I got the deployment error listed below because of the missing persistence.xml.

      To solve this issue I added an empty persistence.xml only declaring the jpa-unit:

       

        <persistence-unit name="org.imixs.workflow.jee.jpa">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        </persistence-unit>
      

       

      Then the application will be deployed and works on WildFly. But with this persitence.xml a deployment on GlassFish is no longer possible because GlassFish complains about the empty persitence-unit. So there is the conflict building a platform independent web module.

       

      My question is: Is it possible to disable JPA for a web module with a jboss descriptor? Is this a known issue or is this a lack of precision of the JEE specification? I thought when I did not provide a persistence.xml no entity ejbs would be deployed into the container?

       

      You can take a look at a example for both kinds of applications:

      With EJBs and JPA: https://github.com/imixs/imixs-jsf-example

      and without EJBs and JPA only using the remote interfaces: https://github.com/imixs/imixs-admin

       

      Thanks for help or some ideas

       

      Ralph

       

      -----------------

      This is the deployment error on glassfish when no persistence.xml exits

      ----------------

       

       

      22:51:37,894 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC000001: Failed to start service jboss.deployment.unit."imixs-admin-3.2.0.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."imixs-admin-3.2.0.war".INSTALL: JBAS018733: Failed to process phase INSTALL of deployment "imixs-admin-3.2.0.war"
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:166) [wildfly-server-8.0.0.Final.jar:8.0.0.Final]
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.0.Final.jar:1.2.0.Final]
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.0.Final.jar:1.2.0.Final]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_55]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_55]
        at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_55]
      Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011047: Component class org.imixs.workflow.jee.ejb.EntityService for component EntityService has errors: 
      JBAS011440: Can't find a persistence unit named org.imixs.workflow.jee.jpa in deployment "imixs-admin-3.2.0.war"
        at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor$1.handle(ModuleJndiBindingProcessor.java:159)
        at org.jboss.as.ee.component.ClassDescriptionTraversal.run(ClassDescriptionTraversal.java:54)
        at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.processClassConfigurations(ModuleJndiBindingProcessor.java:152)
        at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.deploy(ModuleJndiBindingProcessor.java:145)
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:159) [wildfly-server-8.0.0.Final.jar:8.0.0.Final]
        ... 5 more
      
      
      22:51:37,903 ERROR [org.jboss.as.controller.management-operation] (XNIO-1 task-1) JBAS014613: Operation ("full-replace-deployment") failed - address: (undefined) - failure description: {
          "JBAS014671: Failed services" => {"jboss.deployment.unit.\"imixs-admin-3.2.0.war\".INSTALL" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"imixs-admin-3.2.0.war\".INSTALL: JBAS018733: Failed to process phase INSTALL of deployment \"imixs-admin-3.2.0.war\"
          Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011047: Component class org.imixs.workflow.jee.ejb.EntityService for component EntityService has errors: 
      JBAS011440: Can't find a persistence unit named org.imixs.workflow.jee.jpa in deployment \"imixs-admin-3.2.0.war\""},
          "JBAS014771: Services with missing/unavailable dependencies" => ["jboss.deployment.unit.\"imixs-admin-3.2.0.war\".weld.weldClassIntrospector is missing [jboss.deployment.unit.\"imixs-admin-3.2.0.war\".beanmanager]"]
      }
      22:51:37,917 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-7) JBAS015877: Stopped deployment imixs-admin-3.2.0.war (runtime-name: imixs-admin-3.2.0.war) in 10ms
      22:51:37,918 ERROR [org.jboss.as.controller.client] (XNIO-1 task-1) JBAS014781: Step handler org.jboss.as.server.deployment.DeploymentHandlerUtil$4@7abb9dd for operation {"operation" => "full-replace-deployment","content" => [{"hash" => bytes { 0xac, 0x66, 0x8f, 0x0c, 0xa1, 0x36, 0xa0, 0xf1, 0x8c, 0xd8, 0xcf, 0xb4, 0x18, 0x57, 0xb7, 0xc2, 0xd1, 0x46, 0x31, 0x73 }}],"name" => "imixs-admin-3.2.0.war","address" => undefined,"operation-headers" => {"access-mechanism" => "HTTP"}} at address [] failed handling operation rollback -- java.util.NoSuchElementException: No child 'name' exists
      
        • 1. Re: How to disable JPA in wildfly for a module?
          wdfink

          From a quick look I suppose you might add an annotation which reference an Entitymanager or JPA stuff and the server gets confused

          • 2. Re: Re: How to disable JPA in wildfly for a module?
            rsoika

            My entity beans a quite simple. Looks like this:

             

            
            @javax.persistence.Entity
            public class Entity implements java.io.Serializable {
              private static final long serialVersionUID = 1L;
              private String id;
            .....
            }
            

             

            Why WildFly cares about these beans if I specify no persistence.xml?

            • 3. Re: Re: How to disable JPA in wildfly for a module?
              smarlow

              Is there a @PersistenceUnit or @PersistenceContext in org.imixs.workflow.jee.ejb.EntityService?

              • 4. Re: Re: How to disable JPA in wildfly for a module?
                rsoika

                yes there is a @PersistenceContext in my EntityService EJB:

                 

                package org.imixs.workflow.jee.ejb;
                ....
                ..

                @DeclareRoles({ "org.imixs.ACCESSLEVEL.NOACCESS",

                  "org.imixs.ACCESSLEVEL.READERACCESS",

                  "org.imixs.ACCESSLEVEL.AUTHORACCESS",

                  "org.imixs.ACCESSLEVEL.EDITORACCESS",

                  "org.imixs.ACCESSLEVEL.MANAGERACCESS" })

                @RolesAllowed({ "org.imixs.ACCESSLEVEL.NOACCESS",

                  "org.imixs.ACCESSLEVEL.READERACCESS",

                  "org.imixs.ACCESSLEVEL.AUTHORACCESS",

                  "org.imixs.ACCESSLEVEL.EDITORACCESS",

                  "org.imixs.ACCESSLEVEL.MANAGERACCESS" })

                @Stateless

                @LocalBean

                public class EntityService implements EntityServiceRemote {
                ....

                @PersistenceContext(unitName = "org.imixs.workflow.jee.jpa")

                private EntityManager manager;

                • 5. Re: How to disable JPA in wildfly for a module?
                  smarlow

                  > Why WildFly cares about these beans if I specify no persistence.xml?

                   

                  The typical case that I have seen in the past, is a misplaced persistence.xml and WildFly complains as loudly as possible (deployment error), until you move the misplaced persistence.xml to the correct location.

                   

                  Currently, the only (other) way to work around the deployment error, would be to disable the JPA subsystem in standalone.xml.

                   

                  Other suggestions that have been made in the past, are to make the persistence unit look up lazy (defer search for the named persistence unit, until the first use).  Perhaps this could be a an option (probably not the default).

                   

                  Another idea would be introducing a way to silently ignore the persistence unit search (e.g. ignore null returned from persistence unit search).