14 Replies Latest reply on Feb 6, 2012 10:26 AM by Radim Hanus

    implicit JPA subsystem dependencies don't prevent java.lang.ClassNotFoundException: org.hibernate.criterion.Projection

    Radim Hanus Expert

      Hi,

       

      my ejbjar inside an ear uses PersistenceContext annotation so that it should be a JPA subsystem as described here

      @PersistenceContext private EntityManager em;

       

      I also use hibernate criterion classes there:

      ((Session) entityManger.getDelegate()).createCriteria(type).setProjection(Projections.rowCount());

       

      but I'm getting CNFE during deployment of ear:

      22:07:33,733 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC00001: Failed to start service jboss.deployment.subunit."project.ear"."bean.jar".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."project.ear"."bean.jar".POST_MODULE: Failed to process phase POST_MODULE of subdeployment "bean.jar" of deployment "project.ear"

          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:121)

          at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824)

          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759)

          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_29]

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_29]

          at java.lang.Thread.run(Thread.java:662) [:1.6.0_29]

      Caused by: java.lang.RuntimeException: Error getting reflective information for class org.project.bean.sever.Admin

          at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:70)

          at org.jboss.as.ee.metadata.MethodAnnotationAggregator.runtimeAnnotationInformation(MethodAnnotationAggregator.java:59)

          at org.jboss.as.ejb3.deployment.processors.merging.TimerMethodMergingProcessor.handleAnnotations(TimerMethodMergingProcessor.java:64)

          at org.jboss.as.ejb3.deployment.processors.merging.AbstractMergingProcessor.processComponentConfig(AbstractMergingProcessor.java:87)

          at org.jboss.as.ejb3.deployment.processors.merging.AbstractMergingProcessor.deploy(AbstractMergingProcessor.java:72)

          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115)

          ... 5 more

      Caused by: java.lang.NoClassDefFoundError: org/hibernate/criterion/Projection

          at java.lang.Class.getDeclaredFields0(Native Method) [:1.6.0_29]

          at java.lang.Class.privateGetDeclaredFields(Class.java:2291) [:1.6.0_29]

          at java.lang.Class.getDeclaredFields(Class.java:1743) [:1.6.0_29]

          at org.jboss.as.server.deployment.reflect.ClassReflectionIndex.<init>(ClassReflectionIndex.java:57)

          at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:66)

          ... 10 more

      Caused by: java.lang.ClassNotFoundException: org.hibernate.criterion.Projection from [Module "deployment.project.ear.bean.jar:main" from Service Module Loader]

          at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:191)

          at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:361)

          at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:333)

          at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:310)

          at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:103)

          ... 15 more

       

      if I add explicit subdeployment dependency to org.hibernate the CNFE disappears:

      <jboss-deployment-structure>

        <ear-subdeployments-isolated>false</ear-subdeployments-isolated>

        <deployment>

          <dependencies>

            ...

          </dependencies>

        </deployment>

        <sub-deployment name="bean.jar">

          <dependencies>

            <module name="org.hibernate"/>

          </dependencies>

       

      is this expected behaviour if I use org.hibernate classes explicitly then I should list org.hibernate dependency ?

      R.