在 WLS 12 中部署应用程序时出现 java.lang.ArrayIndexOutOfBoundsException

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

java.lang.ArrayIndexOutOfBoundsException while Deploying app in WLS 12

javaweblogic

提问by Yogesh_D

I am getting this error while deploying an app in Weblogic.

在 Weblogic 中部署应用程序时出现此错误。

   <Oct 3, 2013 12:18:00 PM IST> <Error> <Deployer> <BEA-149205> <Failed to initialize the application "MyApp" due to error java.lang.ArrayIndexOutOfBoundsException: 4818
8
java.lang.ArrayIndexOutOfBoundsException: 48188
        at com.bea.objectweb.asm.ClassReader.readClass(Unknown Source)
        at com.bea.objectweb.asm.ClassReader.accept(Unknown Source)
        at com.bea.objectweb.asm.ClassReader.accept(Unknown Source)
        at weblogic.application.utils.annotation.ClassInfoImpl.<init>(ClassInfoImpl.java:45)
        at weblogic.application.utils.annotation.ClassfinderClassInfos.polulateOneClassInfo(ClassfinderClassInfos.java:145)
        Truncated. see log file for complete stacktrace
Caused By: java.lang.ArrayIndexOutOfBoundsException: 48188
        at com.bea.objectweb.asm.ClassReader.readClass(Unknown Source)
        at com.bea.objectweb.asm.ClassReader.accept(Unknown Source)
        at com.bea.objectweb.asm.ClassReader.accept(Unknown Source)
        at weblogic.application.utils.annotation.ClassInfoImpl.<init>(ClassInfoImpl.java:45)
        at weblogic.application.utils.annotation.ClassfinderClassInfos.polulateOneClassInfo(ClassfinderClassInfos.java:145)
        Truncated. see log file for complete stacktrace
>

I understand that this is because of an class not getting loaded correctly, however how do i find it? I am using Hotspot 1.7, and on using -verbose:class I am not able to figure out the incorrectly loaded class.

我知道这是因为类没有正确加载,但是我如何找到它?我正在使用 Hotspot 1.7,在使用 -verbose:class 时,我无法找出错误加载的类。

Here is a listing from having verbose class loading enabled.

这是启用详细类加载的列表。

