oracle 如何解决 NoClassDefFoundError?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11020569/
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
How can i solve a NoClassDefFoundError?
提问by Alexandros
I have installed Oracle Weblogic 11g on Oracle Linux and I tried to complete one of Oracle's ADF tutorials using jdeveloper 11g. When I run my project it compiles successfully with no errors. It starts deploying the application to the weblogic server and my default internet browser opens. But then an Error "500 Internal server error" appears.
我已在 Oracle Linux 上安装了 Oracle Weblogic 11g,并尝试使用 jdeveloper 11g 完成 Oracle 的 ADF 教程之一。当我运行我的项目时,它编译成功,没有错误。它开始将应用程序部署到 weblogic 服务器并打开我的默认 Internet 浏览器。但随后出现错误“500 内部服务器错误”。
I'm getting the following error:
我收到以下错误:
java.lang.NoClassDefFoundError: Could not initialize class org.apache.myfaces.trinidadinternal.convert.ColorConverter at....
java.lang.NoClassDefFoundError: Could not initialize class org.apache.myfaces.trinidadinternal.convert.ColorConverter at....
I researched the internet for this problem and I also asked around and the common answer was that there is a problem with the classpath. Probably the libraries that are used in jdeveloper are not the same in weblogic then the project gets deployed.
我在互联网上研究了这个问题,我也四处询问,普遍的答案是类路径有问题。可能 jdeveloper 中使用的库在 weblogic 中不一样,然后项目被部署。
Can anyone tell if definitely the problem is the classpath?? And how can I setup jdeveloper to deploy the same classpath it used to the weblogic server?
谁能确定问题是否出在类路径上?以及如何设置 jdeveloper 以部署它用于 weblogic 服务器的相同类路径?
回答by JoseK
java.lang.NoClassDefFoundError
means the runtimeversion of the class in the classpath is not the same as that at compiletime.
java.lang.NoClassDefFoundError
表示类路径中类的运行时版本与编译时不同。
Your problem could be multiple versions of the class being found when the server is deploying. I notice the class org.apache.myfaces.trinidadinternal.convert.ColorConverter
is found in trinidad-impl.jar
您的问题可能是在部署服务器时发现类的多个版本。我注意到这个类org.apache.myfaces.trinidadinternal.convert.ColorConverter
是在trinidad-impl.jar
Can you search for how many such jars are found in the run time server environment plus your own webapp libraries?
您能否搜索在运行时服务器环境以及您自己的 webapp 库中找到多少这样的 jar?
On windows, the Jdev inbuilt server runs in this folder
在 Windows 上,Jdev 内置服务器在此文件夹中运行
C:\Users\<...>\AppData\Roaming\JDeveloper\system11.1.1.4.37.59.23 or something similar
C:\Users\<...>\AppData\Roaming\JDeveloper\system11.1.1.4.37.59.23 或类似的东西
you need this in your webapp/WEB-INF/lib and not in the other areas.
你需要在你的 webapp/WEB-INF/lib 中而不是在其他区域中。
On my local I find the Jar under C:\Users\<...>\AppData\Roaming\JDeveloper\system11.1.1.4.37.59.23\o.j2ee.wlLibs\jsp\Trinidad-Components1.2.war
在我的本地,我在 C:\Users\<...>\AppData\Roaming\JDeveloper\system11.1.1.4.37.59.23\o.j2ee.wlLibs\jsp\Trinidad-Components1.2.war 下找到了 Jar
I think you could use the weblogic.xml setting to force the WEB-INF/lib class to get loaded in preference to that in server/lib with
我认为您可以使用 weblogic.xml 设置来强制 WEB-INF/lib 类优先加载到 server/lib 中
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
回答by Triton Man
This happens when you try to load a class that is trying to load another class which is not on the classpath. Find out which classes are needed by ColorConverter and make sure you have them in your classpath.
当您尝试加载一个试图加载另一个不在类路径上的类时,就会发生这种情况。找出 ColorConverter 需要哪些类,并确保您的类路径中有它们。
回答by Michael Willer
First of all: What are you deploying to the server? An ADF jar or a WAR file. In your case - given that you don't have any dependent jars installed on the application server. You should deploy a WAR file.
首先:你在服务器上部署什么?ADF jar 或 WAR 文件。在您的情况下 - 假设您没有在应用程序服务器上安装任何依赖的 jar。您应该部署一个 WAR 文件。
On your view project - right click and select Project Properties. Then go to Deployment and edit the deployment profile (if none are there create one). Make sure that the checkbox "Include Libraries from other projects" is checked. (IT's in the Library Dependencies tab).
在您的视图项目上 - 右键单击并选择项目属性。然后转到部署并编辑部署配置文件(如果没有,请创建一个)。确保选中“包括来自其他项目的库”复选框。(它在库依赖项选项卡中)。
Also: you might find some useful information in here.
另外:您可能会在此处找到一些有用的信息。
Hope this helps. Michael
希望这可以帮助。迈克尔
回答by amicngh
Using StackTrace
you can find out classes
those are missing .I think you are missing some jar and that should be in your classpath.
使用StackTrace
你可以找出classes
那些丢失的东西。我认为你丢失了一些 jar,它应该在你的类路径中。