• Post Reply Bookmark Topic Watch Topic
  • New Topic

NoClassDefFoundError even though packages exists in jar file  RSS feed

 
waavman Rao
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.classSo 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.class
Can 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)




ERROR before adding cfw-env-7.0.6.jar to the WAR file which makes sense

Error 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");
if (logger.isLoggable(Level.FINEST)) {
logger.finest("Forwarding to page " + page);
}

req.getSession().getServletContext()
.getRequestDispatcher("/" + page + ".jsp").forward(req, resp);
}





















 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A NoClassDefFound error is slightly different from a ClassNotFound exception; ClassNotFound is where the class mentioned is not in the classpath (which you have apparently solved), but NoClassDefFound means that some dependency of the class you are loading could not be loaded. In this case I would check the documentation of the library you are using and make sure that all needed jar files are in the classpath, not just the one with the class you are calling. In this case, the CoreState class is referencing some class you do not have in your classpath. These can be not trivial to track down, as the JVM does not tell you what class it can't find and the documentation of dependencies is in many cases lacking, but this should at least give you some place to start looking.
 
waavman Rao
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joel,

Thanks for the reply.I issue got resolved.
I dont know if it had something to do with the installation of the WAR file. In order to break down the problem, I tried to do the installation just by deploying the application folder structure from the context path instead of the WAR file. Testing progressively I found that only 3 external jars were needed and a few classes. Previously I had included several jars in the WAR file. So after confirming that the Deployment from the folder was working fine, I created a WAR with the same bare minimum of jar files and class files.
After deploying this WAR file it worked fine. Like you mentioned there was probably some reference to some package inside CoreState which saw multiple jars containing that and so could not resolve or something. Anyway works fine now.

thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!