[Loaded com.bea.objectweb.asm.FieldVisitor from file:/C:/Oracle/Middleware/modules/com.bea.core.repackaged.asm_1.2.0.0_3-2-0.jar]
[Loaded com.bea.objectweb.asm.MethodVisitor from file:/C:/Oracle/Middleware/modules/com.bea.core.repackaged.asm_1.2.0.0_3-2-0.jar]
[Loaded com.bea.objectweb.asm.AnnotationVisitor from file:/C:/Oracle/Middleware/modules/com.bea.core.repackaged.asm_1.2.0.0_3-2-0.jar]
[Loaded com.bea.objectweb.asm.commons.EmptyVisitor from file:/C:/Oracle/Middleware/modules/com.bea.core.repackaged.asm.commons_1.2.0.0_3-2-0.jar]
[Loaded com.bea.objectweb.asm.ClassReader from file:/C:/Oracle/Middleware/modules/com.bea.core.repackaged.asm_1.2.0.0_3-2-0.jar]
[Loaded com.bea.objectweb.asm.Attribute from file:/C:/Oracle/Middleware/modules/com.bea.core.repackaged.asm_1.2.0.0_3-2-0.jar]
[Loaded com.bea.objectweb.asm.MethodWriter from file:/C:/Oracle/Middleware/modules/com.bea.core.repackaged.asm_1.2.0.0_3-2-0.jar]
[Loaded weblogic.servlet.internal.WebAppInternalModuleExtension$PersistenceExtension from file:/C:/Oracle/Middleware/wlserver_12.1/server/lib/weblogic.jar]
[Loaded weblogic.servlet.internal.WebAppInternalModuleExtension$SpringInstrumentationExtension from file:/C:/Oracle/Middleware/wlserver_12.1/server/lib/weblogic.jar]
[Loaded weblogic.cacheprovider.coherence.CoherenceClusterContainer from file:/C:/Oracle/Middleware/wlserver_12.1/server/lib/weblogic.jar]
[Loaded weblogic.servlet.internal.WebAppInternalModuleExtension$CoherenceCacheExtension from file:/C:/Oracle/Middleware/wlserver_12.1/server/lib/weblogic.jar]
[Loaded weblogic.utils.enumerations.FileEnumeration from file:/C:/Oracle/Middleware/modules/com.bea.core.utils_2.0.0.0.jar]
[Loaded weblogic.utils.classloaders.DirectoryClassFinder from file:/C:/Oracle/Middleware/modules/com.bea.core.utils.classloaders_3.0.0.0.jar]
[Loaded weblogic.utils.enumerations.EmptyFileContainerException from file:/C:/Oracle/Middleware/modules/com.bea.core.utils_2.0.0.0.jar]
[Loaded weblogic.utils.enumerations.FileEnumeration$NullDirectoryListException from file:/C:/Oracle/Middleware/modules/com.bea.core.utils_2.0.0.0.jar]
[Loaded weblogic.utils.enumerations.FileContainer from file:/C:/Oracle/Middleware/modules/com.bea.core.utils_2.0.0.0.jar]
[Loaded weblogic.utils.enumerations.LIFO_FileContainer from file:/C:/Oracle/Middleware/modules/com.bea.core.utils_2.0.0.0.jar]
[Loaded com.bea.objectweb.asm.Type from file:/C:/Oracle/Middleware/modules/com.bea.core.repackaged.asm_1.2.0.0_3-2-0.jar]
[Loaded weblogic.application.internal.flow.ModuleStateDriver$DestroyStateChange from file:/C:/Oracle/Middleware/wlserver_12.1/server/lib/weblogic.jar]
[Loaded weblogic.application.utils.ExceptionUtils from file:/C:/Oracle/Middleware/wlserver_12.1/server/lib/weblogic.jar]
[Loaded javax.management.RuntimeErrorException from C:\Java\JDK\JDK17~1.0_1\jre\lib\rt.jar]
[Loaded com.bea.logging.ThrowableWrapper from file:/C:/Oracle/Middleware/modules/com.bea.core.logging_2.0.0.0.jar]
<Oct 3, 2013 11:51:20 AM IST> <Error> <Deployer> <BEA-149205> <Failed to initialize the application "MyApp" due to error java.lang.ArrayIndexOutOfBoundsException: 48188
java.lang.ArrayIndexOutOfBoundsException: 48188
    at com.bea.objectweb.asm.ClassReader.readClass(Unknown Source)
    at com.bea.objectweb.asm.ClassReader.accept(Unknown Source)
    at com.bea.objectweb.asm.ClassReader.accept(Unknown Source)
    at weblogic.application.utils.annotation.ClassInfoImpl.<init>(ClassInfoImpl.java:45)
    at weblogic.application.utils.annotation.ClassfinderClassInfos.polulateOneClassInfo(ClassfinderClassInfos.java:145)
    Truncated. see log file for complete stacktrace
Caused By: java.lang.ArrayIndexOutOfBoundsException: 48188
    at com.bea.objectweb.asm.ClassReader.readClass(Unknown Source)
    at com.bea.objectweb.asm.ClassReader.accept(Unknown Source)
    at com.bea.objectweb.asm.ClassReader.accept(Unknown Source)
    at weblogic.application.utils.annotation.ClassInfoImpl.<init>(ClassInfoImpl.java:45)
    at weblogic.application.utils.annotation.ClassfinderClassInfos.polulateOneClassInfo(ClassfinderClassInfos.java:145)
    Truncated. see log file for complete stacktrace

Any Hints as to how to proceed furthur?

关于如何继续进行的任何提示?

Thanks!

谢谢!

采纳答案by eis

Basically, it's a bad class file inside your deployment. Some libs have those.

基本上,它是部署中的错误类文件。一些库有那些。

What's wrong there is that weblogic 12c is not catching the exception and logging the culprit so one could find out which one it is. I would raise this issue with Oracle so they would do that.

有什么问题是 weblogic 12c 没有捕获异常并记录罪魁祸首,以便人们可以找出它是哪一个。我会向 Oracle 提出这个问题,以便他们这样做。

See similar issue in Geronimowhere they changed the message to be warn and not preventing deployment.

