5 Replies Latest reply on Aug 16, 2013 10:26 AM by Martin Grotzke

    EAP 6.1: package-info.java with @TypeDef annotation not processed - ClassLoader issue?

    Martin Grotzke Newbie

      Hi,

       

      in EAP 6.1 a package-info.java with a hibernate @TypeDef annotation is not processed, when deploying the war jboss reports a

        "MappingException: Could not determine type ...".

       

      Can someone please confirm that this is a bug (so that I can submit it in bugzilla), or point me to a solution/workaround?

       

      The details:

       

      This issue happens with EAP 6.1. In contrast, with AS 7.1.1.Final and current wildfly master it's working as expected (UserTypes registered via @TypeDef on package-info.java are used by hibernate).

       

      I've modified the hibernate4 sample that allows to reproduce the issue:

      https://github.com/magro/jboss-as-quickstart/tree/master/hibernate4

      (commit 9d0cd7d6 shows what's changed)

       

      To reproduce the issue:

      • $ git clone git@github.com:magro/jboss-as-quickstart.git
      • $ cd jboss-as-quickstart/hibernate4
      • start your EAP 6.1 standalone
      • $ mvn clean package jboss-as:deploy

      This fails with "org.hibernate.MappingException: Could not determine type for: org.jboss.as.quickstart.hibernate4.model.EmailAddress" (more log output is shown in the end).

       

      This happens because the package-info.java with the @TypeDef (for EmailAddress UserType) is not processed.

       

      During debugging I found that in HibernateAnnotationScanner.getPackagesInJar some class.getPackage() returns null, because the underlying classloader does not know the package of the class.

      This is the related call stack copied from eclipse's Debug view:

      {noformat}

      TempClassLoader(ConcurrentClassLoader).findLoadedPackage(String) line: 499

      TempClassLoader(ConcurrentClassLoader).getPackageByName(String) line: 477

      TempClassLoader(ConcurrentClassLoader).getPackage(String) line: 465

      Package.getPackage(Class<?>) line: 332

      Class<T>.getPackage() line: 717

      HibernateAnnotationScanner.getPackagesInJar(URL, Set<Class<Annotation>>) line: 182

      Ejb3Configuration.addScannedEntries(ScanningContext, List<String>, List<String>, List<NamedInputStream>, List<String>) line: 491

      Ejb3Configuration.scanForClasses(ScanningContext, List<String>, List<String>, List<NamedInputStream>) line: 866

      Ejb3Configuration.configure(PersistenceUnitInfo, Map) line: 605

      HibernatePersistence.createContainerEntityManagerFactory(PersistenceUnitInfo, Map) line: 91

      {noformat}

       

      The TempClassLoader asked to findLoadedPackage(String) contains a packages field (Map<String, Package>), which is plain empty.

      I haven't debugged further why there are no packages defined in the classloader (should happen via definePackage), perhaps it's just the wrong classloader that's used.

       

      Can someone please confirm that this is a bug (so that I can submit it in bugzilla), or point me to a solution/workaround?

       

      Thanx && cheers,

      Martin


       

       

      This is an extract of the log output when deploying the war file:

       

      {noformat}

      12:25:26,176 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015876: Starting deployment of "jboss-as-hibernate4.war" (runtime-name: "jboss-as-hibernate4.war")

      12:25:26,222 INFO  [org.jboss.as.jpa] (MSC service thread 1-14) JBAS011401: Read persistence.xml for primary

      12:25:26,240 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-13) JBAS015877: Stopped deployment jboss-as-hibernate4.war (runtime-name: jboss-as-hibernate4.war) in 63ms

      12:25:26,245 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-9) JBAS015876: Starting deployment of "jboss-as-hibernate4.war" (runtime-name: "jboss-as-hibernate4.war")

      12:25:26,285 INFO  [org.jboss.as.jpa] (MSC service thread 1-5) JBAS011401: Read persistence.xml for primary

      12:25:26,308 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-6) JBAS010400: Bound data source [java:jboss/datasources/Hibernate4QuickstartDS]

      12:25:26,319 INFO  [org.jboss.weld.deployer] (MSC service thread 1-10) JBAS016002: Processing weld deployment jboss-as-hibernate4.war

      12:25:26,321 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-10) JNDI bindings for session bean named MemberRegistration in deployment unit deployment "jboss-as-hibernate4.war" are as follows:

       

       

              java:global/jboss-as-hibernate4/MemberRegistration!org.jboss.as.quickstart.hibernate4.service.MemberRegistration

              java:app/jboss-as-hibernate4/MemberRegistration!org.jboss.as.quickstart.hibernate4.service.MemberRegistration

              java:module/MemberRegistration!org.jboss.as.quickstart.hibernate4.service.MemberRegistration

              java:global/jboss-as-hibernate4/MemberRegistration

              java:app/jboss-as-hibernate4/MemberRegistration

              java:module/MemberRegistration

       

       

      12:25:26,353 INFO  [org.jboss.weld.deployer] (MSC service thread 1-4) JBAS016005: Starting Services for CDI deployment: jboss-as-hibernate4.war

      12:25:26,363 INFO  [org.jboss.as.jpa] (ServerService Thread Pool -- 11) JBAS011402: Starting Persistence Unit Service 'jboss-as-hibernate4.war#primary'

      12:25:26,364 INFO  [org.hibernate.ejb.Ejb3Configuration] (ServerService Thread Pool -- 11) HHH000204: Processing PersistenceUnitInfo [

              name: primary

              ...]

      12:25:26,365 INFO  [org.jboss.weld.deployer] (MSC service thread 1-6) JBAS016008: Starting weld service for deployment jboss-as-hibernate4.war

      12:25:26,386 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 11) MSC000001: Failed to start service jboss.persistenceunit."jboss-as-hibernate4.war#primary": org.jboss.msc.service.StartException in service jboss.persistenceunit."jboss-as-hibernate4.war#primary": javax.persistence.PersistenceException: [PersistenceUnit: primary] Unable to build EntityManagerFactory

              at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:103)

              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_25]

              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_25]

              at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_25]

              at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.1.0.Final-redhat-1.jar:2.1.0.Final-redhat-1]

      Caused by: javax.persistence.PersistenceException: [PersistenceUnit: primary] Unable to build EntityManagerFactory

              at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:930)

              at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)

              at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:92)

              at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:200)

              at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$600(PersistenceUnitServiceImpl.java:57)

              at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:99)

              ... 4 more

      Caused by: org.hibernate.MappingException: Could not determine type for: org.jboss.as.quickstart.hibernate4.model.EmailAddress, at table: MemberHibernate4Demo, for columns: [org.hibernate.mapping.Column(email)]

              at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:314)

              at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:292)

              at org.hibernate.mapping.Property.isValid(Property.java:239)

              at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:469)

              at org.hibernate.mapping.RootClass.validate(RootClass.java:270)

              at org.hibernate.cfg.Configuration.validate(Configuration.java:1284)

              at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1742)

              at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:94)

              at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:920)

              ... 9 more

       

       

      12:25:26,500 ERROR [org.jboss.as.server] (management-handler-thread - 1) JBAS015860: Redeploy of deployment "jboss-as-hibernate4.war" was rolled back with the following failure message:

      {"JBAS014671: Failed services" => {"jboss.persistenceunit.\"jboss-as-hibernate4.war#primary\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"jboss-as-hibernate4.war#primary\": javax.persistence.PersistenceException: [PersistenceUnit: primary] Unable to build EntityManagerFactory

          Caused by: javax.persistence.PersistenceException: [PersistenceUnit: primary] Unable to build EntityManagerFactory

          Caused by: org.hibernate.MappingException: Could not determine type for: org.jboss.as.quickstart.hibernate4.model.EmailAddress, at table: MemberHibernate4Demo, for columns: [org.hibernate.mapping.Column(email)]"}}

       

      {noformat}