-
1. Re: migrated war deployed in as7 but no working annotationbinding
prasad.deshpande Nov 30, 2011 9:19 AM (in response to kwaegema)Can you please show how your persistence.xml looks like? Also, where is it placed? What is the location, Also if you could attach server.log file too?
-
2. Re: migrated war deployed in as7 but no working annotationbinding
kwaegema Nov 30, 2011 10:37 AM (in response to prasad.deshpande)Structure of webapp.war:
./WEBINF
/lib
core.1.0-SNAPSHOT.jar
...
...
...
The structure of core.1.0-SNAPSHOT.jar:
./META-INF
jpa-persistance.xml (also tried with persistence.xml)
./net
/straininfo2
/entities
...
applicationContext-core.xml
...
The persistence.xml /jpa-persistence.xml has 4 persistence units like this:
<persistence-unit name="straininfo2-xenneke">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.archive.autodetection" value="class"/> <!-- tested with and without this property-->
<property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver" />
<property name="hibernate.connection.url"
value="jdbc:oracle:thin:@***:***:***" />
<property name="hibernate.connection.username" value="***" />
<property name="hibernate.connection.password" value="***" />
<!-- Added to avoid NPE's on jboss! -->
<property name="hibernate.query.jpaql_strict_compliance" value="false" />
<!-- JDBC connection pool (use the built-in) -->
<!-- <property name="hibernate.connection.pool_size" value="1" /> -->
<!-- JDBC connection pool (use c3p0) -->
<property name="hibernate.c3p0.min_size" value="5" />
<property name="hibernate.c3p0.max_size" value="10" />
<!-- Max time a connection idles (4 hours) -->
<property name="hibernate.c3p0.timeout" value="14400" />
<property name="hibernate.c3p0.max_statements" value="300" />
<!-- Test idle connections every two hours -->
<property name="hibernate.c3p0.idleTestPeriod" value="7200" />
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
<!-- Enable Hibernate's automatic session context management-->
<property name="hibernate.current_session_context_class"
value="thread" />
<property name="jboss.as.jpa.providerModule" value="hibernate3-bundled" />
<!-- Disable the second-level cache -->
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider" />
</properties>
</persistence-unit>
My server.log is in attachment.
Thanks!!
-
server.log.zip 12.1 KB
-
-
3. Re: migrated war deployed in as7 but no working annotationbinding
prasad.deshpande Nov 30, 2011 11:18 AM (in response to kwaegema)name of the file should be persistence.xml, having said that, your listed jpa-persistence.xml has PU name as straininfo2-xenneke and log is reading
15:59:41,451 INFO [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-4) Processing PersistenceUnitInfo [
name: straininfo2-test-xenneke
...]
does that mean you have persistence.xml in some other jar file in WEB-INF/lib or WEB-INF/classes?
Also, if Jboss is providing JPA to your application then your log should have an entry like
[org.jboss.jpa] (MSC service thread 1-1) : Read persistence.xml for straininfo2-test-xenneke
but I couldn't see any such. Also does your classes has @Entity annotation (javax.persistence.Entity) on it otherwise it makes sense why it's asking for <class> tags?
Also, could you please try with 7.1 Beta1 release of Jboss to see if you have same problem?
-
4. Re: migrated war deployed in as7 but no working annotationbinding
kwaegema Dec 1, 2011 5:22 AM (in response to prasad.deshpande)I first had persistence.xml, I didn't work. Then I got this renaming from : http://community.jboss.org/blogs/mariusb/2011/07/13/spring-and-jboss-as7-part-1-getting-started section 'spring travel'. But no changes..
I got 4 persistence units, i accidentally copied another, but it is the same (just -test- is with mor logging enabled).
my persistence is indeed in another jar file in WEB-INF/lib: the main war is the web-application and the core (persistence, entity classes, dao , logic) is in that jar.
My classes have @Entities.
I tried now with 7.1.Beta1. Because 7.1 had an error because multiple PU's were in my persistence.xml, I changed it (temporary) to only one PU:
<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">
<!-- Configuratie van de persistence units. -->
<persistence-unit name="straininfo2-test-xenneke">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.archive.autodetection" value="class"/>
<property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver" />
<property name="hibernate.connection.url"
value="jdbc:oracle:thin:@***:1521:***" />
<property name="hibernate.connection.username" value="***" />
<property name="hibernate.connection.password" value="***" />
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
<!-- Echo all executed SQL to stdout -->
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<!-- Added to avoid NPE's on jboss! -->
<property name="hibernate.query.jpaql_strict_compliance" value="false" />
<!-- JDBC connection pool (use the built-in) -->
<!-- <property name="hibernate.connection.pool_size" value="1" /> -->
<!-- JDBC connection pool (use c3p0) -->
<property name="hibernate.c3p0.min_size" value="3" />
<property name="hibernate.c3p0.max_size" value="5" />
<property name="hibernate.c3p0.timeout" value="900" />
<property name="hibernate.c3p0.max_statements" value="300" />
<!-- Test idle connections every two hours -->
<property name="hibernate.c3p0.idleTestPeriod" value="7200" />
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
<!-- Enable Hibernate's automatic session context management-->
<property name="hibernate.current_session_context_class"
value="thread" />
<!-- Disable the second-level cache -->
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider" />
<property name="jboss.as.jpa.providerModule" value="hibernate3-bundled" />
</properties>
</persistence-unit>
</persistence>
I also changed the name back to persistence.xml.
I have the server.log in attachment.
Now that persistence.xml is back in place, I see again two times the processing PersistenceUnit:
10:30:53,993 INFO [org.jboss.jpa] (MSC service thread 1-4) JBAS011401: Read persistence.xml for straininfo2-test-xenneke
10:30:56,215 INFO [org.jboss.jpa] (MSC service thread 1-10) JBAS011402: Starting Persistence Unit Service 'ROOT.war#straininfo2-test-xenneke'
10:30:56,358 INFO [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-10) Processing PersistenceUnitInfo [
name: straininfo2-test-xenneke
...]
...
...
...
10:30:59,979 INFO [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean] (MSC service thread 1-3) Building JPA container EntityManagerFactory for persistence unit 'straininfo2-test-xenneke'
10:30:59,979 INFO [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-3) Processing PersistenceUnitInfo [
name: straininfo2-test-xenneke
...]
The first does some annotation binding (with some missing packets) but the second doesn't..
Thanks!!
-
server.log.zip 17.1 KB
-
-
5. Re: migrated war deployed in as7 but no working annotationbinding
prasad.deshpande Dec 1, 2011 5:51 AM (in response to kwaegema)1 of 1 people found this helpfulkwaegema wrote:
My classes have @Entities.
Generally, I've observed for Jboss JPA, the jar file that contains persistence.xml only will be scanned for @Entity annotation. So if you have few entities in another separate jar, that jar will not be looked/scanned for classes containig @Entity annotation. This might be true in your case.
Now that persistence.xml is back in place, I see again two times the processing PersistenceUnit:
10:30:53,993 INFO [org.jboss.jpa] (MSC service thread 1-4) JBAS011401: Read persistence.xml for straininfo2-test-xenneke
10:30:56,215 INFO [org.jboss.jpa] (MSC service thread 1-10) JBAS011402: Starting Persistence Unit Service 'ROOT.war#straininfo2-test-xenneke'
10:30:56,358 INFO [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-10) Processing PersistenceUnitInfo [
name: straininfo2-test-xenneke
...]
...
...
...
10:30:59,979 INFO [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean] (MSC service thread 1-3) Building JPA container EntityManagerFactory for persistence unit 'straininfo2-test-xenneke'
10:30:59,979 INFO [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-3) Processing PersistenceUnitInfo [
name: straininfo2-test-xenneke
...]
The first does some annotation binding (with some missing packets) but the second doesn't..
seems that Jboss & spring both are kicking-in for processing PU. I'm not sure about how spring does it so my help on spring will be limited. It seems to me that spring JPA is not scanning entities however, Jboss JPA is scanning see the following logs..
10:30:56,574 INFO [org.hibernate.cfg.AnnotationBinder] (MSC service thread 1-10) Binding entity from annotated class: net.straininfo2.entities.Field
10:30:56,600 INFO [org.hibernate.cfg.annotations.EntityBinder] (MSC service thread 1-10) Bind entity net.straininfo2.entities.Field on table si2.fields
May be you want to try Jboss JPA or play around with spring one..
-
6. Re: migrated war deployed in as7 but no working annotationbinding
kwaegema Dec 1, 2011 8:22 AM (in response to prasad.deshpande)all my entities are in the same jar
I think indeed both Jboss and spring are processing PU.
I would like to use Spring because then the same war can be used on local Jetty webservers (for development).
I started over once again with this guide (https://docs.jboss.org/author/display/AS7/Spring+applications+development+and+migration+guide)
And thus changing back to jpa-persistence so that Jboss stops processing PU. Now there's only the second processing (org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean) but still no scanning entities..
Because it worked this way with Jetty and Jboss 4, I'm still convinced its a problem between Jboss and Spring/Hibernate..
I will ask a new question with clear notice that it is a spring-jboss problem..
Thanks for helping me find the problem!