1 Reply Latest reply on Dec 2, 2011 4:54 AM by kwaegema

    Spring application migration to jboss 7 Persistent Unit not scanned

    kwaegema Newbie

      Hi

       

      I migrated my application war from Jboss 4.2.3 to Jboss 7.0.2 Final.

      I use hibernate 3.5, spring 3.0.5FINAL en struts 2.2.3.1. Those were all added to the WEB-INF/lib folder in the .war.

      I got it deployed eventually, but the app still doesn't work.

      I asked a question here (http://community.jboss.org/message/639279#639279), and I know where the problem is now, but I don't know how to solve it.

      I started over and I followed this guide to do it: https://docs.jboss.org/author/display/AS7/Spring+applications+development+and+migration+guide

      (Section JPA- Using Spring-managed persistence units)

       

      It deploys under jboss 7 and I can see some content. The problem is in the persistence.

       

      First of all: this is my structure:

       

      Structure of webapp.war:

       

      ./WEBINF

           /lib

               core.1.0-SNAPSHOT.jar

                ...

           ...

      ...

       

       

      The structure of core.1.0-SNAPSHOT.jar:

       

      ./META-INF

           jpa-persistance.xml

      ./net

            /straininfo2

                /entities

                     ...

      applicationContext-core.xml

       

      my jpa-persistence.xml (named like in the guide for using spring-managed PU's) is 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 @Entity. This is my jpa-persistence

       

       

      <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>

       

      After using that guide, it still doesn't work.: I get this message in the server.log:

       

      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

                ...]

       

      But then there's nothing, while when usin Jetty (or when Jboss JPA is active) there are messages like

       

      2011-12-01 12:03:10,938 INFO  [AnnotationBinder.java:529] : Binding entity from annotated class: net.straininfo2.entities.AccessLog

      2011-12-01 12:03:10,997 INFO  [EntityBinder.java:501] : Bind entity net.straininfo2.entities.AccessLog on table si2.AccessLog

       

       

      This results in errors like

      message: Unknown entity: net.straininfo2.entities.AccessLog

      stack: java.lang.IllegalArgumentException: Unknown entity: net.straininfo2.entities.AccessLog at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:671) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native

       

      I can have those entries if I add it with <class> in the persistence file, but doing that for a 100 entities doesn't seem me a good thing..

       

      I added my server.log in attach.

       

      Does anyone knows how to solve this?

      Thanks in advance!!