Weblogic .ear 部署 java.lang.ClassNotFoundException

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24742297/
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-14 14:36:58  来源:igfitidea点击:

Weblogic .ear deployment java.lang.ClassNotFoundException

javaweblogic12c

提问by user3791049

When i deploy .ear file on weblogic 12c, it is giving following error.

当我在 weblogic 12c 上部署 .ear 文件时,出现以下错误。

java.lang.ClassNotFoundException: com.abc.util.CustomUtility
    at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:335)
    at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:302)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:180)


<Administration Console encountered the following error: weblogic.application.WrappedDeploymentException: com.abc.util.CustomUtility
    at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:335)
    at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:302)

As soon as I deploy .ear file, it is giving the above error. It's complaining about ClassNotFoundException which is a user-defined class in the project.

我一部署 .ear 文件,就会出现上述错误。它抱怨 ClassNotFoundException 是项目中的用户定义类。

I see all .classes are part of .ear file. Still why this issue comes up ?

我看到所有 .classes 都是 .ear 文件的一部分。还是为什么会出现这个问题?

Please help me on this.

请帮我解决这个问题。

采纳答案by jorgeff

I've seen this problem when I have utility classes defined on several projects. The .class are in the .ear, but the app doesn't find it.

当我在几个项目中定义了实用程序类时,我已经看到了这个问题。.class 在 .ear 中,但应用程序找不到它。

In my case the problem was solved adding the missing class project to the manifest file.

在我的情况下,问题已解决,将缺少的类项目添加到清单文件中。

回答by Lonzak

The accepted answer didn't solve our problem. We solved it by adding the packages (of the missing classes) to the prefer-application-packages section in the weblogic-application.xml

接受的答案并没有解决我们的问题。我们通过将包(缺少的类)添加到weblogic-application.xml

    <!-- to load classes of the packages from application context first and not from server context.  -->
    <prefer-application-packages>
        <package-name>antlr.*</package-name>
        <package-name>org.apache.*</package-name>
        <package-name>org.hibernate.*</package-name>
        <package-name>org.springframework.*</package-name>
        <package-name>org.aopalliance.*</package-name>
        <package-name>org.objectweb.*</package-name>
        <package-name>net.sf.cglib.*</package-name>
        ...
    </prefer-application-packages>
</weblogic-application>