1 Reply Latest reply: Mar 19, 2013 8:43 PM by pastore23 RSS

    Web Service java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration

    pastore23
      I have built a EAR file (using ANT build.xml from eclipse) and deploy it to WebLogic server, when I test the web service with a Test Client, I will receive the exception:

      java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration


      Anything wrong with my build.xml file below? Why I get this exception?

      <?xml version="1.0" encoding="UTF-8"?>
      
      <project name="MyWebServices" default="all">   
      
           <!-- set global properties for this build -->    
           <property name="wls.username" value="weblogic" />    
           <property name="wls.password" value="abcd1234" />    
           <property name="wls.hostname" value="localhost" />    
           <property name="wls.port" value="7001" />    
           <property name="wls.server.name" value="AdminServer" />    
           <property name="ear.deployed.name" value="MyWebServicesEar" />
           <property name="example-output" value="output" />    
           <property name="ear-dir" value="${example-output}/MyWebServicesEar" />    
           <property name="clientclass-dir" value="${example-output}/clientclasses" />    
      
           <path id="client.class.path">        
                <pathelement path="${clientclass-dir}" />        
                <pathelement path="${java.class.path}" />    
           </path>
           
           <taskdef name="jwsc" classname="weblogic.wsee.tools.anttasks.JwscTask" />    
           <taskdef name="clientgen" classname="weblogic.wsee.tools.anttasks.ClientGenTask" />    
           <taskdef name="wldeploy" classname="weblogic.ant.taskdefs.management.WLDeploy" /> 
      
      
           <target name="build-service">        
                <jwsc srcdir="src" destdir="${ear-dir}">
                     <classpath>       
                          <pathelement path="${java.class.path}" /> 
                          <pathelement path="WebContent/WEB-INF/lib"/>
                     </classpath>
                     
                     <module contextPath="MyWebServices" name="MyWebServicesModule">
                          <jws file="/hk/com/my/webservices/servicefacade/CustomerWS.java" type="JAXWS" />                  
                          <jws file="/hk/com/my/webservices/servicefacade/LoginWS.java" type="JAXWS" />               
                          <jws file="/hk/com/my/webservices/servicefacade/PaymentWS.java" type="JAXWS" />
                          <!-- <jws file="/hk/com/my/webservices/servicefacade/RedemptionWS.java" type="JAXWS" /> -->
                     </module>
                </jwsc>
           </target>    
      
           <target name="deploy">
                <wldeploy action="deploy" name="${ear.deployed.name}" source="${ear-dir}" user="${wls.username}" password="${wls.password}" verbose="true" adminurl="t3://${wls.hostname}:${wls.port}" targets="${wls.server.name}" />    
           </target>    
      
           <target name="undeploy">        
                <wldeploy action="undeploy" name="${ear.deployed.name}" failonerror="false" user="${wls.username}" password="${wls.password}" verbose="true" adminurl="t3://${wls.hostname}:${wls.port}" targets="${wls.server.name}" />    
           </target>         
      
           
           <target name="all" depends="clean,build-service,deploy" />
           <target name="clean" depends="undeploy">        
                <delete dir="${example-output}" />    
           </target>  
           
           <target name="run">        
                <java classname="hk.com.my.webservices.servicefacade.client.Main" fork="true" failonerror="true">
                     <classpath refid="client.class.path" />                           
                     <arg line="http://${wls.hostname}:${wls.port}/MyServices" />
                </java>    
           </target>
      
      </project>
        • 1. Re: Web Service java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
          pastore23
          The problem was because I did not include my web-inf into the ear in my build.xml, i added it using the zipfileset tag and it worked like a charm:


          <target name="build-service">          
                    <jwsc srcdir="src" destdir="${ear-dir}" debug="on">
                         
                         <!-- "contextPath" is like a folder to contain the Web Services, "name" is the name of the WAR file -->
                         <module contextPath="MyWebServices" name="MyWebServicesModule">
                              
                              <jws file="/my/webservices/servicefacade/CustomerWS.java" type="JAXWS" />          
                              <jws file="/my/webservices/servicefacade/LoginWS.java" type="JAXWS" />                                                                 
                              <!-- include and copy the required files to the ear directory -->
                              <zipfileset dir="WebContent/WEB-INF/lib" prefix="WEB-INF/lib">
                                   <include name="*.jar"/>
                              </zipfileset>                              
                         </module>
                    </jwsc>
          </target>