请参阅Geronimo中的类似问题,他们将消息更改为警告而不是阻止部署。

A hint as to which file might be problematic is that in 12c they are loading resource classes as well which they did not do in previous versions, so if the app works in a previous version, it might be due to that.

关于哪个文件可能有问题的一个提示是,在 12c 中,它们也在加载资源类,而它们在以前的版本中没有这样做,因此如果应用程序在以前的版本中工作,则可能是由于这个原因。

As to how to find out which class it is, you could hook up debugging to your weblogic instance and add an exception breakpoint on java.lang.ArrayIndexOutOfBoundsException, then try to examine the context to find out the parameters.

至于如何找出它是哪个类,您可以将调试连接到您的weblogic实例并在java.lang.ArrayIndexOutOfBoundsException上添加异常断点,然后尝试检查上下文以找出参数。

回答by Sabir Khan

For me, it was about usage of Java 8 stream lambda in a privatemethod of a class which was a Spring Bean. Weblogic version - 12c , 12.1.3 ) in Eclipse IDE.

对我来说,这是关于在privateSpring Bean 类的方法中使用 Java 8 流 lambda 。Eclipse IDE 中的 Weblogic 版本 - 12c , 12.1.3 )。

I guess there was a problem in bean creation in Spring 3.1 with Java 8.

我想在 Spring 3.1 中使用 Java 8 创建 bean 时存在问题。

I had a Set<String>and I was required to convert it to Set<Long>and for that purpose when I used expression like , strSet.stream().map(s -> Long.parseLong(s)).collect(Collectors.toSet());,

我有一个Set<String>和我需要将其转换为Set<Long>,并为此目的,当我用表情像,strSet.stream().map(s -> Long.parseLong(s)).collect(Collectors.toSet());

I started receiving this java.lang.ArrayIndexOutOfBoundsExceptionwhile deploying to server.

java.lang.ArrayIndexOutOfBoundsException在部署到服务器时开始收到这个。

So when I changed code to iterate over Set<String>and add to Set<Long>after parsing , error was gone.

因此,当我更改代码以迭代Set<String>Set<Long>在解析后添加时,错误消失了。

This was a legacy Spring MVC 3.1 App, Weblogic Server starts with JDK 8 , Eclipse shows no errors whatsoever & Eclipse Project Facet was set to Java 1.8 .

这是一个遗留的 Spring MVC 3.1 应用程序,Weblogic Server 从 JDK 8 开始,Eclipse 没有显示任何错误,Eclipse Project Facet 设置为 Java 1.8 。

回答by SeverityOne

Another problem, that I'm adding for prosperity because it caused me a lotof headaches, is the Spring version bundled with WebLogic 12c. WebLogic 12c comes bundled with Spring 3.x, and that doesn't understand Java 8 class files with lambda expressions.

另一个问题,我为了繁荣而添加,因为它让我头疼,是与 WebLogic 12c 捆绑在一起的 Spring 版本。WebLogic 12c 与 Spring 3.x 捆绑在一起,它不理解带有 lambda 表达式的 Java 8 类文件。

A complicating factor was that it worked fine on a local WebLogic instance on my development machine, but not on the Oracle Cloud instance.

一个复杂的因素是它在我的开发机器上的本地 WebLogic 实例上运行良好,但在 Oracle Cloud 实例上运行不正常。

The solution is to tell WebLogic to use the version of Spring that is bundled with your web application, by adding the weblogic.xmlin the WEB-INFdirectory (src/main/webbapp/WEB-INFif you're using Maven).

解决方案是通过weblogic.xmlWEB-INF目录中添加 来告诉 WebLogic 使用与您的 Web 应用程序捆绑在一起的 Spring 版本(src/main/webbapp/WEB-INF如果您使用的是 Maven)。

<?xml version="1.0" encoding="UTF-8" ?>
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app">

    <container-descriptor>
        <prefer-application-packages>
            <package-name>org.springframework</package-name>
            <!--
                Add other packages that you may want to use
                over the ones bundled with WebLogic.
            -->
        </prefer-application-packages>
    </container-descriptor>

</weblogic-web-app>

And that solved the problem for me.

这为我解决了这个问题。