Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: NoClassDefFoundError even though class found in JAR of WAR deployed to WLS server

  1. #1
    Junior Member
    Join Date
    Oct 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default NoClassDefFoundError even though class found in JAR of WAR deployed to WLS server

    I created a WAR file HelloWorld_5.war for a HelloWorld5 project by copying all the jar files needed by the project into HelloWorld5\WEB-INF\lib folder and then deploying HelloWorld5\HelloWorld_5.war to Weblogic 12.11 server.

    cfw-env-7.0.6.jar is one of the jars that is added to HelloWorld5\WEB-INF\lib folder
    Before adding cfw-env-7.0.6.jar to HelloWorld5\WEB-INF\lib folder and creating the WAR file, I was getting the below noclassdeffounderror for package com/csg/cs/core/base/common/util/cfg/ConfigUtil

    This was because this class is defined in cfw-env-7.0.6.jar which was not yet part of the HelloWorld_5.war .
    As you can see in below, output, jar -tvf cfw-env-7.0.6.jar revealed that com.csg.cs.core.base.common.util.cfg.ConfigUtil package was part of cfw-env-7.0.6.jar jar file.

    9220 Thu Apr 04 18:39:26 EDT 2013 com/csg/cs/core/base/common/util/cfg/ConfigUtil.class
    So I copied this jar file cfw-env-7.0.6.ja to HelloWorld5\WEB-INF\lib. After adding cfw-env-7.0.6.jar to HelloWorld5\WEB-INF\lib and re-creating WAR file and redeploying to Weblogic, above ConfigUtil error goes away and I am getting a different noclassdefounderror for com/csg/cs/core/CoreState shown further below.
    I donot understand this because this class is also defined in cfw-env-7.0.6.jar.
    jar -tvf cfw-env-7.0.6.jar output as shown below reveals that along with ConfigUtil.class and a bunch of other classes, com.csg.cs.core.CoreState.class is also part of cfw-env-7.0.6.jar
    2115 Thu Apr 04 18:39:26 EDT 2013 com/csg/cs/core/CoreState.classCan you please explain why I get the java.lang.NoClassDefFoundError: com/csg/cs/core/CoreState error even after including cfw-env-7.0.6.jar in HelloWorld5\WEB-INF\lib and creating a new WAR file with it ?Below are error messages I got before adding cfw-env-7.0.6.jar to the WAR file (which makes sense) and what i got after adding cfw-env-7.0.6.jar to the WAR (which doesnot make sense.Please explain)

    After deploying the HelloWorld_5.war to weblogic server I am running URL and initially get the index.jsp page which in turn calls Servlet HelloWorld5BankController.class. This class internally calls logger.isLoggable method at which point it generates an error related to CoreState in the browser. The call to logger.isLoggable in HelloWorld5BankController.java is given further below


    ERROR before adding cfw-env-7.0.6.jar to the WAR file which makes senseError 500--Internal Server Error

    java.lang.NoClassDefFoundError: com/csg/cs/core/base/common/util/cfg/ConfigUtil
          at com.csg.cs.core.base.logging.LoggerHelper.createLoggerManager(LoggerHelper.java:119)
          at com.csg.cs.core.base.logging.LoggerHelper.getLoggerManager(LoggerHelper.java:111)
          at com.csg.cs.core.base.logging.LoggerHelper.getLogger(LoggerHelper.java:188)
          at com.csgtest.HelloWorld5BankController.(HelloWorld5BankController.java:24)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
          at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
          at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
          at java.lang.Class.newInstance0(Class.java:357)
          at java.lang.Class.newInstance(Class.java:310)
          at weblogic.servlet.internal.WebComponentContributor.getNewInstance(WebComponentContributor.java:236)
          at weblogic.servlet.internal.WebComponentContributor.getNewInstance(WebComponentContributor.java:229)
          at weblogic.servlet.internal.WebComponentContributor.createServletInstance(WebComponentContributor.java:258)
          at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.newServletInstanceIfNecessary(StubSecurityHelper.java:320)
          at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:273)
          at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:250)
          at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
          at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
          at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
          at weblogic.servlet.internal.StubSecurityHelper.initServletInstance(StubSecurityHelper.java:94)
          at weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:82)
          at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:74)
          at weblogic.servlet.internal.StubLifecycleHelper.(StubLifecycleHelper.java:60)
          at weblogic.servlet.internal.StubLifecycleHelper.(StubLifecycleHelper.java:34)
          at weblogic.servlet.internal.ServletStubImpl.initStubLifecycleHelper(ServletStubImpl.java:624)
          at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:565)
          at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:281)
          at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:221)
          at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3284)
          at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3254)
          at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
          at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
          at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
          at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2163)
          at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2089)
          at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2074)
          at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1513)
          at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:254)
          at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
          at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
    Caused by: java.lang.ClassNotFoundException: com.csg.cs.core.base.common.util.cfg.ConfigUtil
          at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:297)
          at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:270)
          at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:64)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
          at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:179)


    ERROR after adding cfw-env-7.0.6.jar to the WAR file and re-deploying which doesnot make sense because I no more get the above ConfigUtil class not found error which means Weblogic is able to find the cfw-env.7.0.6.jar but strangely still cannot find CoreState package


    Error 500--Internal Server Error

    java.lang.NoClassDefFoundError: com/csg/cs/core/CoreState
            at com.csg.cs.core.base.logging.impl.ContextAwareLoggerDelegate.getTraceLevel(ContextAwareLoggerDelegate.java:96)
            at com.csg.cs.core.base.logging.impl.ContextAwareLoggerDelegate.isLoggable(ContextAwareLoggerDelegate.java:82)
            at com.csg.cs.core.base.logging.impl.AbstractLogger.isLoggable(AbstractLogger.java:261)
            at com.csg.cs.core.base.logging.impl.LoggerImpl.isLoggable(LoggerImpl.java:70)
            at com.csgtest.HelloWorld5BankController.process(HelloWorld5BankController.java:53)
            at com.csgtest.HelloWorld5BankController.doGet(HelloWorld5BankController.java:36)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:844)
            at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:242)
            at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:216)
            at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:132)
            at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:338)
            at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:221)
            at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3284)
            at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3254)
            at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
            at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
            at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
            at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2163)
            at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2089)
            at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2074)
            at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1513)
            at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:254)
            at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
            at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)

    As you can see in the stack trace of error above, after Process is called in my Servlet class HelloWorld5BankController, isLoggable function is called.
    Inside my Servlet class HelloWorld5BankController.class the point where isLoggable is called is as follows

    private void process(HttpServletRequest req, HttpServletResponse resp)
    			throws IOException, ServletException {
     
    		if (req.getSession().getAttribute(CS_CUSTOMER) == null) {
    			CSBankData bankData = new CSBankData();
    			Customer customer = (Customer) bankData.getCustomer(ContextHelper
    					.getCoreContext().getPID());
    			req.getSession().setAttribute(CS_CUSTOMER, customer);
    			if (logger.isLoggable(Level.FINEST)) {
    				logger.finest("Customer " + customer);
    			}
     
    		}
    		executeTX(req);
    		String page = (String) req.getParameter("page");
    		[COLOR="#800080"]if (logger.isLoggable(Level.FINEST)) [/COLOR]{
    			logger.finest("Forwarding to page " + page);
    		}
     
    		req.getSession().getServletContext()
    				.getRequestDispatcher("/" + page + ".jsp").forward(req, resp);
    	}


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 697 Times in 679 Posts

    Default Re: NoClassDefFoundError even though class found in JAR of WAR deployed to WLS server

    Welcome to the forum! Thanks for taking the time to learn how to post code correctly. If you haven't already, please read this topic to learn other useful info for new members.

Similar Threads

  1. Replies: 1
    Last Post: August 19th, 2014, 12:12 PM
  2. [SOLVED] Class Not found in jar
    By dicdic in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 14th, 2014, 12:42 AM
  3. [SOLVED] jar file not found
    By user2013 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: June 13th, 2013, 02:12 PM
  4. Spring app deployed in tomcat server going down
    By sumitbhatia in forum Web Frameworks
    Replies: 0
    Last Post: March 23rd, 2012, 02:49 AM
  5. get method names in all the class files in the jar/war/ear
    By purushothaman in forum Java SE APIs
    Replies: 0
    Last Post: March 20th, 2012, 08:45 AM