13 Replies Latest reply on Jul 21, 2010 1:11 PM by marcos_aps

    Share persistence.xml file between two EJB modules in EAR

    marcos_aps

      JBoss 6.0.0 M3

       

      Hello, everybody!

       

      I have two EJB modules in an EAR module. I would like to know how to share a single persistence.xml file with these two EJB modules. If I replicate the persistence.xml file in the two EJB modules, the EAR project deploys ok, but of course that's not what we want. If I remove the persistence.xml file from any of the EJB projects, the EAR doesn't deploy properly. I'm stuck with this. I've already tried many kind of configurations but none worked. I really would like to have some help with this issue to proceed working. This is my EAR structure:

       

      solicitacoes-ejb.jar       (EJB session beans)

      solicitacoes-dao.jar       (EJB interfaces)

      solicitacoes-dao-jpa.jar   (EJB session beans)

      solicitacoes-ejbClient.jar (entities and EJB interfaces)

      solicitacoes-web.war

      META-INF/

       

      This is my application.xml file:

       

      <?xml version="1.0" encoding="UTF-8"?>

      <application

      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

      xmlns="http://java.sun.com/xml/ns/javaee"

      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd"

      version="5">

          <display-name>solicitacoes-ear</display-name>

          <module>

              <ejb>solicitacoes-ejb.jar</ejb>

          </module>

          <module>

              <ejb>solicitacoes-dao-jpa.jar</ejb>

          </module>

          <module>

              <web>

                  <web-uri>solicitacoes-web.war</web-uri>

                  <context-root>solicitacoes</context-root>

              </web>

          </module>

      </application>

       

      If I remove the persistence.xml file from one of the EJB modules, let's say solicitacoes-dao-jpa.jar, I get this error when deploying the EAR file:

       

      16:09:44,062 ERROR [Ejb3Deployment] Exception while processing container metadata for EJB: LocalizadorSetoresDAOBean in unit: solicitacoes-dao-jpa.jar

      16:09:44,078 ERROR [AbstractKernelController] Error installing to Real: name=vfs:///C:/jboss-6.0.0.20100429-M3/server/default/deploy/solicitacoes-ear.ear state=PreReal mode=Manual requiredState=Real: org.jboss.deployers.spi.DeploymentException: Error deploying solicitacoes-dao-jpa.jar: Exception while processing container metadata for EJB: LocalizadorSetoresDAOBean in unit: solicitacoes-dao-jpa.jar

      at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:189) [:6.0.0.20100429-M3]

      at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:59) [:6.0.0.20100429-M3]

      at org.jboss.deployers.vfs.spi.deployer.AbstractSimpleVFSRealDeployer.deploy(AbstractSimpleVFSRealDeployer.java:56) [:2.2.0.Alpha4]

      at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62) [:2.2.0.Alpha4]

      at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:55) [:2.2.0.Alpha4]

      at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:179) [:2.2.0.Alpha4]

      at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1857) [:2.2.0.Alpha4]

      at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1575) [:2.2.0.Alpha4]

      at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1628) [:2.2.0.Alpha4]

      at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1516) [:2.2.0.Alpha4]

      at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:377) [jboss-dependency.jar:2.2.0.Alpha9]

      at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2042) [jboss-dependency.jar:2.2.0.Alpha9]

      at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1081) [jboss-dependency.jar:2.2.0.Alpha9]

      at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1320) [jboss-dependency.jar:2.2.0.Alpha9]

      at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1244) [jboss-dependency.jar:2.2.0.Alpha9]

      at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1137) [jboss-dependency.jar:2.2.0.Alpha9]

      at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:937) [jboss-dependency.jar:2.2.0.Alpha9]

      at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:652) [jboss-dependency.jar:2.2.0.Alpha9]

      at org.jboss.deployers.plugins.deployers.DeployersImpl.change(DeployersImpl.java:2008) [:2.2.0.Alpha4]

      at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:1101) [:2.2.0.Alpha4]

      at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:679) [:2.2.0.Alpha4]

      at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117) [:6.0.0.20100429-M3]

      at org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70) [:6.0.0.20100429-M3]

      at org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53) [:6.0.0.20100429-M3]

      at org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:403) [:6.0.0.20100429-M3]

      at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:377) [jboss-dependency.jar:2.2.0.Alpha9]

      at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2042) [jboss-dependency.jar:2.2.0.Alpha9]

      at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1081) [jboss-dependency.jar:2.2.0.Alpha9]

      at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1320) [jboss-dependency.jar:2.2.0.Alpha9]

      at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1244) [jboss-dependency.jar:2.2.0.Alpha9]

      at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1137) [jboss-dependency.jar:2.2.0.Alpha9]

      at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:892) [jboss-dependency.jar:2.2.0.Alpha9]

      at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:639) [jboss-dependency.jar:2.2.0.Alpha9]

      at org.jboss.system.server.profileservice.repository.AbstractProfileService.registerProfile(AbstractProfileService.java:308) [:6.0.0.20100429-M3]

      at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:256) [:6.0.0.20100429-M3]

      at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:97) [:6.0.0.20100429-M3]

      at org.jboss.bootstrap.impl.base.server.AbstractServer.startBootstraps(AbstractServer.java:827) [jboss-bootstrap-impl-base.jar:2.1.0-alpha-5]

      at org.jboss.bootstrap.impl.base.server.AbstractServer$StartServerTask.run(AbstractServer.java:417) [jboss-bootstrap-impl-base.jar:2.1.0-alpha-5]

      at java.lang.Thread.run(Thread.java:619) [:1.6.0_20]

      Caused by: java.lang.Exception: Exception while processing container metadata for EJB: LocalizadorSetoresDAOBean in unit: solicitacoes-dao-jpa.jar

      at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:551) [:1.3.1]

      at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:182) [:6.0.0.20100429-M3]

      ... 38 more

      Caused by: java.lang.IllegalArgumentException: Container jboss.j2ee:ear=solicitacoes-ear.ear,jar=solicitacoes-dao-jpa.jar,name=LocalizadorSetoresDAOBean,service=EJB3 failed to resolve persistence unit null

      at org.jboss.injection.PersistenceUnitHandler.addPUDependency(PersistenceUnitHandler.java:135) [:1.3.1]

      at org.jboss.injection.PersistenceContextHandler.loadXml(PersistenceContextHandler.java:76) [:1.3.1]

      at org.jboss.ejb3.EJBContainer.processMetadata(EJBContainer.java:629) [:1.3.1]

      at org.jboss.ejb3.Ejb3Deployment.processEJBContainerMetadata(Ejb3Deployment.java:420) [:1.3.1]

      at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:529) [:1.3.1]

      ... 39 more

      Caused by: java.lang.IllegalArgumentException: Can't find a persistence unit named 'null' in AbstractVFSDeploymentContext@28359170{vfs:///C:/jboss-6.0.0.20100429-M3/server/default/deploy/solicitacoes-ear.ear/solicitacoes-dao-jpa.jar/}

      at org.jboss.jpa.resolvers.BasePersistenceUnitDependencyResolver.resolvePersistenceUnitSupplier(BasePersistenceUnitDependencyResolver.java:107) [:1.0.2-alpha-1]

      at org.jboss.ejb3.Ejb3Deployment.resolvePersistenceUnitSupplier(Ejb3Deployment.java:778) [:1.3.1]

      at org.jboss.ejb3.EJBContainer.resolvePersistenceUnitSupplier(EJBContainer.java:1517) [:1.3.1]

      at org.jboss.injection.PersistenceUnitHandler.addPUDependency(PersistenceUnitHandler.java:130) [:1.3.1]

      ... 43 more

       

      Thank you in advance.

       

      Marcos

        • 1. Re: Share persistence.xml file between two EJB modules in EAR
          marcos_aps

          I'm sorry for my insistence, but I need help with this issue. As you could see, the EJB container doesn't like to see an EJB module without a persistence.xml file. This is clearly a dumb decision though. I agree with it if there was only one EJB module in an EAR. But the container should have been smart enough to require only one persistence.xml file in an EAR module with more than one EJB module, and share that persistece context with the whole EAR.

           

          Acting the way it is acting now, the container forces us to duplicate the persistece.xml file and kill our application modularity. This is clearly wrong. I've already tried to put the entity classes and persistence.xml file in the lib directory of the EAR, but it didn't work either. The container needs to have the persistence.xml file in both EJB modules.

           

          I don't know if this is a JBoss implementation decision or if it comes from the Java EE 6 specification. Whatever it is, it goes against all good modular and good design decision. Please if some of you know how to solve this, took a little time to tell me how. I would be very grateful.

           

          Thank you again.

           

          Marcos

          • 2. Re: Share persistence.xml file between two EJB modules in EAR
            marcos_aps

            I think that I'm not the only one interested in getting an answer to this issue. I believe that many people want to know how to achieve this. An answer to this question, even if it is possible or not, and how to do it in case it is possible would help the community.

             

            Marcos

            • 3. Re: Share persistence.xml file between two EJB modules in EAR
              jaikiran

              Sorry, couldn't reply earlier. Here's what the JPA2 spec says:

               

               

              JPA2 Spec, Section 8.2:
              
              A persistence unit may be packaged within one or more jar files contained within a WAR or EAR, as a set of classes within an EJB-JAR file or in the WAR classes directory, or as a combination of these as defined below.
              
              A persistence unit is defined by a persistence.xml file. The jar file or directory whose META-INF directory contains the persistence.xml file is termed the root of the persistence unit.
              
              In Java EE environments, the root of a persistence unit must be one of the following:
                     * an EJB-JAR file
                     * the WEB-INF/classes directory of a WAR file[80]
                     * a jar file in the WEB-INF/lib directory of a WAR file
                     * a jar file in the EAR library directory
                     * an application client jar file
                     
              It is not required that an EJB-JAR or WAR file containing a persistence unit be packaged in an EAR unless the persistence unit contains persistence classes in addition to those contained within the EJB-JAR or WAR. See Section 8.2.1.6.
              
              NOTE: Java Persistence 1.0 supported use of a jar file in the root of the EAR as the root of a persistence unit. This use is no longer supported. Portable applications should use the EAR library directory for this case instead. See [9].
              

               

              So try packaging that persistence.xml in  .ear/lib/shared.jar/META-INF folder.

              • 4. Re: Share persistence.xml file between two EJB modules in EAR
                marcos_aps

                Hello, jaikiran! Sorry for the delay; I don't work on weekends.

                 

                Indeed, before posting my problem here I had already looked at that section of the JPA specification you pointed out here to know the valid locations to place the persistence.xml file. But the problem was that I followed it and it didn't work. I put the persistence.xml file in the solicitacoes-ejbClient.jar (entity classes, EJB interfaces), placed in the EAR lib directory and removed it from the two EJB modules, solicitacoes-ejb.jar and
                solicitacoes-dao-jpa.jar, and I got the same error:

                 

                Caused by: java.lang.IllegalArgumentException: Container jboss.j2ee:ear=solicitacoes-ear.ear,jar=solicitacoes-dao-jpa.jar,name=LocalizadorSetoresDAOBean,service=EJB3 failed to resolve persistence unit null
                at org.jboss.injection.PersistenceUnitHandler.addPUDependency(PersistenceUnitHandler.java:135) [:1.3.1]
                at org.jboss.injection.PersistenceContextHandler.loadXml(PersistenceContextHandler.java:76) [:1.3.1]
                at org.jboss.ejb3.EJBContainer.processMetadata(EJBContainer.java:629) [:1.3.1]
                at org.jboss.ejb3.Ejb3Deployment.processEJBContainerMetadata(Ejb3Deployment.java:420) [:1.3.1]
                at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:529) [:1.3.1]
                ... 39 more
                Caused by: java.lang.IllegalArgumentException: Can't find a persistence unit named 'null' in
                AbstractVFSDeploymentContext@23290620{vfs:///C:/jboss-6.0.0.20100429-M3/server/default/deploy/solicitacoes-ear.ear/solicitacoes-dao-jpa.jar/}
                at org.jboss.jpa.resolvers.BasePersistenceUnitDependencyResolver.resolvePersistenceUnitSupplier(BasePersistenceUnitDependencyResolver.java:107) [:1.0.2-alpha-1]
                at org.jboss.ejb3.Ejb3Deployment.resolvePersistenceUnitSupplier(Ejb3Deployment.java:778) [:1.3.1]
                at org.jboss.ejb3.EJBContainer.resolvePersistenceUnitSupplier(EJBContainer.java:1517) [:1.3.1]
                at org.jboss.injection.PersistenceUnitHandler.addPUDependency(PersistenceUnitHandler.java:130) [:1.3.1]
                ... 43 more

                 

                But after your post, I decided to try one more time to see what was wrong. After all, I was doing exactly what the specification says. Again I put the persistence.xml file in the solicitacoes-ejbClient.jar and got the error again. After that moved the solicitacoes-ejbClient.jar to where it was and removed the persistence.xml file from it. Now I put the persisntece.xml file in the solicitacoes-dao.jar (EJB dao interfaces) and placed it in the EAR lib directory and... it worked. I just don't know why it works with the solicitacoes-dao.jar and not with the solicitacoes-ejbClient.jar. Maybe because the later has entity classes, but I don't know why this can be a problem. Perhaps you know why.

                 

                Ok, now my application don't have a persisntece.xml file duplicated and has a better modular structure. Jaikiran, I want to thank you very much for you valuable help. This issue was very important to me.

                 

                Marcos

                • 5. Re: Share persistence.xml file between two EJB modules in EAR
                  jaikiran
                  But the problem was that I followed it and it didn't work. I put the  persistence.xml file in the solicitacoes-ejbClient.jar (entity classes,  EJB interfaces), placed in the EAR lib directory

                   

                  That should have worked, unless there's some bug in there. I have a feeling that the persistence.xml scanning is being skipped for jars which do not contain any EJBs. Can you, for the sake of testing, just add a simple (dummy) annotated EJB class in that client jar and see if that does the trick?

                  • 6. Re: Share persistence.xml file between two EJB modules in EAR
                    marcos_aps

                    jaikiran pai wrote:

                     

                    But the problem was that I followed it and it didn't work. I put the  persistence.xml file in the solicitacoes-ejbClient.jar (entity classes,  EJB interfaces), placed in the EAR lib directory

                     

                    That should have worked, unless there's some bug in there. I have a feeling that the persistence.xml scanning is being skipped for jars which do not contain any EJBs. Can you, for the sake of testing, just add a simple (dummy) annotated EJB class in that client jar and see if that does the trick?

                     

                    Jaikiran, the solicitacoes-dao.jar, that is in the EAR lib directory containing the persistence.xml file, also, like the solicitacoes-ejbClient.jar, doesn't have any annotated EJB classes. It only has annotated EJB interfaces (@javax.ejb.Local), like the solicitacoes-ejbClient.jar. But, unlike the solicitacoes-ejbClient.jar, it doesn't have any entity classes (@javax.persistence.Entity). Maybe, for some reason or another, the problem lies on this.
                    That's why it doesn't work with the solicitacoes-ejbClient.jar, because it has entity classes. Perhaps this doesn't make sense, but it is just what I think.

                     

                    Marcos

                    • 7. Re: Share persistence.xml file between two EJB modules in EAR
                      jaikiran

                      Any chance you can share that app or any similar app (preferably a small one) which reproduces this problem? Just want to be sure that it's not a bug in the persistence unit deployment.

                      • 8. Re: Share persistence.xml file between two EJB modules in EAR
                        marcos_aps

                        Ok, here's the project.

                         

                        I'm using:

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

                        - JBoss 6.0.0.M3
                        - JKD 6 Update 20
                        - Windows XP SP3

                         

                        Build instructions:

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

                        - Create the directory 'C:\Projeto\Java\Solicitacoes3' and unzip the zip file there.
                          You can use another directory, but you'll have to change the ant build file.
                        - Use the ant build.xml file located in 'C:\Projeto\Java\Solicitacoes3\solicitacoes-web'
                          to build and deploy the EAR file.

                         

                        I didn't bother attaching to the zip other jars needed by the application, because the application won't even have a change to use them, for you'll get an deployment error when starting JBoss:

                         

                        Caused by: java.lang.IllegalArgumentException: Can't find a persistence unit named 'null' in AbstractVFSDeploymentContext@4780842{vfs:///C:/jboss-6.0.0.20100429-M3/server/default/deploy/solicitacoes-ear.ear/solicitacoes-dao-impl.jar/}
                        at org.jboss.jpa.resolvers.BasePersistenceUnitDependencyResolver.resolvePersistenceUnitSupplier(BasePersistenceUnitDependencyResolver.java:107) [:1.0.2-alpha-1]
                        at org.jboss.ejb3.Ejb3Deployment.resolvePersistenceUnitSupplier(Ejb3Deployment.java:778) [:1.3.1]
                        at org.jboss.ejb3.EJBContainer.resolvePersistenceUnitSupplier(EJBContainer.java:1517) [:1.3.1]
                        at org.jboss.injection.PersistenceUnitHandler.addPUDependency(PersistenceUnitHandler.java:130) [:1.3.1]
                        ... 43 more

                         

                        But if you put the persistence.xml file in the solicitacoes-dao.jar and place this jar in the EAR lib directory the error will go away. Of course you also have to remove the solicitacoes-ejbClient.jar from the EAR lib directory, place it in the EAR root directory and also remove the persistence.xml file from it.

                         

                        Marcos

                        • 9. Re: Share persistence.xml file between two EJB modules in EAR
                          marcos_aps

                          In case you need the additional jars, I'm placing them here. You can place them in <JBOSS-HOME>\common\lib.

                           

                          Marcos

                          • 10. Re: Share persistence.xml file between two EJB modules in EAR
                            jaikiran

                            Thank you. I'll take a look at it.

                            • 11. Re: Share persistence.xml file between two EJB modules in EAR
                              marcos_aps

                              jaikiran pai wrote:

                               

                              Thank you. I'll take a look at it.

                               

                              You're welcome. In case you can't build the application because of missing jars in the build process, please tell me. I'm confident I provided all jars needed, but in case I've forgot any of them, tell me and I'll provide them as well.

                               

                              Marcos

                              • 12. Re: Share persistence.xml file between two EJB modules in EAR
                                jaikiran

                                I just gave it a try and couldn't reproduce it. Initially, the build.xml had a problem (it wasn't copying the persistence.xml to solicitacoes-ejbClient/META-INF). I fixed that and made some minor changes to the build file and built the ear. I then deployed it to 6.0.0.M3 (and even AS trunk) and it deployed fine without any errors. I could even see that the persistence.xml was being picked up:

                                 

                                 

                                22:15:35,959 INFO  [SessionFactoryImpl] building session factory
                                22:15:36,297 INFO  [SessionFactoryObjectFactory] Factory name: persistence.unit:unitName=solicitacoes-ear.ear/lib/solicitacoes-ejbClient.jar#solicitacoes
                                22:15:36,300 INFO  [NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
                                22:15:36,305 INFO  [NamingHelper] Creating subcontext: persistence.unit:unitName=solicitacoes-ear.ear
                                22:15:36,306 INFO  [NamingHelper] Creating subcontext: lib
                                22:15:36,306 INFO  [SessionFactoryObjectFactory] Bound factory to JNDI name: persistence.unit:unitName=solicitacoes-ear.ear/lib/solicitacoes-ejbClient.jar#solicitacoes
                                22:15:36,306 WARN  [SessionFactoryObjectFactory] InitialContext did not implement EventContext
                                22:15:36,306 INFO  [NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
                                22:15:36,958 INFO  [SessionSpecContainer] Starting jboss.j2ee:ear=solicitacoes-ear.ear,jar=solicitacoes-ejb.jar,name=GerenciadorFuncionariosBean,service=EJB3
                                22:15:37,044 INFO  [EJBContainer] STARTED EJB: br.urca.solicitacoes.ejb.GerenciadorFuncionariosBean ejbName: GerenciadorFuncionariosBean
                                22:15:37,048 INFO  [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:
                                
                                    solicitacoes-ear/GerenciadorFuncionariosBean/local - EJB3.x Default Local Business Interface
                                    solicitacoes-ear/GerenciadorFuncionariosBean/local-br.urca.solicitacoes.IGerenciadorFuncionarios - EJB3.x Local Business Interface
                                
                                22:15:37,049 INFO  [SessionSpecContainer] Starting jboss.j2ee:ear=solicitacoes-ear.ear,jar=solicitacoes-ejb.jar,name=VerificadorNovasSolicitacoesBean,service=EJB3
                                22:15:37,053 INFO  [EJBContainer] STARTED EJB: br.urca.solicitacoes.ejb.VerificadorNovasSolicitacoesBean ejbName: VerificadorNovasSolicitacoesBean
                                22:15:37,098 INFO  [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:
                                
                                    solicitacoes-ear/VerificadorNovasSolicitacoesBean/local - EJB3.x Default Local Business Interface
                                    solicitacoes-ear/VerificadorNovasSolicitacoesBean/local-br.urca.solicitacoes.IVerificadorNovasSolicitacoes - EJB3.x Local Business Interface
                                
                                22:15:37,189 INFO  [SessionSpecContainer] Starting jboss.j2ee:ear=solicitacoes-ear.ear,jar=solicitacoes-dao-impl.jar,name=LocalizadorSetoresDAOBean,service=EJB3
                                22:15:37,190 INFO  [EJBContainer] STARTED EJB: br.urca.solicitacoes.dao.jpa.LocalizadorSetoresDAOBean ejbName: LocalizadorSetoresDAOBean
                                22:15:37,194 INFO  [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:
                                
                                    solicitacoes-ear/LocalizadorSetoresDAOBean/local - EJB3.x Default Local Business Interface
                                    solicitacoes-ear/LocalizadorSetoresDAOBean/local-br.urca.solicitacoes.dao.ILocalizadorSetoresDAO - EJB3.x Local Business Interface
                                
                                22:15:37,199 INFO  [SessionSpecContainer] Starting jboss.j2ee:ear=solicitacoes-ear.ear,jar=solicitacoes-ejb.jar,name=LocalizadorFuncionarioBean,service=EJB3
                                22:15:37,200 INFO  [EJBContainer] STARTED EJB: br.urca.solicitacoes.ejb.LocalizadorFuncionarioBean ejbName: LocalizadorFuncionarioBean
                                22:15:37,211 INFO  [SessionSpecContainer] Starting jboss.j2ee:ear=solicitacoes-ear.ear,jar=solicitacoes-ejb.jar,name=LocalizadorSetoresBean,service=EJB3
                                22:15:37,212 INFO  [EJBContainer] STARTED EJB: br.urca.solicitacoes.ejb.LocalizadorSetoresBean ejbName: LocalizadorSetoresBean
                                22:15:37,215 INFO  [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:
                                
                                    solicitacoes-ear/LocalizadorSetoresBean/local - EJB3.x Default Local Business Interface
                                    solicitacoes-ear/LocalizadorSetoresBean/local-br.urca.solicitacoes.ILocalizadorSetores - EJB3.x Local Business Interface
                                
                                22:15:37,230 INFO  [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:
                                
                                    solicitacoes-ear/LocalizadorFuncionarioBean/local - EJB3.x Default Local Business Interface
                                    solicitacoes-ear/LocalizadorFuncionarioBean/local-br.urca.solicitacoes.ejb.ILocalizadorFuncionario - EJB3.x Local Business Interface
                                
                                22:15:37,272 INFO  [SessionSpecContainer] Starting jboss.j2ee:ear=solicitacoes-ear.ear,jar=solicitacoes-ejb.jar,name=GerenciadorFuncionarioAutenticadoBean,service=EJB3
                                22:15:37,273 INFO  [EJBContainer] STARTED EJB: br.urca.solicitacoes.ejb.GerenciadorFuncionarioAutenticadoBean ejbName: GerenciadorFuncionarioAutenticadoBean
                                22:15:37,276 INFO  [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:
                                
                                    solicitacoes-ear/GerenciadorFuncionarioAutenticadoBean/local - EJB3.x Default Local Business Interface
                                    solicitacoes-ear/GerenciadorFuncionarioAutenticadoBean/local-br.urca.solicitacoes.IGerenciadorFuncionarioAutenticado - EJB3.x Local Business Interface
                                
                                22:15:37,294 INFO  [SessionSpecContainer] Starting jboss.j2ee:ear=solicitacoes-ear.ear,jar=solicitacoes-ejb.jar,name=LocalizadorFuncionarioAutenticadoBean,service=EJB3
                                22:15:37,295 INFO  [EJBContainer] STARTED EJB: br.urca.solicitacoes.ejb.LocalizadorFuncionarioAutenticadoBean ejbName: LocalizadorFuncionarioAutenticadoBean
                                22:15:37,298 INFO  [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:
                                
                                    solicitacoes-ear/LocalizadorFuncionarioAutenticadoBean/local - EJB3.x Default Local Business Interface
                                    solicitacoes-ear/LocalizadorFuncionarioAutenticadoBean/local-br.urca.solicitacoes.ILocalizadorFuncionarioAutenticado - EJB3.x Local Business Interface
                                
                                22:15:37,370 INFO  [TomcatDeployment] deploy, ctxPath=/solicitacoes-web
                                22:15:37,427 INFO  [config] Initializing Mojarra 2.0.2 (FCS b10) for context '/solicitacoes-web'
                                22:15:39,011 INFO  [service] Removing bootstrap log handlers
                                22:15:39,132 INFO  [org.jboss.system.server.profileservice.ProfileServiceBootstrap] Loading profile: ProfileKey@18c10af[domain=default, server=default, name=default]
                                22:15:39,262 INFO  [org.apache.coyote.http11.Http11Protocol] Starting Coyote HTTP/1.1 on http-0.0.0.0-8080
                                22:15:39,265 INFO  [org.apache.coyote.ajp.AjpProtocol] Starting Coyote AJP/1.3 on ajp-0.0.0.0-8009
                                22:15:39,265 INFO  [org.jboss.bootstrap.impl.base.server.AbstractServer] JBossAS [6.0.0.20100429-M3 "Neo"] Started in 50s:730
                                

                                 

                                I have attached the modified build file and the .ear that I deployed

                                • 13. Re: Share persistence.xml file between two EJB modules in EAR
                                  marcos_aps

                                  Yes, you're absolutely right. That was the problem: the build.xml file wasn't copying the persistence.xml file. I had the false feeling that just because the persistence.xml file was physically in the directory, it also was being copied to the generated EAR file. So, I just changed the build.xml from:

                                   

                                  <target name="ejbclient" depends="propriedades">
                                    <property name="direjbclient" value="C:/Projeto/Java/Solicitacoes3/solicitacoes-ejbClient" />
                                    <jar destfile="${tmp-ear}/lib/solicitacoes-ejbClient.jar" filesetmanifest="merge">
                                      <fileset dir="${direjbclient}" includes="**/*.class" />
                                      <!-- the guilty below -->
                                      <fileset dir="${direjbclient}" includes="META-INF/MANIFEST.MF" />
                                    </jar>
                                  </target>

                                   

                                  to:

                                   

                                  <target name="ejbclient" depends="propriedades">
                                    <property name="direjbclient" value="C:/Projeto/Java/Solicitacoes3/solicitacoes-ejbClient" />
                                    <jar destfile="${tmp-ear}/lib/solicitacoes-ejbClient.jar" filesetmanifest="merge">
                                      <fileset dir="${direjbclient}" includes="**/*.class" />
                                      <!-- the guilty went away -->
                                      <fileset dir="${direjbclient}" includes="META-INF/**" />
                                    </jar>
                                  </target>

                                   

                                  I always rely on an IDE to build and deploy my applications, but I had to use ant because I didn't find an IDE ready to build Jave EE 6 applications.

                                   

                                  Thank you for finding the problem, Jaikiran.

                                   

                                  Marcos