7 Replies Latest reply on Feb 23, 2009 4:32 AM by jaikiran

    JARs in EAR using single orm.xml

    frankthetank

      I hope this is the correct sub-forum.

      I have one EAR with multiple Jars that each contain their own orm.xml (besides persistence.xml and ejb-jar.xml).
      Each of the jars contains one Pojo defined via Deployment Descirptor as an Entity.

      When they are deployed I can clearly see that while for each jar the system tries to map the Pojos as Entities, but each time uses the same first orm.xml that was deployed.
      Thus my other Pojos are not mapped.

      Am I doing something wrong?

        • 1. Re: JARs in EAR using single orm.xml
          jaikiran

          Can you post the console logs which show this problem? Also which version of JBossAS do you use? And have you changed any of the hibernate related jars/versions that ship by default in the AS?

          • 2. Re: JARs in EAR using single orm.xml
            frankthetank

            I am using AS 4.2.3 (jdk6) without modifications to the hibernate files.

            In order to continue working I simply switched to annotations for the time being (but would like to switch back) but I can pretty much quote from memory:

            Deploy jar file (once for each jar)
            object mapping file found in META-INF/orm.xml
            Binding object my.test.class (this file always remains the same)

            I had already confirmed that each jar contains the correct orm.xml file.
            I had also thought about renaming the orm.xml for each project and mapping it in the persistence.xml.

            I'll revert my changes and get you a log output.

            • 3. Re: JARs in EAR using single orm.xml
              frankthetank

              log:
              I have split up the log a little to show the points of interest.
              (names changed to protect the innocent)

              The user management already contains classes with annotations.
              In the apple and pear management the entities are completely missing, as these only have orm.xml based mappings.

              09:32:42,867 INFO [EARDeployer] Init J2EE application: file:/C:/Lang/JBoss/jboss-4.2.3.GA/server/all/deploy/FruitTestCache.ear/
              09:32:44,290 INFO [dynTopic] Bound to JNDI name: topic/dynTopic
              09:32:44,306 INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.entity.PersistenceUnitDeployment
              09:32:44,306 INFO [JmxKernelAbstraction] installing MBean: persistence.units:ear=FruitTestCache.ear,jar=fruit-license-manager.jar,unitName=FruitDS with dependencies:
              09:32:44,306 INFO [JmxKernelAbstraction] jboss.jca:name=FruitDS,service=DataSourceBinding
              09:32:44,306 INFO [PersistenceUnitDeployment] Starting persistence unit persistence.units:ear=FruitTestCache.ear,jar=fruit-license-manager.jar,unitName=FruitDS
              09:32:44,993 INFO [Version] Hibernate EntityManager 3.2.1.GA
              09:32:45,103 INFO [Version] Hibernate Annotations 3.2.1.GA
              09:32:45,150 INFO [Environment] Hibernate 3.2.4.sp1
              09:32:45,165 INFO [Environment] hibernate.properties not found
              09:32:45,165 INFO [Environment] Bytecode provider name : javassist
              09:32:45,212 INFO [Environment] using JDK 1.4 java.sql.Timestamp handling
              

              09:32:46,166 INFO [Configuration] Reading mappings from resource : META-INF/orm.xml
              09:32:46,447 INFO [Ejb3Configuration] [PersistenceUnit: FruitDS] META-INF/orm.xml found
              09:32:47,072 INFO [AnnotationBinder] Binding entity from annotated class: my.test.dom.License
              09:32:47,213 INFO [EntityBinder] Bind entity my.test.dom.License on table licenses
              

              09:32:48,370 INFO [ConnectionProviderFactory] Initializing connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
              09:32:48,370 INFO [InjectedDataSourceConnectionProvider] Using provided datasource
              09:32:48,964 INFO [SettingsFactory] RDBMS: PostgreSQL, version: 8.3.1
              09:32:48,964 INFO [SettingsFactory] JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 8.2 JDBC3 with SSL (build 504)
              09:32:49,057 INFO [Dialect] Using dialect: org.hibernate.dialect.PostgreSQLDialect
              09:32:49,073 INFO [TransactionFactoryFactory] Transaction strategy: org.hibernate.ejb.transaction.JoinableCMTTransactionFactory
              09:32:49,073 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: org.hibernate.transaction.JBossTransactionManagerLookup
              09:32:49,089 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
              09:32:49,089 INFO [SettingsFactory] Automatic flush during beforeCompletion(): disabled
              09:32:49,089 INFO [SettingsFactory] Automatic session close at end of transaction: disabled
              09:32:49,089 INFO [SettingsFactory] JDBC batch size: 15
              09:32:49,089 INFO [SettingsFactory] JDBC batch updates for versioned data: disabled
              09:32:49,089 INFO [SettingsFactory] Scrollable result sets: enabled
              09:32:49,089 INFO [SettingsFactory] JDBC3 getGeneratedKeys(): disabled
              09:32:49,089 INFO [SettingsFactory] Connection release mode: auto
              09:32:49,089 INFO [SettingsFactory] Default batch fetch size: 1
              09:32:49,089 INFO [SettingsFactory] Generate SQL with comments: disabled
              09:32:49,089 INFO [SettingsFactory] Order SQL updates by primary key: disabled
              09:32:49,089 INFO [SettingsFactory] Order SQL inserts for batching: disabled
              09:32:49,089 INFO [SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
              09:32:49,104 INFO [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
              09:32:49,104 INFO [SettingsFactory] Query language substitutions: {}
              09:32:49,104 INFO [SettingsFactory] JPA-QL strict compliance: enabled
              09:32:49,104 INFO [SettingsFactory] Second-level cache: enabled
              09:32:49,104 INFO [SettingsFactory] Query cache: enabled
              09:32:49,104 INFO [SettingsFactory] Cache provider: org.jboss.ejb3.entity.TreeCacheProviderHook
              09:32:49,136 INFO [SettingsFactory] Optimize cache for minimal puts: enabled
              09:32:49,136 INFO [SettingsFactory] Cache region prefix: FruitTestCache_ear,fruit-license-manager_jar,FruitDS
              09:32:49,136 INFO [SettingsFactory] Structured second-level cache entries: disabled
              09:32:49,136 INFO [SettingsFactory] Query cache factory: org.hibernate.cache.StandardQueryCacheFactory
              09:32:49,182 INFO [SettingsFactory] Statistics: disabled
              09:32:49,182 INFO [SettingsFactory] Deleted entity synthetic identifier rollback: disabled
              09:32:49,182 INFO [SettingsFactory] Default entity-mode: pojo
              09:32:49,182 INFO [SettingsFactory] Named query checking : enabled
              09:32:49,401 INFO [SessionFactoryImpl] building session factory
              09:32:50,308 INFO [SessionFactoryObjectFactory] Factory name: persistence.units:ear=FruitTestCache.ear,jar=fruit-license-manager.jar,unitName=FruitDS
              09:32:50,324 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
              09:32:50,324 INFO [SessionFactoryObjectFactory] Bound factory to JNDI name: persistence.units:ear=FruitTestCache.ear,jar=fruit-license-manager.jar,unitName=FruitDS
              09:32:50,324 WARN [SessionFactoryObjectFactory] InitialContext did not implement EventContext
              09:32:50,355 INFO [SchemaExport] Running hbm2ddl schema export
              09:32:50,355 INFO [SchemaExport] exporting generated schema to database
              09:32:50,464 INFO [SchemaExport] schema export complete
              09:32:50,464 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
              09:32:50,480 INFO [UpdateTimestampsCache] starting update timestamps cache at region: FruitTestCache_ear,fruit-license-manager_jar,FruitDS.org.hibernate.cache.UpdateTimestampsCache
              09:32:50,480 INFO [StandardQueryCache] starting query cache at region: FruitTestCache_ear,fruit-license-manager_jar,FruitDS.org.hibernate.cache.StandardQueryCache
              09:32:50,636 INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.stateless.StatelessContainer
              09:32:50,636 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=FruitTestCache.ear,jar=fruit-license-manager.jar,name=LicenseManagerBean,service=EJB3 with dependencies:
              09:32:50,636 INFO [JmxKernelAbstraction] my.test:service=EventEmitter
              09:32:50,636 INFO [EJB3Deployer] Deployed: file:/C:/Lang/JBoss/jboss-4.2.3.GA/server/all/deploy/FruitTestCache.ear/fruit-license-manager.jar
              09:32:50,652 INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.service.ServiceContainer
              09:32:50,652 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=FruitTestCache.ear,jar=events-emitter.jar,name=EventEmitterMBean,service=EJB3 with dependencies:
              09:32:50,683 INFO [EJBContainer] STARTED EJB: events.emitter.EventEmitterMBean ejbName: EventEmitterMBean
              09:32:50,746 INFO [STDOUT] events.emitter.EventEmitterMBean.create()
              09:32:50,746 INFO [STDOUT] events.emitter.EventEmitterMBean.start()
              09:32:50,761 INFO [EJBContainer] STARTED EJB: my.test.beans.LicenseManagerBean ejbName: LicenseManagerBean
              09:32:50,824 INFO [EJB3Deployer] Deployed: file:/C:/Lang/JBoss/jboss-4.2.3.GA/server/all/deploy/FruitTestCache.ear/events-emitter.jar
              09:32:50,824 INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.entity.PersistenceUnitDeployment
              09:32:50,824 INFO [JmxKernelAbstraction] installing MBean: persistence.units:ear=FruitTestCache.ear,jar=apple-manager.jar,unitName=FruitDS with dependencies:
              09:32:50,824 INFO [JmxKernelAbstraction] jboss.jca:name=FruitDS,service=DataSourceBinding
              

              09:32:50,824 INFO [PersistenceUnitDeployment] Starting persistence unit persistence.units:ear=FruitTestCache.ear,jar=apple-manager.jar,unitName=FruitDS
              09:32:50,824 INFO [Configuration] Reading mappings from resource : META-INF/orm.xml
              09:32:50,839 INFO [Ejb3Configuration] [PersistenceUnit: FruitDS] META-INF/orm.xml found
              09:32:50,839 INFO [AnnotationBinder] Binding entity from annotated class: my.test.dom.License
              09:32:50,839 INFO [EntityBinder] Bind entity my.test.dom.License on table licenses
              

              09:32:50,839 INFO [ConnectionProviderFactory] Initializing connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
              09:32:50,839 INFO [InjectedDataSourceConnectionProvider] Using provided datasource
              09:32:50,839 INFO [SettingsFactory] RDBMS: PostgreSQL, version: 8.3.1
              09:32:50,839 INFO [SettingsFactory] JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 8.2 JDBC3 with SSL (build 504)
              09:32:50,855 INFO [Dialect] Using dialect: org.hibernate.dialect.PostgreSQLDialect
              09:32:50,855 INFO [TransactionFactoryFactory] Transaction strategy: org.hibernate.ejb.transaction.JoinableCMTTransactionFactory
              09:32:50,855 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: org.hibernate.transaction.JBossTransactionManagerLookup
              09:32:50,855 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
              09:32:50,855 INFO [SettingsFactory] Automatic flush during beforeCompletion(): disabled
              09:32:50,855 INFO [SettingsFactory] Automatic session close at end of transaction: disabled
              09:32:50,855 INFO [SettingsFactory] JDBC batch size: 15
              09:32:50,855 INFO [SettingsFactory] JDBC batch updates for versioned data: disabled
              09:32:50,855 INFO [SettingsFactory] Scrollable result sets: enabled
              09:32:50,855 INFO [SettingsFactory] JDBC3 getGeneratedKeys(): disabled
              09:32:50,855 INFO [SettingsFactory] Connection release mode: auto
              09:32:50,855 INFO [SettingsFactory] Default batch fetch size: 1
              09:32:50,855 INFO [SettingsFactory] Generate SQL with comments: disabled
              09:32:50,855 INFO [SettingsFactory] Order SQL updates by primary key: disabled
              09:32:50,855 INFO [SettingsFactory] Order SQL inserts for batching: disabled
              09:32:50,855 INFO [SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
              09:32:50,855 INFO [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
              09:32:50,855 INFO [SettingsFactory] Query language substitutions: {}
              09:32:50,855 INFO [SettingsFactory] JPA-QL strict compliance: enabled
              09:32:50,855 INFO [SettingsFactory] Second-level cache: enabled
              09:32:50,855 INFO [SettingsFactory] Query cache: enabled
              09:32:50,855 INFO [SettingsFactory] Cache provider: org.jboss.ejb3.entity.TreeCacheProviderHook
              09:32:50,855 INFO [SettingsFactory] Optimize cache for minimal puts: enabled
              09:32:50,855 INFO [SettingsFactory] Cache region prefix: FruitTestCache_ear,apple-manager_jar,FruitDS
              09:32:50,855 INFO [SettingsFactory] Structured second-level cache entries: disabled
              09:32:50,855 INFO [SettingsFactory] Query cache factory: org.hibernate.cache.StandardQueryCacheFactory
              09:32:50,855 INFO [SettingsFactory] Statistics: disabled
              09:32:50,855 INFO [SettingsFactory] Deleted entity synthetic identifier rollback: disabled
              09:32:50,855 INFO [SettingsFactory] Default entity-mode: pojo
              09:32:50,855 INFO [SettingsFactory] Named query checking : enabled
              09:32:50,855 INFO [SessionFactoryImpl] building session factory
              09:32:50,871 INFO [SessionFactoryObjectFactory] Factory name: persistence.units:ear=FruitTestCache.ear,jar=apple-manager.jar,unitName=FruitDS
              09:32:50,871 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
              09:32:50,871 INFO [SessionFactoryObjectFactory] Bound factory to JNDI name: persistence.units:ear=FruitTestCache.ear,jar=apple-manager.jar,unitName=FruitDS
              09:32:50,871 WARN [SessionFactoryObjectFactory] InitialContext did not implement EventContext
              09:32:50,871 INFO [SchemaExport] Running hbm2ddl schema export
              09:32:50,871 INFO [SchemaExport] exporting generated schema to database
              09:32:50,996 INFO [SchemaExport] schema export complete
              09:32:50,996 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
              09:32:50,996 INFO [UpdateTimestampsCache] starting update timestamps cache at region: FruitTestCache_ear,apple-manager_jar,FruitDS.org.hibernate.cache.UpdateTimestampsCache
              09:32:50,996 INFO [StandardQueryCache] starting query cache at region: FruitTestCache_ear,apple-manager_jar,FruitDS.org.hibernate.cache.StandardQueryCache
              09:32:51,027 INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.stateless.StatelessContainer
              09:32:51,027 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=FruitTestCache.ear,jar=apple-manager.jar,name=AppleManagementBean,service=EJB3 with dependencies:
              09:32:51,027 INFO [JmxKernelAbstraction] persistence.units:ear=FruitTestCache.ear,jar=apple-manager.jar,unitName=FruitDS
              09:32:51,027 INFO [JmxKernelAbstraction] my.test:service=EventEmitter
              09:32:51,043 INFO [EJBContainer] STARTED EJB: my.test.beans.AppleManagementBean ejbName: AppleManagementBean
              09:32:51,043 INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.service.ServiceContainer
              09:32:51,043 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=FruitTestCache.ear,jar=apple-manager.jar,name=AppleManagementMBean,service=EJB3 with dependencies:
              09:32:51,043 INFO [JmxKernelAbstraction] jboss.j2ee:ear=FruitTestCache.ear,jar=apple-manager.jar,name=AppleManagementBean,service=EJB3
              09:32:51,043 INFO [JmxKernelAbstraction] jboss.j2ee:ear=FruitTestCache.ear,jar=user-management.jar,name=UserManagementBean,service=EJB3
              09:32:51,058 INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.mdb.MDB
              09:32:51,058 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=FruitTestCache.ear,jar=apple-manager.jar,name=SystemVarsListener,service=EJB3 with dependencies:
              09:32:51,058 INFO [EJBContainer] STARTED EJB: my.test.events.listeners.SystemVarsListener ejbName: SystemVarsListener
              09:32:51,105 INFO [EJB3Deployer] Deployed: file:/C:/Lang/JBoss/jboss-4.2.3.GA/server/all/deploy/FruitTestCache.ear/apple-manager.jar
              09:32:51,105 INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.entity.PersistenceUnitDeployment
              09:32:51,105 INFO [JmxKernelAbstraction] installing MBean: persistence.units:ear=FruitTestCache.ear,jar=pear-manager.jar,unitName=FruitDS with dependencies:
              09:32:51,105 INFO [JmxKernelAbstraction] jboss.jca:name=FruitDS,service=DataSourceBinding
              

              09:32:51,136 INFO [PersistenceUnitDeployment] Starting persistence unit persistence.units:ear=FruitTestCache.ear,jar=pear-manager.jar,unitName=FruitDS
              09:32:51,152 INFO [Configuration] Reading mappings from resource : META-INF/orm.xml
              09:32:51,168 INFO [Ejb3Configuration] [PersistenceUnit: FruitDS] META-INF/orm.xml found
              09:32:51,183 INFO [AnnotationBinder] Binding entity from annotated class: my.test.dom.License
              09:32:51,183 INFO [EntityBinder] Bind entity my.test.dom.License on table licenses
              

              09:32:51,183 INFO [ConnectionProviderFactory] Initializing connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
              09:32:51,183 INFO [InjectedDataSourceConnectionProvider] Using provided datasource
              09:32:51,183 INFO [SettingsFactory] RDBMS: PostgreSQL, version: 8.3.1
              09:32:51,183 INFO [SettingsFactory] JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 8.2 JDBC3 with SSL (build 504)
              09:32:51,183 INFO [Dialect] Using dialect: org.hibernate.dialect.PostgreSQLDialect
              09:32:51,183 INFO [TransactionFactoryFactory] Transaction strategy: org.hibernate.ejb.transaction.JoinableCMTTransactionFactory
              09:32:51,183 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: org.hibernate.transaction.JBossTransactionManagerLookup
              09:32:51,183 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
              09:32:51,183 INFO [SettingsFactory] Automatic flush during beforeCompletion(): disabled
              09:32:51,183 INFO [SettingsFactory] Automatic session close at end of transaction: disabled
              09:32:51,183 INFO [SettingsFactory] JDBC batch size: 15
              09:32:51,183 INFO [SettingsFactory] JDBC batch updates for versioned data: disabled
              09:32:51,183 INFO [SettingsFactory] Scrollable result sets: enabled
              09:32:51,183 INFO [SettingsFactory] JDBC3 getGeneratedKeys(): disabled
              09:32:51,183 INFO [SettingsFactory] Connection release mode: auto
              09:32:51,183 INFO [SettingsFactory] Default batch fetch size: 1
              09:32:51,183 INFO [SettingsFactory] Generate SQL with comments: disabled
              09:32:51,183 INFO [SettingsFactory] Order SQL updates by primary key: disabled
              09:32:51,183 INFO [SettingsFactory] Order SQL inserts for batching: disabled
              09:32:51,183 INFO [SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
              09:32:51,183 INFO [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
              09:32:51,183 INFO [SettingsFactory] Query language substitutions: {}
              09:32:51,183 INFO [SettingsFactory] JPA-QL strict compliance: enabled
              09:32:51,183 INFO [SettingsFactory] Second-level cache: enabled
              09:32:51,183 INFO [SettingsFactory] Query cache: enabled
              09:32:51,183 INFO [SettingsFactory] Cache provider: org.jboss.ejb3.entity.TreeCacheProviderHook
              09:32:51,183 INFO [SettingsFactory] Optimize cache for minimal puts: enabled
              09:32:51,183 INFO [SettingsFactory] Cache region prefix: FruitTestCache_ear,pear-manager_jar,FruitDS
              09:32:51,183 INFO [SettingsFactory] Structured second-level cache entries: disabled
              09:32:51,183 INFO [SettingsFactory] Query cache factory: org.hibernate.cache.StandardQueryCacheFactory
              09:32:51,183 INFO [SettingsFactory] Statistics: disabled
              09:32:51,183 INFO [SettingsFactory] Deleted entity synthetic identifier rollback: disabled
              09:32:51,183 INFO [SettingsFactory] Default entity-mode: pojo
              09:32:51,183 INFO [SettingsFactory] Named query checking : enabled
              09:32:51,183 INFO [SessionFactoryImpl] building session factory
              09:32:51,214 INFO [SessionFactoryObjectFactory] Factory name: persistence.units:ear=FruitTestCache.ear,jar=pear-manager.jar,unitName=FruitDS
              09:32:51,214 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
              09:32:51,214 INFO [SessionFactoryObjectFactory] Bound factory to JNDI name: persistence.units:ear=FruitTestCache.ear,jar=pear-manager.jar,unitName=FruitDS
              09:32:51,214 WARN [SessionFactoryObjectFactory] InitialContext did not implement EventContext
              09:32:51,214 INFO [SchemaExport] Running hbm2ddl schema export
              09:32:51,230 INFO [SchemaExport] exporting generated schema to database
              09:32:51,418 INFO [SchemaExport] schema export complete
              09:32:51,418 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
              09:32:51,418 INFO [UpdateTimestampsCache] starting update timestamps cache at region: FruitTestCache_ear,pear-manager_jar,FruitDS.org.hibernate.cache.UpdateTimestampsCache
              09:32:51,418 INFO [StandardQueryCache] starting query cache at region: FruitTestCache_ear,pear-manager_jar,FruitDS.org.hibernate.cache.StandardQueryCache
              09:32:51,433 INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.stateless.StatelessContainer
              09:32:51,433 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=FruitTestCache.ear,jar=pear-manager.jar,name=SystemVarBean,service=EJB3 with dependencies:
              09:32:51,433 INFO [JmxKernelAbstraction] my.test:service=PearManagement
              09:32:51,433 INFO [JmxKernelAbstraction] jboss.j2ee:ear=FruitTestCache.ear,jar=user-management.jar,name=UserManagementBean,service=EJB3
              09:32:51,433 INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.service.ServiceContainer
              09:32:51,433 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=FruitTestCache.ear,jar=pear-manager.jar,name=PearManagementMBean,service=EJB3 with dependencies:
              09:32:51,433 INFO [JmxKernelAbstraction] persistence.units:ear=FruitTestCache.ear,jar=pear-manager.jar,unitName=FruitDS
              09:32:51,433 INFO [JmxKernelAbstraction] jboss.j2ee:ear=FruitTestCache.ear,jar=user-management.jar,name=UserManagementBean,service=EJB3
              09:32:51,433 INFO [JmxKernelAbstraction] my.test:service=EventEmitter
              09:32:51,449 INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.mdb.MDB
              09:32:51,449 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=FruitTestCache.ear,jar=pear-manager.jar,name=SystemVarsListener,service=EJB3 with dependencies:
              09:32:51,449 INFO [JmxKernelAbstraction] jboss.j2ee:ear=FruitTestCache.ear,jar=user-management.jar,name=UserManagementBean,service=EJB3
              09:32:51,449 INFO [EJB3Deployer] Deployed: file:/C:/Lang/JBoss/jboss-4.2.3.GA/server/all/deploy/FruitTestCache.ear/pear-manager.jar
              09:32:51,449 INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.entity.PersistenceUnitDeployment
              09:32:51,449 INFO [JmxKernelAbstraction] installing MBean: persistence.units:ear=FruitTestCache.ear,jar=user-management.jar,unitName=FruitDS with dependencies:
              09:32:51,449 INFO [JmxKernelAbstraction] jboss.jca:name=FruitDS,service=DataSourceBinding
              

              09:32:51,449 INFO [PersistenceUnitDeployment] Starting persistence unit persistence.units:ear=FruitTestCache.ear,jar=user-management.jar,unitName=FruitDS
              09:32:51,465 INFO [Ejb3Configuration] found EJB3 Entity bean: my.test.dom.Action
              09:32:51,465 INFO [Ejb3Configuration] found EJB3 Entity bean: my.test.dom.User
              09:32:51,527 INFO [Configuration] Reading mappings from resource : META-INF/orm.xml
              09:32:51,558 INFO [Ejb3Configuration] [PersistenceUnit: FruitDS] META-INF/orm.xml found
              09:32:51,558 INFO [AnnotationBinder] Binding entity from annotated class: my.test.dom.Action
              09:32:51,574 INFO [EntityBinder] Bind entity my.test.dom.Action on table actions
              09:32:51,637 INFO [AnnotationBinder] Binding entity from annotated class: my.test.dom.User
              09:32:51,637 INFO [EntityBinder] Bind entity my.test.dom.User on table users
              09:32:51,637 INFO [AnnotationBinder] Binding entity from annotated class: my.test.dom.License
              09:32:51,637 INFO [EntityBinder] Bind entity my.test.dom.License on table licenses
              

              09:32:51,683 INFO [ConnectionProviderFactory] Initializing connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
              09:32:51,699 INFO [InjectedDataSourceConnectionProvider] Using provided datasource
              09:32:51,699 INFO [SettingsFactory] RDBMS: PostgreSQL, version: 8.3.1
              09:32:51,699 INFO [SettingsFactory] JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 8.2 JDBC3 with SSL (build 504)
              09:32:51,715 INFO [Dialect] Using dialect: org.hibernate.dialect.PostgreSQLDialect
              09:32:51,715 INFO [TransactionFactoryFactory] Transaction strategy: org.hibernate.ejb.transaction.JoinableCMTTransactionFactory
              09:32:51,715 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: org.hibernate.transaction.JBossTransactionManagerLookup
              09:32:51,715 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
              09:32:51,715 INFO [SettingsFactory] Automatic flush during beforeCompletion(): disabled
              09:32:51,715 INFO [SettingsFactory] Automatic session close at end of transaction: disabled
              09:32:51,715 INFO [SettingsFactory] JDBC batch size: 15
              09:32:51,715 INFO [SettingsFactory] JDBC batch updates for versioned data: disabled
              09:32:51,715 INFO [SettingsFactory] Scrollable result sets: enabled
              09:32:51,715 INFO [SettingsFactory] JDBC3 getGeneratedKeys(): disabled
              09:32:51,715 INFO [SettingsFactory] Connection release mode: auto
              09:32:51,715 INFO [SettingsFactory] Default batch fetch size: 1
              09:32:51,730 INFO [SettingsFactory] Generate SQL with comments: disabled
              09:32:51,730 INFO [SettingsFactory] Order SQL updates by primary key: disabled
              09:32:51,730 INFO [SettingsFactory] Order SQL inserts for batching: disabled
              09:32:51,730 INFO [SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
              09:32:51,730 INFO [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
              09:32:51,730 INFO [SettingsFactory] Query language substitutions: {}
              09:32:51,730 INFO [SettingsFactory] JPA-QL strict compliance: enabled
              09:32:51,730 INFO [SettingsFactory] Second-level cache: enabled
              09:32:51,730 INFO [SettingsFactory] Query cache: enabled
              09:32:51,730 INFO [SettingsFactory] Cache provider: org.jboss.ejb3.entity.TreeCacheProviderHook
              09:32:51,730 INFO [SettingsFactory] Optimize cache for minimal puts: enabled
              09:32:51,730 INFO [SettingsFactory] Cache region prefix: FruitTestCache_ear,user-management_jar,FruitDS
              09:32:51,746 INFO [SettingsFactory] Structured second-level cache entries: disabled
              09:32:51,746 INFO [SettingsFactory] Query cache factory: org.hibernate.cache.StandardQueryCacheFactory
              09:32:51,746 INFO [SettingsFactory] Statistics: disabled
              09:32:51,746 INFO [SettingsFactory] Deleted entity synthetic identifier rollback: disabled
              09:32:51,746 INFO [SettingsFactory] Default entity-mode: pojo
              09:32:51,746 INFO [SettingsFactory] Named query checking : enabled
              09:32:51,746 INFO [SessionFactoryImpl] building session factory
              09:32:51,824 INFO [SessionFactoryObjectFactory] Factory name: persistence.units:ear=FruitTestCache.ear,jar=user-management.jar,unitName=FruitDS
              09:32:51,824 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
              09:32:51,824 INFO [SessionFactoryObjectFactory] Bound factory to JNDI name: persistence.units:ear=FruitTestCache.ear,jar=user-management.jar,unitName=FruitDS
              09:32:51,824 WARN [SessionFactoryObjectFactory] InitialContext did not implement EventContext
              09:32:51,824 INFO [SchemaExport] Running hbm2ddl schema export
              09:32:51,824 INFO [SchemaExport] exporting generated schema to database
              09:32:52,074 INFO [SchemaExport] schema export complete
              09:32:52,074 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
              09:32:52,074 INFO [UpdateTimestampsCache] starting update timestamps cache at region: FruitTestCache_ear,user-management_jar,FruitDS.org.hibernate.cache.UpdateTimestampsCache
              09:32:52,074 INFO [StandardQueryCache] starting query cache at region: FruitTestCache_ear,user-management_jar,FruitDS.org.hibernate.cache.StandardQueryCache
              09:32:52,090 INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.stateless.StatelessContainer
              09:32:52,090 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=FruitTestCache.ear,jar=user-management.jar,name=UserManagementBean,service=EJB3 with dependencies:
              09:32:52,090 INFO [JmxKernelAbstraction] persistence.units:ear=FruitTestCache.ear,jar=user-management.jar,unitName=FruitDS
              09:32:52,090 INFO [JmxKernelAbstraction] my.test:service=EventEmitter
              09:32:52,090 INFO [EJBContainer] STARTED EJB: my.test.beans.UserManagementBean ejbName: UserManagementBean
              09:32:52,105 INFO [EJBContainer] STARTED EJB: my.test.components.AppleManagementMBean ejbName: AppleManagementMBean
              09:32:52,121 INFO [STDOUT] my.test.components.AppleManagementMBean.create()
              09:32:52,121 INFO [STDOUT] my.test.components.AppleManagementMBean.start()
              09:32:52,137 INFO [EJBContainer] STARTED EJB: my.test.components.PearManagementMBean ejbName: PearManagementMBean
              09:32:52,137 INFO [STDOUT] my.test.components.PearManagementMBean.create()
              09:32:52,152 INFO [STDOUT] my.test.components.PearManagementMBean.start()
              09:32:52,152 INFO [EJBContainer] STARTED EJB: my.test.beans.SystemVarBean ejbName: SystemVarBean
              09:32:52,168 INFO [EJBContainer] STARTED EJB: my.test.events.listeners.SystemVarsListener ejbName: SystemVarsListener
              09:32:52,168 INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.service.ServiceContainer
              09:32:52,184 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=FruitTestCache.ear,jar=user-management.jar,name=UserManagementMBean,service=EJB3 with dependencies:
              09:32:52,184 INFO [JmxKernelAbstraction] jboss.j2ee:ear=FruitTestCache.ear,jar=user-management.jar,name=UserManagementBean,service=EJB3
              09:32:52,184 INFO [EJBContainer] STARTED EJB: my.test.components.UserManagementMBean ejbName: UserManagementMBean
              09:32:52,215 INFO [STDOUT] my.test.components.UserManagementMBean.create()
              09:32:52,215 INFO [STDOUT] my.test.components.UserManagementMBean.start()
              09:32:52,215 INFO [EJB3Deployer] Deployed: file:/C:/Lang/JBoss/jboss-4.2.3.GA/server/all/deploy/FruitTestCache.ear/user-management.jar
              09:32:52,231 INFO [EARDeployer] Started J2EE application: file:/C:/Lang/JBoss/jboss-4.2.3.GA/server/all/deploy/FruitTestCache.ear/
              


              • 4. Re: JARs in EAR using single orm.xml
                jaikiran

                Can you please post the contents of your persistence.xml files and the orm.xml files? Looking at the logs, it appears that all these jars have persistence.xml with the same persistence-unit name?

                • 5. Re: JARs in EAR using single orm.xml
                  frankthetank

                  Yep, all have the same persistence-unit name.
                  I knew it was probably somehow related to the persistence.xml

                  So I just need a unique name for each persistence-unit and I am good to go?

                  • 6. Re: JARs in EAR using single orm.xml
                    frankthetank

                    Answer to myself (we need an edit function):
                    No, even changing the persistence-names will not fix the issue.

                    Here is the content of one persistence.xml (besides the different persistence-names they are all the same).

                    <persistence
                     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"
                     version="1.0">
                    
                     <persistence-unit name="user-management">
                     <!-- use the JNDI name here!! -->
                     <jta-data-source>java:/FruitDS</jta-data-source>
                     <mapping-file>META-INF/orm.xml</mapping-file>
                     <properties>
                     <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
                    
                     <property name="hibernate.cache.use_query_cache" value="true"/>
                     <property name="hibernate.cache.provider_class" value="org.jboss.ejb3.entity.TreeCacheProviderHook" />
                     <property name="hibernate.treecache.mbean.object_name" value="jboss.cache:service=EJB3EntityTreeCache" />
                    
                     </properties>
                     </persistence-unit>
                    </persistence>
                    


                    and the matching orm.xml:
                    <?xml version="1.0" encoding="UTF-8"?>
                    <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                     xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd"
                     version="1.0">
                     <persistence-unit-metadata>
                     <persistence-unit-defaults>
                     <schema>public</schema>
                     </persistence-unit-defaults>
                     </persistence-unit-metadata>
                    
                     <entity class="my.test.dom.Action">
                     <table name="actions"/>
                     <attributes>
                     <id name="id">
                     <column name="ID"/>
                     <generated-value/>
                     </id>
                     <basic name="userId">
                     <column name="user_id"/>
                     </basic>
                     <basic name="method">
                     <column name="method"/>
                     </basic>
                     </attributes>
                     </entity>
                    
                     <entity class="my.test.dom.User">
                     <table name="users"/>
                     <attributes>
                     <id name="id">
                     <column name="ID"/>
                     <generated-value/>
                     </id>
                     <basic name="name">
                     <column name="NAME"/>
                     </basic>
                     </attributes>
                     </entity>
                    
                    </entity-mappings>
                    


                    • 7. Re: JARs in EAR using single orm.xml
                      jaikiran

                       


                      I have one EAR with multiple Jars that each contain their own orm.xml (besides persistence.xml and ejb-jar.xml).
                      Each of the jars contains one Pojo defined via Deployment Descirptor as an Entity.

                      When they are deployed I can clearly see that while for each jar the system tries to map the Pojos as Entities, but each time uses the same first orm.xml that was deployed.


                      I gave this a try with a sample application on JBossAS-5.0 GA. I don't see this issue. When each of the jar in my EAR is being deployed, i can see that each of the orm.xml is read and the corresponding entity deployed.

                      Does each of your orm.xml contain "distinct" entities? Or are you mapping the same entity in all these orm.xml?