9 Replies Latest reply on Apr 23, 2015 3:50 PM by smarlow

    Gettting java.lang.ClassNotFoundException: org.hibernate.HibernateException

    minoleg

      Hello,

       

      I am getting java.lang.ClassNotFoundException: org.hibernate.HibernateException when I deploy my application to Wildfly 8.1.  How is it possible if Hibernate one of the core modules and HibernateException should be available to the application?


      Here is my stack trace:


      2015-04-14 22:06:09,314 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC000001: Failed to start service jboss.deployment.unit."mwcog.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."mwcog.war".POST_MODULE: JBAS018733: Failed to process phase POST_MODULE of deployment "mwcog.war"

        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:166) [wildfly-server-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]

        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]

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

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

        at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_76]

      Caused by: java.lang.RuntimeException: JBAS018757: Error getting reflective information for class bti.tdms.ajaxcontroller.AjaxController with ClassLoader ModuleClassLoader for Module "deployment.mwcog.war:main" from Service Module Loader

        at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:72) [wildfly-server-8.1.0.Final.jar:8.1.0.Final]

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

        at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.handleAnnotations(InterceptorAnnotationProcessor.java:107)

        at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.processComponentConfig(InterceptorAnnotationProcessor.java:92)

        at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.deploy(InterceptorAnnotationProcessor.java:77)

        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:159) [wildfly-server-8.1.0.Final.jar:8.1.0.Final]

        ... 5 more

      Caused by: java.lang.NoClassDefFoundError: org/hibernate/HibernateException

        at java.lang.Class.getDeclaredFields0(Native Method) [rt.jar:1.7.0_76]

        at java.lang.Class.privateGetDeclaredFields(Class.java:2499) [rt.jar:1.7.0_76]

        at java.lang.Class.getDeclaredFields(Class.java:1811) [rt.jar:1.7.0_76]

        at org.jboss.as.server.deployment.reflect.ClassReflectionIndex.<init>(ClassReflectionIndex.java:57) [wildfly-server-8.1.0.Final.jar:8.1.0.Final]

        at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:68) [wildfly-server-8.1.0.Final.jar:8.1.0.Final]

        ... 10 more

      Caused by: java.lang.ClassNotFoundException: org.hibernate.HibernateException from [Module "deployment.mwcog.war:main" from Service Module Loader]

        at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.3.Final]

        at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.3.Final]

        at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.3.Final]

        at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.3.Final]

        at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.3.Final]

        ... 15 more

       

      I appreciate any help.

        • 1. Re: Gettting java.lang.ClassNotFoundException: org.hibernate.HibernateException
          smarlow

          Show us the contents of "mwcog.war" ("jar tf mwcog.war").  I am curious if you have a persistence.xml file in "mwcog.war".

          • 2. Re: Gettting java.lang.ClassNotFoundException: org.hibernate.HibernateException
            minoleg

            Thank you, Scott, for your reply.

             

            I do not have persistence.xml, since I am not using JPA but proprietary Hibernate functionality instead and hence hibernate.cfg.xml.


            <hibernate-configuration>

            <session-factory name="mwcog">

              <property name="connection.datasource">java:/MWCOGDS</property>

              <property name="hibernate.current_session_context_class">thread</property>

              <property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>

              <property name="hibernate.show_sql">true</property>

              <mapping resource="bti/tdms/data/Tblsites.hbm.xml"/>

              ...

            </session-factory>

            </hibernate-configuration>

             

            I thought since Hibernate classes are part of the system module they should be available to my app.  Or they are only available to system class loader and not my application?

             

            Thanks,

            Oleg

            • 3. Re: Gettting java.lang.ClassNotFoundException: org.hibernate.HibernateException
              smarlow

              Do you have a MANIFEST.MF?  Some related information is in the documentation at https://docs.jboss.org/author/display/WFLY9/JPA+Reference+Guide#JPAReferenceGuide-NativeHibernateuse, the MANIFEST.MF should contain at least:

              Dependencies: org.hibernate

               

              The "dependencies" specified in MANIFEST.MF, determine which WildFly static modules are added to your application classpath.  For JPA applications, we scan for the persistence.xml and automatically add the Hibernate dependency.

              • 4. Re: Gettting java.lang.ClassNotFoundException: org.hibernate.HibernateException
                minoleg

                Thanks again for your reply.  Unfortunately, it's still did not work for me.  I am getting the following error during the deployment:

                 

                [disconnected /] connect

                [standalone@localhost:9990 /] deploy --force c:\mwcog\mwcog\mwcog.war

                {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:

                " => {"Operation step-2" => {"JBAS014671: Failed services" => {"jboss.deployment

                .unit.\"mwcog.war\".POST_MODULE" => "org.jboss.msc.service.StartException in ser

                vice jboss.deployment.unit.\"mwcog.war\".POST_MODULE: JBAS018733: Failed to proc

                ess phase POST_MODULE of deployment \"mwcog.war\"

                    Caused by: java.lang.RuntimeException: JBAS018757: Error getting reflective

                information for class bti.tdms.ajaxcontroller.AjaxController with ClassLoader Mo

                duleClassLoader for Module \"deployment.mwcog.war:main\" from Service Module Loa

                der

                    Caused by: java.lang.NoClassDefFoundError: org/hibernate/HibernateException

                    Caused by: java.lang.ClassNotFoundException: org.hibernate.HibernateExceptio

                n from [Module \"deployment.mwcog.war:main\" from Service Module Loader]"}}}}

                 

                Let me know if you have an idea what is happening here.

                 

                Thanks,

                Oleg

                • 5. Re: Gettting java.lang.ClassNotFoundException: org.hibernate.HibernateException
                  minoleg

                  Scott, I have found the solution by adding jboss-deployment-structure.xml.

                   

                  • 6. Re: Gettting java.lang.ClassNotFoundException: org.hibernate.HibernateException
                    sanjay05222

                    Oleg , I also have face several issues like this and I afraid to say that I there are two things here in my experience wildfly class loader is and behaves very weird. as per Scott just by defining in the manifest should work for you and there is no need to jboss-deployment-structure.xml . sorry for interrupting this thread in middle. Oleg is that if declaring in the dependency inside the manifest-mf didnt worked then there is issue with the class loader as per the class loading definition it should work if it didnt worked and it only worked with use of jboss-deployment-structure.xml declaration then there is issue.

                    I have wasted several hours working in these dependency issue and I have made my motive to clarify this issue once for all for benefit of the community user. Please let me know if Manifest.mf declaration of dependency also works for you ?

                    • 7. Re: Gettting java.lang.ClassNotFoundException: org.hibernate.HibernateException
                      smarlow

                      Sanjay, did you also get a NoClassDefFoundError exception? 

                       

                      Oleg, what are the contents of your jboss-deployment-structure.xml?

                      • 8. Re: Gettting java.lang.ClassNotFoundException: org.hibernate.HibernateException
                        minoleg

                        Hi guys,

                         

                        Modifying MANIFEST.MF did not work for my, but having jboss-deploment-structure.xml did. And it might be because my application is a web app (war file).  Here is the content:

                         

                        <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">

                            <deployment>

                                <!-- This allows you to define additional dependencies, it is the same as using the Dependencies: manifest attribute -->

                                <dependencies>

                                    <module name="org.hibernate" />

                                </dependencies>

                            </deployment>

                        </jboss-deployment-structure>

                         

                        Regards,

                        Oleg

                        • 9. Re: Gettting java.lang.ClassNotFoundException: org.hibernate.HibernateException
                          smarlow

                          Thanks Oleg.  I'm not sure why there is a difference.  From the Class Loading in WildFly - WildFly 9 - Project Documentation Editor doc, I think that both MANIFEST.MF and jboss-deployment-structure.xml should work.  Have you tried recreating this problem on the latest nightly build