5
java.lang.NoClassDefFoundError: Could not initialize class org.apache.axis.utils.XMLUtils

I am getting this error. How to avoid this exception. Please suggest me a solution.

akshay
  • 115
  • 1
  • 3
  • 9

4 Answers4

3

According to Oracle:

NoClassDefFoundError is 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.

In simple language, it means "At compile-time class was there but at run-time, it failed to find/load the class

Question comes : How come my code compile?

Answer maybe because you added jars using Eclipse. But Eclipse does not actually move those jars into you classpath.It just uses those referenced jars while compilation. So your code compiles fine.
After, you move your project to tomcat, when it tries to load some class inside those 'jars', it fails to find the class,because you never moved those jars to the classpath.

Solution:
Move all the libraries(jars) into your project's /WEB-INF/lib. Now all the libraries/jars under /WEB-INF/lib will come under classpath.

You can read more on Oracle's Docs & this article

Aman Arora
  • 1,232
  • 1
  • 10
  • 26
  • thank you for your reply..but i have all the jars under /WEB-INF/lib folder, but still i am getting this exception..when i am running the project from eclipse it's working fine, but after deploying it on tomcat of Agile PLM its giving me this exception. – akshay Jan 01 '14 at 16:41
  • try to search for this class in the jars under `lib`. – Aman Arora Jan 02 '14 at 04:18
  • Hi I have the class in the WEB-INF\lib\myjar. Still the same error. – sree Nov 28 '14 at 10:28
0

This exception probably means that an instance has to be created by reflection, but the corresponding class is not in the execution classpath. Check your execution classpath.

It is also possible that the creation of the new instance depends on some configuration that is wrong or absent. Check your execution configuration files.

Andres
  • 10,561
  • 4
  • 45
  • 63
0

NoClassDefFoundError means, a library that was available at the compile time, is not available at the runtime.

In this case it's the jar file containing the class org.apache.axis.utils.XMLUtils. Make sure it is available in your classpath.

Amila
  • 5,195
  • 1
  • 27
  • 46
0

NoClassDefFoundError means the compiler trys to load the class at compile time but the required class is not available at compile time.

So add the required jar file to your program. Can you add this jar file: axis-1.2.jar

sank
  • 51
  • 1
  • 4