-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: mappings not loaded for multiple apps in jBoss
PostPosted: Thu Oct 15, 2009 11:48 am 
Beginner
Beginner

Joined: Wed Aug 11, 2004 3:50 pm
Posts: 26
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.