1 2 3 4 5 Previous Next 68 Replies Latest reply on Apr 17, 2012 8:54 AM by Ales Justin Go to original post
      • 45. Re: How to stop my WAR loading JBoss's provided 3rd party classes?
        Petr H Newbie

        You are controlling this by the before-filter config.

        If it's AFTER_BUT_JAVA_ONLY then it's the same as what you get with parent-first=false.

         

        jb-cl-domain.xml is by default java-se compliant, meaning parent-first=true.

        It could be debated what should be the default, but I think this is more natural.

        before-filter? Didn't you mean parent-policy instead? Because what could be simply done is:

        <?xml version="1.0" encoding="UTF-8"?>
        <classloading-domain xmlns="urn:jboss:classloading-domain:1.0" name="jboss.j2ee:extension=LoaderRepository,service=EARDeployment,url=&apos;myapp.ear&apos;" parent-domain="DefaultDomain">
        <parent-policy name="AFTER_BUT_JAVA_BEFORE">
          <before-filter>
           <javabean xmlns="urn:jboss:javabean:2.0" class="org.jboss.classloader.plugins.filter.NegatingClassFilter">
            <constructor>
             <parameter>
              <javabean xmlns="urn:jboss:javabean:2.0" class="org.jboss.classloader.spi.filter.RecursivePackageClassFilter">
               <constructor>
                <parameter>org.hibernate</parameter>
               </constructor>
              </javabean>
             </parameter>
            </constructor>
           </javabean-->
          </before-filter>
          <after-filter>
           <javabean xmlns="urn:jboss:javabean:2.0" class="org.jboss.classloader.plugins.filter.NegatingClassFilter">
            <constructor>
             <parameter>
              <javabean xmlns="urn:jboss:javabean:2.0" class="org.jboss.classloader.spi.filter.RecursivePackageClassFilter">
               <constructor>
                <parameter>org.hibernate</parameter>
               </constructor>
              </javabean>
             </parameter>
            </constructor>
           </javabean>
          </after-filter>
        </parent-policy>
        </classloading-domain>

         

        but then only parent policy is set to AFTER_BUT_JAVA_BEFORE and additional filters have no effect.

         

        Equivalent to AFTER_BUT_JAVA_BEFORE parent policy via filters would be that already posted:

        <?xml version="1.0" encoding="UTF-8"?>
        <classloading-domain xmlns="urn:jboss:classloading-domain:1.0" name="jboss.j2ee:extension=LoaderRepository,service=EARDeployment,url=&apos;myapp.ear&apos;" parent-domain="DefaultDomain">
        <parent-policy>
          <before-filter>
           <javabean xmlns="urn:jboss:javabean:2.0" class="org.jboss.classloader.plugins.filter.JavaOnlyClassFilter" />
          </before-filter>
          <after-filter>
           <javabean xmlns="urn:jboss:javabean:2.0" class="org.jboss.classloader.plugins.filter.EverythingClassFilter" />
          </after-filter>
        </parent-policy>
        </classloading-domain>

         

        but that of course doesn't work because of private constructors (and even if it would work it wouldn't be of much help when multiple filters can't be specified in each (before/after) section).

         

        As a quick solution I've currently removed the hibernate-validator-legacy.jar from JBoss libs which got us further, but I'll try to look at some solution with combining filters. but generally I was hoping that this jboss-classloading-domain.xml approach would bring an easy solution right away - at least for this case which is probably to be used most - I believe.

         

        And yes, I too think that parent-first is more natural, but the weirdness here is that "plain default" is false while adding classloading config turns it automatically into true. Then if you want to use filters the previous behavior changes significantly just because of that. The optimal target would be either to allow for multiple filters directly, or at least alllow change the parent-first state and let filters work over it.

        • 46. Re: How to stop my WAR loading JBoss's provided 3rd party classes?
          Ales Justin Master

          The optimal target would be either to allow for multiple filters directly

          You just need to <javabean> the right filter instance. ;-)

           

          e.g. <-- pseudo code -- I need to check this into more details (it's been a while since I wrote this javabean' stuff )

           

          <before-filter>
          <javabean xmlns="urn:jboss:javabean:2.0" class="org.jboss.classloader.plugins.filter.CombiningClassFilter">
               <constructor>

               <parameter>

               <!-- some other filter missing here + some xml syntax -->

               <javabean xmlns="urn:jboss:javabean:2.0" class="org.jboss.classloader.plugins.filter.NegatingClassFilter">
                <constructor>
                 <parameter>
                  <javabean xmlns="urn:jboss:javabean:2.0" class="org.jboss.classloader.spi.filter.RecursivePackageClassFilter">
                   <constructor>
                    <parameter>org.hibernate</parameter>
                   </constructor>
                  </javabean>
                 </parameter>
                </constructor>
               </javabean>

             </parameter>
             </constructor>
              </javabean>

          </before-filter>

          • 47. Re: How to stop my WAR loading JBoss's provided 3rd party classes?
            Ales Justin Master

            And yes, I too think that parent-first is more natural, but the weirdness here is that "plain default" is false while adding classloading config turns it automatically into true.

            Well, the "plain default" knows about deployment type:

            * ear --> isolation --> look locally first == parent-first=false

            * war, which has parent-first=false by default

             

            Whereas jb-cl-domain.xml is deployment type agnostic, hence uses the more natural default.

            • 48. Re: How to stop my WAR loading JBoss's provided 3rd party classes?
              Chris Council Newbie

              So I'm having a similar issue to Petr, I'm getting the following exception when I try to start up JBoss with my war in the server/default/deploy directory:

               

              Caused by: org.hibernate.AnnotationException: java.lang.NoSuchMethodException: org.hibernate.validator.ClassValidator.<init>(java.lang.Class, java.util.ResourceBundle, org.hibernate.validator.MessageInterpolator, java.util.Map, org.hibernate.annotations.common.reflection.ReflectionManager)
              at org.hibernate.cfg.Configuration.applyHibernateValidatorLegacyConstraintsOnDDL(Configuration.java:1651) [:3.6.0.Final]
              at org.hibernate.cfg.Configuration.applyConstraintsToDDL(Configuration.java:1623) [:3.6.0.Final]
              at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1415) [:3.6.0.Final]
              at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1345) [:3.6.0.Final]

              Caused by: org.hibernate.AnnotationException: java.lang.NoSuchMethodException: org.hibernate.validator.ClassValidator.<init>(java.lang.Class, java.util.ResourceBundle, org.hibernate.validator.MessageInterpolator, java.util.Map, org.hibernate.annotations.common.reflection.ReflectionManager)

              at org.hibernate.cfg.Configuration.applyHibernateValidatorLegacyConstraintsOnDDL(Configuration.java:1651) [:3.6.0.Final]

              at org.hibernate.cfg.Configuration.applyConstraintsToDDL(Configuration.java:1623) [:3.6.0.Final]

              at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1415) [:3.6.0.Final]

              ...

               

              Note that I'm using JPA 2.0/Hibernate 3.6.0.Final. I have a fairly simple project - in my case, it's just a war. It's a stock JBoss 6.0.0.Final install - all I've done is put my war, together with an associated db-ds.xml file, into the server/default/deploy directory. I'm also using Spring 3.0.5.

               

              Here's the relevant section of my project's pom.xml:

               

              <dependency>

              <groupId>org.hibernate</groupId>

              <artifactId>hibernate-entitymanager</artifactId>

              <version>3.6.0.Final</version>

              <exclusions>

              <exclusion>

              <groupId>javax.transaction</groupId>

              <artifactId>jta</artifactId>

              </exclusion>

              </exclusions>

              </dependency>

               

              I have also tried changing the scope of hibernate-entitymanager to "provided", in which case my project should be using JBoss 6's provided hibernate libraries, but when I do that I get this exception:

               

              Caused by: java.lang.IncompatibleClassChangeError: Class org.hibernate.ejb.HibernatePersistence does not implement the requested interface javax.persistence.spi.PersistenceProvider

              at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225) [:3.0.5.RELEASE]

              at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:308) [:3.0.5.RELEASE]

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477) [:3.0.5.RELEASE]

               

              I have also tried removing the hibernate libraries from $JBOSS_HOME/common/lib, but then the server immediately halts with this exception:

               

              13:37:45,775 INFO  [AbstractServer] Starting: JBossAS [6.0.0.Final "Neo"]

              13:37:47,530 INFO  [ServerInfo] Java version: 1.6.0_22,Apple Inc.

              13:37:47,530 INFO  [ServerInfo] Java Runtime: Java(TM) SE Runtime Environment (build 1.6.0_22-b04-307-10M3261)

              13:37:47,530 INFO  [ServerInfo] Java VM: Java HotSpot(TM) 64-Bit Server VM 17.1-b03-307,Apple Inc.

              13:37:47,530 INFO  [ServerInfo] OS-System: Mac OS X 10.6.5,x86_64

              13:37:47,531 INFO  [ServerInfo] VM arguments: -Xms128m -Xmx512m -XX:MaxPermSize=256m -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Dprogram.name=run.sh -Djava.library.path=/wdev/jboss-6.0.0.Final/bin/native/lib64 -Djava.endorsed.dirs=/wdev/jboss-6.0.0.Final/lib/endorsed

              13:37:47,620 INFO  [JMXKernel] Legacy JMX core initialized

              13:37:52,790 ERROR [AbstractKernelController] Error installing to PreInstall: name=CEMFBuilder state=Real: java.lang.NoClassDefFoundError: javax/persistence/spi/PersistenceUnitInfo

                   at java.lang.Class.getDeclaredMethods0(Native Method) [:1.6.0_22]

                   at java.lang.Class.privateGetDeclaredMethods(Class.java:2427) [:1.6.0_22]

                   at java.lang.Class.getDeclaredMethods(Class.java:1791) [:1.6.0_22]

               

              I've tried using this jboss-classloading-domain.xml in my WEB-INF directory, but it seems to have no effect:

               

              <?xml version="1.0" encoding="UTF-8"?>

               

              <classloading-domain xmlns="urn:jboss:classloading-domain:1.0"

                   name="MyDomain">

                   <parent-policy>

                        <before-filter>

                             <javabean xmlns="urn:jboss:javabean:2.0"

                                  class="org.jboss.classloader.plugins.filter.NegatingClassFilter">

                                  <constructor>

                                       <parameter>

                                            <javabean xmlns="urn:jboss:javabean:2.0"

                                                 class="org.jboss.classloader.spi.filter.RecursivePackageClassFilter">

                                                 <constructor>

                                                      <parameter>org.hibernate</parameter>

                                                 </constructor>

                                            </javabean>

                                       </parameter>

                                  </constructor>

                             </javabean>

                        </before-filter>

                   </parent-policy>

              </classloading-domain>

               

              I do get further when I remove just the hibernate-validator-legacy.jar from common/lib - but I really don't want to modify the stock JBoss installation.

               

              Any thoughts?

               

              Thanks in advance.

              • 49. Re: How to stop my WAR loading JBoss's provided 3rd party classes?
                Petr H Newbie

                You just need to <javabean> the right filter instance. ;-)

                 

                e.g. <-- pseudo code -- I need to check this into more details (it's been a while since I wrote this javabean' stuff )

                ...

                Yeah, something of that sort would do it - CombiningClassFilter::

                 

                public static CombiningClassFilter create(ClassFilter... filters) ...

                public static CombiningClassFilter create(boolean and, ClassFilter... filters) ...

                public CombiningClassFilter(boolean and, ClassFilter[] filters) ...

                 

                so passing filters via array would probably work if it's implemented that way. Anyway use of JavaOnlyClassFilter or EverythingClassFilter will still be an issue due to their private constructors.

                 

                Well, the "plain default" knows about deployment type:

                * ear --> isolation --> look locally first == parent-first=false

                * war, which has parent-first=false by default

                 

                Whereas jb-cl-domain.xml is deployment type agnostic, hence uses the more natural default.

                Right, understood, it's just unfortunate that it's not so simple to change the classloading back to plain ear default then..

                • 50. Re: How to stop my WAR loading JBoss's provided 3rd party classes?
                  Petr H Newbie

                  Chris: based on my findings you can currently either remove that hibernate-validator-legacy.jar which will put things back to work (and you can also blame Hibernate devs for the incompatibility between validator-legacy and annotations classes ), or do something like:

                   

                  <?xml version="1.0" encoding="UTF-8"?>
                  <classloading-domain xmlns="urn:jboss:classloading-domain:1.0" name="jboss.j2ee:extension=LoaderRepository,service=EARDeployment,url=&apos;myapp.ear&apos;" parent-domain="DefaultDomain">
                  <parent-policy>
                    <before-filter>
                     <javabean xmlns="urn:jboss:javabean:2.0" class="org.jboss.classloader.plugins.filter.NegatingClassFilter">
                      <constructor>
                       <parameter>
                        <javabean xmlns="urn:jboss:javabean:2.0" class="org.jboss.classloader.spi.filter.RecursivePackageClassFilter">
                         <constructor>
                          <parameter>org.hibernate.validator</parameter>
                         </constructor>
                        </javabean>
                       </parameter>
                      </constructor>
                     </javabean>
                    </before-filter>
                    <after-filter>
                     <javabean xmlns="urn:jboss:javabean:2.0" class="org.jboss.classloader.plugins.filter.NegatingClassFilter">
                      <constructor>
                       <parameter>
                        <javabean xmlns="urn:jboss:javabean:2.0" class="org.jboss.classloader.spi.filter.RecursivePackageClassFilter">
                         <constructor>
                          <parameter>org.hibernate.validator</parameter>
                         </constructor>
                        </javabean>
                       </parameter>
                      </constructor>
                     </javabean>
                    </after-filter>
                  </parent-policy>
                  </classloading-domain>

                   

                  where you'll have to replace the domain name with the one valid for your case (you can find it via jmx-console for example).

                  But that will introduce the currently discussed change in classloadin behavior - plain war is parent-first=false while with jboss-classloading-domain.xml it will change to parent-first=true (and it's not that simple to switch it back while preserving the required package filters) which may (but maybe it won't) cause you some troubles.

                  • 51. Re: How to stop my WAR loading JBoss's provided 3rd party classes?
                    Ales Justin Master
                    so passing filters via array would probably work if it's implemented that way.

                    Yeah, array usage would work.

                     

                    But unfortuantely <javabean> xml handling is too simplistic (just checked),

                    it doesn't support arrays -- by design we didn't over do it --> we have MC beans.

                     

                    But you can always simply add your own jar with custom filter impls,

                    and then simple use <javabean> to instantiate them.

                    Anyway use of JavaOnlyClassFilter or EverythingClassFilter will still be an issue due to their private constructors.

                    Like I already said, this is simple to duplicate - just check how we do it.

                    • 52. Re: How to stop my WAR loading JBoss's provided 3rd party classes?
                      Ales Justin Master
                      Caused by: org.hibernate.AnnotationException: java.lang.NoSuchMethodException: org.hibernate.validator.ClassValidator.<init>(java.lang.Class, java.util.ResourceBundle, org.hibernate.validator.MessageInterpolator, java.util.Map, org.hibernate.annotations.common.reflection.ReflectionManager)
                      at org.hibernate.cfg.Configuration.applyHibernateValidatorLegacyConstraintsOnDDL(Configuration.java:1651) [:3.6.0.Final]
                      at org.hibernate.cfg.Configuration.applyConstraintsToDDL(Configuration.java:1623) [:3.6.0.Final]
                      at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1415) [:3.6.0.Final]
                      at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1345) [:3.6.0.Final]

                      Caused by: org.hibernate.AnnotationException: java.lang.NoSuchMethodException: org.hibernate.validator.ClassValidator.<init>(java.lang.Class, java.util.ResourceBundle, org.hibernate.validator.MessageInterpolator, java.util.Map, org.hibernate.annotations.common.reflection.ReflectionManager)

                      at org.hibernate.cfg.Configuration.applyHibernateValidatorLegacyConstraintsOnDDL(Configuration.java:1651) [:3.6.0.Final]

                      at org.hibernate.cfg.Configuration.applyConstraintsToDDL(Configuration.java:1623) [:3.6.0.Final]

                      at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1415) [:3.6.0.Final]

                      ...

                       

                      Note that I'm using JPA 2.0/Hibernate 3.6.0.Final. I have a fairly simple project - in my case, it's just a war. It's a stock JBoss 6.0.0.Final install - all I've done is put my war, together with an associated db-ds.xml file, into the server/default/deploy directory. I'm also using Spring 3.0.5.

                       

                      Here's the relevant section of my project's pom.xml:

                       

                      <dependency>

                      <groupId>org.hibernate</groupId>

                      <artifactId>hibernate-entitymanager</artifactId>

                      <version>3.6.0.Final</version>

                      <exclusions>

                      <exclusion>

                      <groupId>javax.transaction</groupId>

                      <artifactId>jta</artifactId>

                      </exclusion>

                      </exclusions>

                      </dependency>

                       

                      I have also tried changing the scope of hibernate-entitymanager to "provided", in which case my project should be using JBoss 6's provided hibernate libraries, but when I do that I get this exception:

                       

                      Caused by: java.lang.IncompatibleClassChangeError: Class org.hibernate.ejb.HibernatePersistence does not implement the requested interface javax.persistence.spi.PersistenceProvider

                      at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225) [:3.0.5.RELEASE]

                      at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:308) [:3.0.5.RELEASE]

                      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477) [:3.0.5.RELEASE]

                      Hmmm, how can this happen if both you and JBossAS use the same Hibernate version?

                      • 53. Re: How to stop my WAR loading JBoss's provided 3rd party classes?
                        Ales Justin Master

                        Here's the relevant section of my project's pom.xml:

                         

                        <dependency>

                        <groupId>org.hibernate</groupId>

                        <artifactId>hibernate-entitymanager</artifactId>

                        <version>3.6.0.Final</version>

                        <exclusions>

                        <exclusion>

                        <groupId>javax.transaction</groupId>

                        <artifactId>jta</artifactId>

                        </exclusion>

                        </exclusions>

                        </dependency>

                         

                        I have also tried changing the scope of hibernate-entitymanager to "provided", in which case my project should be using JBoss 6's provided hibernate libraries, but when I do that I get this exception:

                         

                        Caused by: java.lang.IncompatibleClassChangeError: Class org.hibernate.ejb.HibernatePersistence does not implement the requested interface javax.persistence.spi.PersistenceProvider

                        at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225) [:3.0.5.RELEASE]

                        at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:308) [:3.0.5.RELEASE]

                        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477) [:3.0.5.RELEASE]

                        Hmmm, how can this happen if both you and JBossAS use the same Hibernate version?

                        This would mean that somehow JPA slips into your project, hence those JPA classes get used -- as by the servlet spec.

                        Otoh, JBoss' Hibernate of course doesn't use those JPA classes, but its own.

                        • 54. Re: How to stop my WAR loading JBoss's provided 3rd party classes?
                          Chris Council Newbie

                          Ales Justin wrote:

                           

                          Hmmm, how can this happen if both you and JBossAS use the same Hibernate version?

                           

                          That's confusing to me, too. When I build my war using the default "compile" scope I have these jars inside WEB-INF/lib:

                           

                           

                           

                          hibernate-commons-annotations-3.2.0.Final.jar
                          hibernate-core-3.6.0.Final.jar
                          hibernate-entitymanager-3.6.0.Final.jar
                          hibernate-jpa-2.0-api-1.0.0.Final.jar

                          hibernate-commons-annotations-3.2.0.Final.jar

                          hibernate-core-3.6.0.Final.jar

                          hibernate-entitymanager-3.6.0.Final.jar

                          hibernate-jpa-2.0-api-1.0.0.Final.jar

                           

                           

                          I've verified that those jars are not in my war when I build using the "provided" scope.

                           

                          These versions seem to be the same as in the JBoss distribution. The only one that's different is hibernate-commons-annotations, which is "6.0.0.Final" in the manifest. (It would be nice if the libs in $JBOSS_HOME/common/lib would have the version numbers as part of the filename, so I didn't have to go into each one and look at the manifest to determine what versions they are!)

                           

                          I did find this kind of interesting:

                           

                           

                          $ ls -l /appserver/jboss-6.0.0.Final/common/lib/hibernate-core.jar

                          -rw-rw-r--@ 1 chriscouncil  staff  3116797 Dec 28 08:30 /wdev/jboss-6.0.0.Final/common/lib/hibernate-core.jar

                          $ ls -l /m2repo/org/hibernate/hibernate-core/3.6.0.Final/hibernate-core-3.6.0.Final.jar

                          -rw-r--r--  1 chriscouncil  staff  3083100 Oct 14 16:22 /mm/org/hibernate/hibernate-core/3.6.0.Final/hibernate-core-3.6.0.Final.jar

                           

                          My hibernate jars come from the jboss public repo at https://repository.jboss.org/nexus/content/repositories/public, so I'd expect them to be the same size. Obviously the MD5 sums don't match I haven't checked any further, though.

                           

                           

                           

                           

                           

                          • 55. Re: How to stop my WAR loading JBoss's provided 3rd party classes?
                            Petr H Newbie

                             

                            But you can always simply add your own jar with custom filter impls,

                            and then simple use <javabean> to instantiate them.

                            ...

                            Like I already said, this is simple to duplicate - just check how we do it.


                            Yes I know, that's how I'll try it (after we manage to get the app at least fully starting on JBAS 6) but the main idea was to avoid the need for messing up with the JBoss-level code as much as possible - so try to make it possible with standard JBoss code and just "configuration changes".

                             

                             

                            As for that IncompatibleClassChangeError discussed in parallel - yes I think you're right with JPA stuff being in the app, I was seeing very similar issues when having JAXB and JTA stuff in there in my case. Here, parent-first=true would very likely "fix" that as well.

                             

                            However parent-first=false is easier in my case, for example because of logging - I've got a log4j property file on classpath, initializing it via Spring (org.springframework.web.util.Log4jConfigListener) and with parent-first=false it logs more or less (well it steals JBoss' own logging but whatever)"out-of-the-box" while with parent-first=true everything naturally goes into JBoss server log. I recall there was supposed to be implemented some possibility to let it working properly with these multiple log4j configs etc (I think this was it but I'm not that sure at the moment: http://community.jboss.org/wiki/LoggingPOJOServiceRequirements) but haven't looked at it yet.

                            • 56. Re: How to stop my WAR loading JBoss's provided 3rd party classes?
                              Chris Council Newbie

                              So I did have a JPA jar (org.hibernate.java-persistence:jpa-api:2.0-cr-1) in my war, coming from a transitive dependency. After removing it (and the four hibernate jars hibernate-commons-annotations-3.2.0.Final.jar, hibernate-core-3.6.0.Final.jar, hibernate-entitymanager-3.6.0.Final.jar, hibernate-jpa-2.0-api-1.0.0.Final.jar), I got the following exception on startup:

                               

                              Caused by: java.lang.IllegalArgumentException: Can't find a persistence unit named 'null' in AbstractVFSDeploymentContext@1032284510{vfs:///wdev/jboss-6.0.0.Final/server/default/deploy/properties-webapp-0.0.1-SNAPSHOT.war}
                              at org.jboss.jpa.resolvers.BasePersistenceUnitDependencyResolver.resolvePersistenceUnitSupplier(BasePersistenceUnitDependencyResolver.java:107) [:1.0.2-alpha-3]
                              at org.jboss.web.deployers.AbstractWarDeployer.deployWebModule(AbstractWarDeployer.java:793) [:6.0.0.Final

                              Caused by: java.lang.IllegalArgumentException: Can't find a persistence unit named 'null' in AbstractVFSDeploymentContext@1032284510{vfs:///appserver/jboss-6.0.0.Final/server/default/deploy/my-webapp-0.0.1-SNAPSHOT.war}

                              at org.jboss.jpa.resolvers.BasePersistenceUnitDependencyResolver.resolvePersistenceUnitSupplier(BasePersistenceUnitDependencyResolver.java:107) [:1.0.2-alpha-3]

                              at org.jboss.web.deployers.AbstractWarDeployer.deployWebModule(AbstractWarDeployer.java:793) [:6.0.0.Final]

                              I get a similar exception when I tried setting "parent-first" to false in my jboss-classloading.xml (not removing any hibernate or jpa jars).
                              So the only way I can get things to work right now is to have those four jars inside my war, and hibernate-validator-legacy.jar manually removed from common/lib. I'll try Petr's solution proposed in comment #50 as well.
                              Oh well. I don't really want to remove the hibernate jars from my war, because then it won't work on Glassfish and Jetty.
                              Any thoughts on why JBoss won't start up without the hibernate jars in common/lib? It seems like there could be problems if I upgrade the war to another version of Hibernate in the future, and if I'm going to be modifying common/lib anyway, maybe I should just remove Hibernate altogether... or alternatively, ensure that the version I want is in that directory.
                              • 57. Re: How to stop my WAR loading JBoss's provided 3rd party classes?
                                Ales Justin Master

                                Actually thinking about this, both (or all) of these things should just work out-of-the-box,

                                if you have all compatible components.

                                If it doesn't work, then it's probably not CL issue, but Hibernate components incompatibility.

                                 

                                ear and war should both already have parent-first=false lookups:

                                * ear by that isolation flag in EARCLDCeployer

                                * war by the spec

                                 

                                I know we have tests for this in our testsuite, hence I doubt this is CL issue -- I still could be wrong.

                                Whereas Hibernate had its components issues.

                                • 58. Re: How to stop my WAR loading JBoss's provided 3rd party classes?
                                  Ales Justin Master

                                  I was too early to say this is Hibernate issue.

                                  It actually takes quite some magic to make it work,

                                  and there are still some issues with it (see EJB3 timers comment).

                                   

                                  Together with Emmanuel we created this test project,

                                  and I actually made it work, but it's very limited in the JEE features.

                                  You have to handle most of the things yourself in order to make it work.

                                  e.g. EM/Session instantiation, Tx, ...

                                   

                                  But at least it will shed some light on the subject:

                                  * https://github.com/alesj/hib-in-war/commit/a320e0a2bfe3e9cdf5524ea81da0ef34413ab46f

                                  • 59. Re: How to stop my WAR loading JBoss's provided 3rd party classes?
                                    Fabrice Daugan Newbie

                                    In fact all issues come from the fact JBoss load the persistence.xml too early. I've tested to update the <provider> tag with a little patch by using "org.hibernate.ejb.HibernatePersistenceMyImpl" (this class has to start with "org.hibernate.ejb.HibernatePersistence" to be considered by Hibernate configuration, but hibernate dos not use the CL of this provided class, but the one of "PersistenceUnitInfo"  (see Ejb3Configuration#configure(PersistenceUnitInfo, Map). One solution could consist to wrap the "PersistenceUnitInfo" with a custom proxy class to force the CL....

                                    Anyway, to be fully compliant with JBoss (and some other JEE servers) I've switch to this solution : http://fabdouglas.blogspot.com/2011/01/how-to-run-spring-3-jpa-application-to.html