Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 405 Vote(s) - 3.53 Average
  • 1
  • 2
  • 3
  • 4
  • 5
"NoClassDefFoundError: Could not initialize class" error

#1
When I run my project, I get numerous outputs of this error:

<pre>
Sep 9, 2009 8:22:23 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet Jersey threw exception
java.lang.NoClassDefFoundError: Could not initialize class SpringFactory
at com.point2.prospect.persistence.hibernate.HibernateTransactionInterceptor.doFilter(HibernateTrans
actionInterceptor.java:17)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.point2.prospect.restapi.ServerErrorInterceptor.doFilter(ServerErrorInterceptor.java:27)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
</pre>

I notice that this problem has a pattern of being asked all over the web, but with no real answers. What is a general cause for this kind of error?
Reply

#2
You're missing the necessary class definition; typically caused by required JAR not being in classpath.

From <a href="http://java.sun.com/javase/6/docs/api/java/lang/NoClassDefFoundError.html">J2SE API</a>:

> public class NoClassDefFoundError
> extends LinkageError
>
> Thrown if the Java Virtual Machine or
> a ClassLoader instance tries to load
> in the definition of a class (as part
> of a normal method call or as part of
> creating a new instance using the new
> expression) and no definition of the
> class could be found.
>
> The searched-for class definition
> existed when the currently executing
> class was compiled, but the definition
> can no longer be found.

Reply

#3
I had faced the same issue, because the jar library was copied by other Linux user(root), and the logged in user(process) did not have sufficient privilege to read the jar file content.
Reply

#4
NoClassDefFound error is a nebulous error and is often hiding a more serious issue. It is _not_ the same as ClassNotFoundException (which is thrown when the class is just plain not there).

NoClassDefFound _may_ indicate the class is not there, as the javadocs indicate, but it is typically thrown when, after the classloader has loaded the bytes for the class and calls "defineClass" on them. Also carefully check your full stack trace for other clues or possible "cause" Exceptions (though your particular backtrace shows none).

The first place to look when you get a NoClassDefFoundError is in the static bits of your class i.e. any initialization that takes place during the defining of the class. If this fails it will throw a NoClassDefFoundError - it's supposed to throw an ExceptionInInitializerError and indicate the details of the problem but in my experience, these are rare. It will only do the ExceptionInInitializerError the first time it tries to define the class, after that it will just throw NoClassDefFound. So look at earlier logs.

I would thus suggest looking at the code in that HibernateTransactionInterceptor line and seeing what it is requiring. It seems that it is unable to define the class SpringFactory. So maybe check the initialization code in that class, that might help.
If you can debug it, stop it at the last line above (17) and debug into so you can try find the exact line that is causing the exception. Also check higher up in the log, if you very lucky there might be an ExceptionInInitializerError.
Reply

#5
Realised that I was using OpenJDK when I saw this error. Fixed it once I installed the Oracle JDK instead.
Reply

#6
I had this:

class Util {
static boolean isNeverAsync = System.getenv().get("asyncc_exclude_redundancy").equals("yes");
}


you can probably see the problem, the env var might return null instead of string.
So just to test my theory, I changed it to:

class Util {
static boolean isNeverAsync = false;
}

and the problem went away. Too bad that Java can't give you the exact stack trace of the error though, kinda weird.

Reply

#7
I recently ran into this error on Windows 10. It turned out that windows was looking for .dll files necessary for my project and couldn't find them because it looks for them in the system path, PATH, rather than the CLASSPATH or -Djava.library.path
Reply

#8
I had this same Error and it turns out, I had a method that was being called over and over, like an infinite loop, except it wasn't in an actual loop.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through