1 Reply Latest reply on Aug 5, 2012 9:19 AM by Ondrej Zizka

    Automatic jar scanning (How to disable?)

    Ondrej Zizka Master

      Hi, I have an app with FreeMarker as a dependency. It's packaged as an uber-jar with deps, using Maven Shade plugin.

      AS 7.1.2

      FreeMarker 2.3.19

       

      Freemarker has a lot of dependencies, amongst them maven-cobertura-plugin and maven-findbugs-plugin (through jaxen).

       

      Some deps are optional, but when FreeMarker is deployed with an app to JBoss AS, scanning hits classes which use them and AS throws a WARN:

       

      18:37:43,193 WARN  [org.jboss.modules] (MSC service thread 1-5) Failed to define class freemarker.ext.xml.DomNavigator$DomXPathEx in Module "deployment.pohlidame-fakturace-1.0-SNAPSHOT.jar:main" from Service Module Loader: java.lang.LinkageError: Failed to link freemarker/ext/xml/DomNavigator$DomXPathEx (Module "deployment.pohlidame-fakturace-1.0-SNAPSHOT.jar:main" from Service Module Loader)
              at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:396)
              at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:243)
              at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:73)
              at org.jboss.modules.Module.loadModuleClass(Module.java:527)
              at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:182)
              at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
              at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
              at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
              at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
              at org.jboss.as.jpa.hibernate4.HibernateAnnotationScanner.getPackagesInJar(HibernateAnnotationScanner.java:171)
              at org.hibernate.ejb.Ejb3Configuration.addScannedEntries(Ejb3Configuration.java:490) [hibernate-entitymanager-4.1.5.SP1.jar:4.1.5.SP1]
              at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:852) [hibernate-entitymanager-4.1.5.SP1.jar:4.1.5.SP1]
              at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:597) [hibernate-entitymanager-4.1.5.SP1.jar:4.1.5.SP1]
              at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73) [hibernate-entitymanager-4.1.5.SP1.jar:4.1.5.SP1]
              at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162) [jboss-as-jpa-7.1.2.Final.jar:7.1.2.Final]
              at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85) [jboss-as-jpa-7.1.2.Final.jar:7.1.2.Final]
              at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
              at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
              at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_27]
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_27]
              at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_27]
      Caused by: java.lang.NoClassDefFoundError: org/jaxen/dom/DOMXPath
              at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.6.0_27]
              at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) [rt.jar:1.6.0_27]
              at java.lang.ClassLoader.defineClass(ClassLoader.java:615) [rt.jar:1.6.0_27]
              at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) [rt.jar:1.6.0_27]
              at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:327)
              at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:391)
              ... 20 more
      Caused by: java.lang.ClassNotFoundException: org.jaxen.dom.DOMXPath from [Module "deployment.pohlidame-fakturace-1.0-SNAPSHOT.jar:main" from Service Module Loader]
              at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
              at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
              at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
              at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)
              at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)
              at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
              at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
              ... 26 more
      

       

      The same with Ant's MatchingTask etc.

       

      And then the deployment fails when Hibernate scans the app for entities:

       

      18:37:43,200 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-5) MSC00001: Failed to start service jboss.persistenceunit."pohlidame-fakturace-1.0-SNAPSHOT.jar#PohlidamePU": org.jboss.msc.service.StartException in service jboss.persistenceunit."pohlidame-fakturace-1.0-SNAPSHOT.jar#PohlidamePU": Failed to start service
              at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
              at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_27]
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_27]
              at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_27]
      Caused by: java.lang.RuntimeException: error trying to scan <jar-file>: vfs:/content/pohlidame-fakturace-1.0-SNAPSHOT.jar/
              at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:855)
              at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:597)
              at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
              at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162)
              at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85)
              at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
              at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
              ... 3 more
      Caused by: java.lang.RuntimeException: JBAS011431: Could not load entity class 'freemarker.ext.xml.DomNavigator$DomXPathEx' with PersistenceUnitInfo.getClassLoader()
              at org.jboss.as.jpa.hibernate4.HibernateAnnotationScanner.getPackagesInJar(HibernateAnnotationScanner.java:175)
              at org.hibernate.ejb.Ejb3Configuration.addScannedEntries(Ejb3Configuration.java:490)
              at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:852)
              ... 9 more
      Caused by: java.lang.ClassNotFoundException: freemarker.ext.xml.DomNavigator$DomXPathEx from [Module "deployment.pohlidame-fakturace-1.0-SNAPSHOT.jar:main" from Service Module Loader]
              at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
              at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
              at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
              at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
              at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
              at org.jboss.as.jpa.hibernate4.HibernateAnnotationScanner.getPackagesInJar(HibernateAnnotationScanner.java:171)
              ... 11 more
      

       

       

      How can I disable these scans? Prefferably for certain jars or packages. Or is there a better solution?

       

      PS: I know about <exclude-unlisted-classes> in persistence.xml.  But I want to specify excluded packages, not the included.