java.lang.NoClassDefFoundError: 无法初始化类 org.apache.axis.utils.XMLUtils

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20854214/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 04:49:02  来源:igfitidea点击:

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

javatomcat

提问by akshay

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.

我收到此错误。如何避免这种异常。请建议我一个解决方案。

采纳答案by Aman Arora

According to Oracle:

根据甲骨文:

NoClassDefFoundErroris 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.

NoClassDefFoundError如果 Java 虚拟机或 ClassLoader 实例尝试加载类的定义(作为正常方法调用的一部分或作为使用 new 表达式创建新实例的一部分)并且找不到类的定义,则抛出.

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

Question comes : How come my code compile?

用简单的语言来说,这意味着“在编译时class存在但在运行时,它无法找到/加载class

问题来了:我的代码如何编译?

Answer maybe because you added jarsusing Eclipse. But Eclipse does not actually move those jarsinto you classpath.It just uses those referenced jarswhile 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 jarsto the classpath.

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

回答可能是因为您jars使用 Eclipse添加。但是 Eclipse 实际上并没有将它们移动jars到您中。classpath它只是使用jars编译时引用的那些。所以你的代码编译得很好。
之后,您将项目移至 tomcat,当它尝试在这些“罐子”中加载某个类时,它无法找到class,因为您从未将它们jars移到类路径中。

解决方案:
将所有内容移动libraries(jars)到项目的/WEB-INF/lib. 现在所有的libraries/jars/WEB-INF/lib都将下classpath

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

你可以阅读更多关于Oracle 的文档这篇文章

回答by Andres

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.

新实例的创建也可能取决于某些错误或不存在的配置。检查您的执行配置文件。

回答by Amila

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

NoClassDefFoundError 意味着在编译时可用的库在运行时不可用。

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

在本例中,它是包含类 org.apache.axis.utils.XMLUtils 的 jar 文件。确保它在您的类路径中可用。

回答by sank

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

NoClassDefFoundError 意味着编译器尝试在编译时加载类,但所需的类在编译时不可用。

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

因此,将所需的 jar 文件添加到您的程序中。你可以添加这个jar文件:axis-1.2.jar