I am using jBoss with its default Unified classloader (that means that unless you do something special, the classes and resources of apps are visible by other apps).
I have a library app that is used by most of my apps and uses JPA to maintain a centralized audit-trail facility.
I have a totally independent webapp that uses JPA to manage some tables.
Both apps are written using the JPA + Spring + Hibernate approach to JPA, relying mostly on JPA annotations. The persistence-<appName>.xml files only contain the persistence-unit name for its app, and explicitly list the mapping classes using the <class> tag.
PROBLEM:
- If I only have one of the two apps present... no problem. Everything works like a charm.
- If I have boths apps present... big problem. The library apps (correctly) loads first and works fine. The webapp loads last, gives no errors, but its mappings are NOT loaded... causing it to fail at the first query attempt.
This webapp JPA configuration:
Code:
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceXmlLocation" value="WEB-INF/persistence-myWebapp.xml"/>
<property name="dataSource" ref="myDataSource" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="false" />
<property name="databasePlatform" value="org.hibernate.dialect.SQLServerDialect"/>
</bean>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
<property name="dataSource" ref="myDataSource" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
and this is its persistence-myWebapp.xml:
Quote:
<persistence-unit name="MyWebapp" transaction-type="RESOURCE_LOCAL">
<class>myPkg.MyMappingClass1</class>
<class>myPkg.MyMappingClass2</class>
<class>myPkg.MyMappingClass3</class>
</persistence-unit>
And the library app is setup in a similar way.
- Any idea about what is wrong?
- Is the webapp's JPA ignoring the instructions and using the library app's persistence.xml mappings?
- Is there a way to tell JPA to ignore persistence.xml and instead rely on annotations for the mappings? (I read some stuff saying that it should be possible, but that hibernate doesn't support it - is that true?)
BTW... the whole thing works great on Tomcat but not on jBoss 4.3 EAP. The whole situation seems nuts since jBoss owns Hibernate!!! You'd expect that things would work in their environment if they work anywhere.