8 Replies Latest reply on Apr 14, 2008 7:36 AM by jwenting

    Reference-Problems within an ear

    hilwi

      Hello!

      I have a problem deploying an ear with multiple ejb-modules.

      I have an ejb-module called "JbsCore.jar" and another ejb-module called "JbsCalendar.jar". I set up the order of the modules in the application.xml and set <module-order>strict</module-order> to make sure that JbsCalendar is deployed after JbsCore.

      Within JbsCalendar I have an entity-bean named Appointment that references an entity-bean (JbsUser) within JbsCore in this way:

      @ManyToOne
      public JbsUser getLastChangeUser() {
       return lastChangeUser;
      }
      


      When I now try to deploy my application I get the following error:

      org.hibernate.AnnotationException: @OneToOne or @ManyToOne on org.jabusuite.calendar.Appointment.lastChangeUser references an unknown entity: org.jabusuite.core.users.JbsUser
       at org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:56)
       at org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder(AnnotationConfiguration.java:428)
       at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:286)
       at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
       at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1233)
      [...]
      


      As I have seen in the jboss-logs JbsCalendar is deployed just after JbsCore so this problem seems to have nothing to do with the deployment-order. This reference is used in nearly all entity-beans within JbsCore so this seems not to be a general problem with the reference.

      Isn't it possible to reference entities from another jar within the same ear? Both ejb-modules use the same persistence-unit.

      Am I doing something wrong? Is there another/better way to separate an enterprise-application into different modules?

      I'm using JBoss 4.2.2GA

      Hilwi

        • 1. Re: Reference-Problems within an ear
          jaikiran

          Can you post the org.jabusuite.core.users.JbsUser class? Have you annotated it using the @Entity annotation? Also, please post the logs that you see on the console.

          • 2. Re: Reference-Problems within an ear
            jaikiran

            Forgot to mention, please post the contents of the persistence.xml too.

            • 3. Re: Reference-Problems within an ear
              hilwi

              Hello!

              I post an extract of the JbsUser because it's a little bit too long but very simple:

              @Entity
              public class JbsUser extends JbsBaseObject implements Serializable {
              
               private String userName;
               private String password;
               private JbsUserGroup mainGroup;
               private List<JbsUserGroup> groups;
              
               /**
               * @return the mainGroup
               */
               @ManyToOne
               @JoinColumn(name = "mainGroupId")
               public JbsUserGroup getMainGroup() {
               return mainGroup;
               }
              
               /**
               * @param mainGroup the mainGroup to set
               */
               public void setMainGroup(JbsUserGroup mainGroup) {
               this.mainGroup = mainGroup;
               }
              
               /**
               * @return the groups
               */
               @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
               public List<JbsUserGroup> getGroups() {
               return groups;
               }
              
               /**
               * @param groups the groups to set
               */
               public void setGroups(List<JbsUserGroup> groups) {
               this.groups = groups;
               }
              
               /**
               * @return the userName
               */
               public String getUserName() {
               return userName;
               }
              
               /**
               * @param userName the userName to set
               */
               public void setUserName(String userName) {
               this.userName = userName;
               }
              
               /**
               * @return the password
               */
               public String getPassword() {
               return password;
               }
              
               /**
               * @param password the password to set
               */
               public void setPassword(String password) {
               this.password = password;
               }
              
              }
              


              The base class is JbsBaseObject - this is the base-class for many of my entity-beans - it's no EJB itself:

              @MappedSuperclass
              public class JbsBaseObject implements Serializable {
              
               private Logger logger = Logger.getLogger(JbsBaseObject.class);
              
               private long id;
               private Date created;
               private Timestamp lastAction;
               private boolean deleted;
              
              
              
               public JbsBaseObject() {
               this.setStandardValues();
               }
              
               /**
               * Set's a new unique id for the JbsBaseObject
               */
               public void setNewId() {
               this.setId(JbsBaseObject.createUniqueId());
               }
              
               public static long createUniqueId() {
               UniqueId uniqueId = new UniqueId();
               return uniqueId.getUID();
               }
              
               protected void setStandardValues() {
               this.setId(JbsObject.createUniqueId());
               this.setCreated(new Date());
               this.setDeleted(false);
               }
              
               /**
               * @return the created
               */
               public Date getCreated() {
               return created;
               }
               /**
               * @param created the created to set
               */
               public void setCreated(Date created) {
               this.created = created;
               }
               /**
               * @return the id
               */
               @Id
               public long getId() {
               return id;
               }
               /**
               * @param id the id to set
               */
               public void setId(long id) {
               this.id = id;
               }
               /**
               * @return the lastAction
               */
               public Timestamp getLastAction() {
               return lastAction;
               }
               /**
               * @param lastAction the lastAction to set
               */
               public void setLastAction(Timestamp lastAction) {
               this.lastAction = lastAction;
               }
              
               /**
               * @return the deleted
               */
               public boolean isDeleted() {
               return deleted;
               }
              
               /**
               * @param deleted the deleted to set
               */
               public void setDeleted(boolean deleted) {
               this.deleted = deleted;
               }
              
              
              }
              


              This is an extract of the interesting things that I see on the console. First it finds my entity-beans that belong to JbsCore.jar:

              [...]
              13:17:54,238 INFO [Ejb3Configuration] found EJB3 Entity bean: org.jabusuite.core.users.JbsUser
              13:17:54,239 INFO [Ejb3Configuration] found EJB3 Entity bean: org.jabusuite.core.users.JbsUserGroup
              13:17:54,242 INFO [Ejb3Configuration] found EJB3 @MappedSuperclass: org.jabusuite.core.utils.JbsBaseObject
              13:17:54,243 INFO [Ejb3Configuration] found EJB3 @MappedSuperclass: org.jabusuite.core.utils.JbsObject
              13:17:54,244 INFO [Ejb3Configuration] found EJB3 Entity bean: org.jabusuite.core.utils.UserNumber
              [...]
              


              and binds it to the correct tables. After that it deploys JbsCalendar:

              13:18:20,549 INFO [PersistenceUnitDeployment] Starting persistence unit persistence.units:ear=OpenJbs_Server.ear,unitName=jabusuite
              13:18:20,556 INFO [Ejb3Configuration] found EJB3 Entity bean: org.jabusuite.calendar.Appointment
              13:18:20,558 INFO [Configuration] Reading mappings from resource : META-INF/orm.xml
              13:18:20,558 INFO [Ejb3Configuration] [PersistenceUnit: jabusuite] no META-INF/orm.xml found
              13:18:20,561 INFO [AnnotationBinder] Binding entity from annotated class: org.jabusuite.calendar.Appointment
              13:18:20,562 INFO [EntityBinder] Bind entity org.jabusuite.calendar.Appointment on table Appointment
              13:18:20,572 WARN [ServiceController] Problem starting service persistence.units:ear=OpenJbs_Server.ear,unitName=jabusuite
              org.hibernate.AnnotationException: @OneToOne or @ManyToOne on org.jabusuite.calendar.Appointment.owner references an unknown entity: org.jabusuite.core.users.JbsUser
               at org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:56)
               at org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder(AnnotationConfiguration.java:428)
               at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:286)
               at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
               at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1233)
               at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154)
               at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:869)
               at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:407)
               at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:126)
               at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:246)
               at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
               at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
               at java.lang.reflect.Method.invoke(Method.java:585)
               at org.jboss.ejb3.ServiceDelegateWrapper.startService(ServiceDelegateWrapper.java:103)
               at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
               at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
               at sun.reflect.GeneratedMethodAccessor91.invoke(Unknown Source)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
               at java.lang.reflect.Method.invoke(Method.java:585)
               at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
               at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
               at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
               at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
               at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
               at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
               at $Proxy0.start(Unknown Source)
               at org.jboss.system.ServiceController.start(ServiceController.java:417)
               at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
               at java.lang.reflect.Method.invoke(Method.java:585)
               at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
               at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
               at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
               at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
               at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
               at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
               at $Proxy217.start(Unknown Source)
               at org.jboss.ejb3.JmxKernelAbstraction.install(JmxKernelAbstraction.java:120)
               at org.jboss.ejb3.Ejb3Deployment.startPersistenceUnits(Ejb3Deployment.java:627)
               at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:351)
               at org.jboss.ejb3.Ejb3Module.startService(Ejb3Module.java:91)
               at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
               at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
               at sun.reflect.GeneratedMethodAccessor91.invoke(Unknown Source)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
               at java.lang.reflect.Method.invoke(Method.java:585)
               at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
               at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
               at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
               at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
               at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
               at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
               at $Proxy0.start(Unknown Source)
               at org.jboss.system.ServiceController.start(ServiceController.java:417)
               at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
               at java.lang.reflect.Method.invoke(Method.java:585)
               at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
               at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
               at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
               at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
               at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
               at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
               at $Proxy33.start(Unknown Source)
               at org.jboss.ejb3.EJB3Deployer.start(EJB3Deployer.java:512)
               at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
               at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
               at java.lang.reflect.Method.invoke(Method.java:585)
               at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
               at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
               at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
               at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
               at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
               at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
               at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
               at org.jboss.wsf.container.jboss42.DeployerInterceptor.start(DeployerInterceptor.java:87)
               at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
               at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
               at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
               at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
               at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
               at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
               at $Proxy34.start(Unknown Source)
               at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
               at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1015)
               at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
               at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
               at sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
               at java.lang.reflect.Method.invoke(Method.java:585)
               at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
               at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
               at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
               at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
               at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
               at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
               at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
               at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
               at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
               at $Proxy9.deploy(Unknown Source)
               at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
               at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:610)
               at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
               at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274)
               at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)
              13:18:20,574 INFO [EJB3Deployer] Deployed: file:/opt/JBoss/jboss-4.2.2.GA/server/default/tmp/deploy/tmp30047OpenJbs_Server.ear-contents/JbsCalendar.jar
              13:18:20,579 INFO [TomcatDeployer] deploy, ctxPath=/JaBuSuite_Webclient, warUrl=.../tmp/deploy/tmp30047OpenJbs_Server.ear-contents/JaBuSuite_Webclient-exp.war/
              13:18:20,795 INFO [EARDeployer] Started J2EE application: file:/opt/JBoss/jboss-4.2.2.GA/server/default/deploy/OpenJbs_Server.ear
              13:18:20,806 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
              
              --- MBeans waiting for other MBeans ---
              ObjectName: persistence.units:ear=OpenJbs_Server.ear,unitName=jabusuite
               State: FAILED
               Reason: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on org.jabusuite.calendar.Appointment.owner references an unknown entity: org.jabusuite.core.users.JbsUser
               I Depend On:
               jboss.jca:service=DataSourceBinding,name=JaBuSuiteDS
              
              --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
              ObjectName: persistence.units:ear=OpenJbs_Server.ear,unitName=jabusuite
               State: FAILED
               Reason: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on org.jabusuite.calendar.Appointment.owner references an unknown entity: org.jabusuite.core.users.JbsUser
               I Depend On:
               jboss.jca:service=DataSourceBinding,name=JaBuSuiteDS
              


              This is my persistence.xml:

              <?xml version="1.0" encoding="UTF-8"?>
              <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
               <persistence-unit name="jabusuite" transaction-type="JTA">
               <provider>org.hibernate.ejb.HibernatePersistence</provider>
               <jta-data-source>java:/JaBuSuiteDS</jta-data-source>
               <properties>
               <property name="hibernate.hbm2ddl.auto" value="update"/>
               </properties>
               </persistence-unit>
              </persistence>
              


              I use the same for JbsCore and JbsCalendar.

              Maybe I have found a possible problem:
              I use the JbsCore.jar as lirary for the JbsCalendar in order to make the JbsCore-Classes available during development in Netbeans. When the JbsCalendar.jar is build the JbsCore.jar will be added to this archieve, so that the classes are deployed twice - the first time because it's added directly to the ear and the second time because it's found within the JbsCalendar.jar. May this have something to do with my problem? Could I delete the JbsCore.jar out of my JbsCalendar.jar?




              • 4. Re: Reference-Problems within an ear
                jaikiran

                 

                "Hilwi" wrote:

                This is an extract of the interesting things that I see on the console. First it finds my entity-beans that belong to JbsCore.jar:

                [...]
                13:17:54,238 INFO [Ejb3Configuration] found EJB3 Entity bean: org.jabusuite.core.users.JbsUser
                13:17:54,239 INFO [Ejb3Configuration] found EJB3 Entity bean: org.jabusuite.core.users.JbsUserGroup
                13:17:54,242 INFO [Ejb3Configuration] found EJB3 @MappedSuperclass: org.jabusuite.core.utils.JbsBaseObject
                13:17:54,243 INFO [Ejb3Configuration] found EJB3 @MappedSuperclass: org.jabusuite.core.utils.JbsObject
                13:17:54,244 INFO [Ejb3Configuration] found EJB3 Entity bean: org.jabusuite.core.utils.UserNumber
                [...]
                


                and binds it to the correct tables. After that it deploys JbsCalendar:

                13:18:20,549 INFO [PersistenceUnitDeployment] Starting persistence unit persistence.units:ear=OpenJbs_Server.ear,unitName=jabusuite
                 13:18:20,556 INFO [Ejb3Configuration] found EJB3 Entity bean: org.jabusuite.calendar.Appointment
                13:18:20,558 INFO [Configuration] Reading mappings from resource : META-INF/orm.xml
                13:18:20,558 INFO [Ejb3Configuration] [PersistenceUnit: jabusuite] no META-INF/orm.xml found
                13:18:20,561 INFO [AnnotationBinder] Binding entity from annotated class: org.jabusuite.calendar.Appointment
                13:18:20,562 INFO [EntityBinder] Bind entity org.jabusuite.calendar.Appointment on table Appointment
                13:18:20,572 WARN [ServiceController] Problem starting service persistence.units:ear=OpenJbs_Server.ear,unitName=jabusuite
                org.hibernate.AnnotationException: @OneToOne or @ManyToOne on org.jabusuite.calendar.Appointment.owner references an unknown entity: org.jabusuite.core.users.JbsUser
                 at org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:56)
                 at org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder(AnnotationConfiguration.java:428)
                 at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:286)
                 at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
                 at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1233)
                 at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154)
                 at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:869)
                 at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:407)
                 at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:126)
                 at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:246)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:585)
                 at org.jboss.ejb3.ServiceDelegateWrapper.startService(ServiceDelegateWrapper.java:103)
                 at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
                 at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
                 at sun.reflect.GeneratedMethodAccessor91.invoke(Unknown Source)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:585)
                 at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                 at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                 at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                 at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                 at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                 at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
                 at $Proxy0.start(Unknown Source)
                 at org.jboss.system.ServiceController.start(ServiceController.java:417)
                 at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:585)
                 at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                 at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                 at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                 at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                 at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                 at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
                 at $Proxy217.start(Unknown Source)
                 at org.jboss.ejb3.JmxKernelAbstraction.install(JmxKernelAbstraction.java:120)
                 at org.jboss.ejb3.Ejb3Deployment.startPersistenceUnits(Ejb3Deployment.java:627)
                 at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:351)
                 at org.jboss.ejb3.Ejb3Module.startService(Ejb3Module.java:91)
                 at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
                 at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
                 at sun.reflect.GeneratedMethodAccessor91.invoke(Unknown Source)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:585)
                 at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                 at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                 at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                 at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                 at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                 at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
                 at $Proxy0.start(Unknown Source)
                 at org.jboss.system.ServiceController.start(ServiceController.java:417)
                 at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:585)
                 at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                 at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                 at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
                 at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                 at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                 at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
                 at $Proxy33.start(Unknown Source)
                 at org.jboss.ejb3.EJB3Deployer.start(EJB3Deployer.java:512)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:585)
                 at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                 at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                 at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
                 at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                 at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
                 at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
                 at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
                 at org.jboss.wsf.container.jboss42.DeployerInterceptor.start(DeployerInterceptor.java:87)
                 at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
                 at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
                 at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                 at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                 at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                 at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
                 at $Proxy34.start(Unknown Source)
                 at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
                 at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1015)
                 at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
                 at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
                 at sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:585)
                 at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                 at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                 at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
                 at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                 at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
                 at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                 at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                 at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                 at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
                 at $Proxy9.deploy(Unknown Source)
                 at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
                 at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:610)
                 at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
                 at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274)
                 at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)
                13:18:20,574 INFO [EJB3Deployer] Deployed: file:/opt/JBoss/jboss-4.2.2.GA/server/default/tmp/deploy/tmp30047OpenJbs_Server.ear-contents/JbsCalendar.jar
                13:18:20,579 INFO [TomcatDeployer] deploy, ctxPath=/JaBuSuite_Webclient, warUrl=.../tmp/deploy/tmp30047OpenJbs_Server.ear-contents/JaBuSuite_Webclient-exp.war/
                13:18:20,795 INFO [EARDeployer] Started J2EE application: file:/opt/JBoss/jboss-4.2.2.GA/server/default/deploy/OpenJbs_Server.ear
                13:18:20,806 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
                
                --- MBeans waiting for other MBeans ---
                ObjectName: persistence.units:ear=OpenJbs_Server.ear,unitName=jabusuite
                 State: FAILED
                 Reason: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on org.jabusuite.calendar.Appointment.owner references an unknown entity: org.jabusuite.core.users.JbsUser
                 I Depend On:
                 jboss.jca:service=DataSourceBinding,name=JaBuSuiteDS
                
                --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
                ObjectName: persistence.units:ear=OpenJbs_Server.ear,unitName=jabusuite
                 State: FAILED
                 Reason: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on org.jabusuite.calendar.Appointment.owner references an unknown entity: org.jabusuite.core.users.JbsUser
                 I Depend On:
                 jboss.jca:service=DataSourceBinding,name=JaBuSuiteDS
                




                This looks strange. There are some entities that are being parsed and *after that* there's a message(marked in bold) which states it (re)starting the deployment of the persistence unit.

                "Hilwi" wrote:

                This is my persistence.xml:

                
                <?xml version="1.0" encoding="UTF-8"?>
                <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
                 <persistence-unit name="jabusuite" transaction-type="JTA">
                 <provider>org.hibernate.ejb.HibernatePersistence</provider>
                 <jta-data-source>java:/JaBuSuiteDS</jta-data-source>
                 <properties>
                 <property name="hibernate.hbm2ddl.auto" value="update"/>
                 </properties>
                 </persistence-unit>
                </persistence>
                


                I use the same for JbsCore and JbsCalendar.



                Do you mean, that you have placed this persistence.xml in *both* JbsCore.jar and the JbsCalendar.jar? If yes, then it explains the above logs.

                Ideally, if you are having the entities in more than one jar file then, you will create a single persistence.xml and place it in only one of the jar files. The persistence.xml will further have a jar-file element which will mention the name of the other jar file which contains the entities.

                For example, in your case, you can place the persistence.xml (only) in the JbsCalendar.jar and have something like this in the persistence.xml:
                <?xml version="1.0" encoding="UTF-8"?>
                <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
                 <persistence-unit name="jabusuite" transaction-type="JTA">
                 <provider>org.hibernate.ejb.HibernatePersistence</provider>
                 <jta-data-source>java:/JaBuSuiteDS</jta-data-source>
                 <jar-file>../</jar-file>
                 <jar-file>../JbsCore.jar</jar-file>
                
                
                 <properties>
                 <property name="hibernate.hbm2ddl.auto" value="update"/>
                 </properties>
                 </persistence-unit>
                </persistence>


                • 5. Re: Reference-Problems within an ear
                  hilwi

                  Thank you for your help! It works this way!

                  With these different jars I wanted to divide my application into different modues. If I have to create another application with different features I want to assemble these different modules in a new ear. In this case it's not easy to decide in which jar I have to place my persistence.xml.

                  I created another ejb-jar named OpenJbs_EJB.jar now that only contains the persistence.xml with the jar-files to scan:

                  <?xml version="1.0" encoding="UTF-8"?>
                  <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
                   <persistence-unit name="jabusuite" transaction-type="JTA">
                   <provider>org.hibernate.ejb.HibernatePersistence</provider>
                   <jta-data-source>java:/JaBuSuiteDS</jta-data-source>
                   <!--<exclude-unlisted-classes>false</exclude-unlisted-classes>-->
                  
                   <jar-file>../JbsCore.jar</jar-file>
                   <jar-file>../JbsCalendar.jar</jar-file>
                  
                   <properties>
                   <property name="hibernate.hbm2ddl.auto" value="update"/>
                   </properties>
                   </persistence-unit>
                  </persistence>
                  


                  The application.xml:

                  <?xml version="1.0" encoding="UTF-8"?>
                  <application version="1.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
                   <display-name>OpenJbs_Server</display-name>
                   <module>
                   <ejb>JbsCore.jar</ejb>
                   </module>
                   <module>
                   <ejb>JbsCalendar.jar</ejb>
                   </module>
                   <module>
                   <ejb>OpenJbs_EJB.jar</ejb>
                   </module>
                   <module>
                   <web>
                   <web-uri>JaBuSuite_Webclient.war</web-uri>
                   <context-root>/JaBuSuite_Webclient</context-root>
                   </web>
                   </module>
                  </application>
                  


                  This seems not to be a very clean solution to me because the OpenJbs_EJB.jar is just a dummy. Isn't it possible to put the persistence.xml elsewhere?

                  • 6. Re: Reference-Problems within an ear
                    jaikiran

                     

                    "Hilwi" wrote:

                    I created another ejb-jar named OpenJbs_EJB.jar now that only contains the persistence.xml with the jar-files to scan:


                    This need not be an EJB jar. It can be a simple jar file and in the application.xml file you can map it as a java module instead of an ejb module:


                     <module>
                     <java>OpenJbs_EJB.jar</java>
                     </module>
                    


                    "Hilwi" wrote:

                    This seems not to be a very clean solution to me because the OpenJbs_EJB.jar is just a dummy. Isn't it possible to put the persistence.xml elsewhere?


                    As far as i know, this is the only way to have multiple jars containing the entities, all belonging to a single persistence unit. In your case, you had to create the dummy jar because you are planning to use the modules across multiple applications.

                    • 7. Re: Reference-Problems within an ear
                      hilwi

                      Thank you for your help!

                      I think I'll do it in this way now. It would be great if it was possible to put the persistence.xml into the ear. :)

                      • 8. Re: Reference-Problems within an ear

                        the persistence context exists within the context of its entities.
                        Without those entities it has no real meaning.
                        That means those entities need to be packed with the persistence context.

                        You might be best off restructuring your project to have a single persistence module containing all your entities and the persistence context, and referencing to that from your other modules.
                        That also prevents a lot of class duplication among the other modules, which can become a major headache when table definitions or other entity-related stuff changes.
                        As it now stands in your application you'd need to change each module separately, rather than change just one.
                        I can guarantee that sooner rather than later that'll come back to bite you.