Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.ArrayIndexOutOfBoundsException while Deploying app in WLS 12

Tags:

java

weblogic

I am getting this error while deploying an app in 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.

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$1 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!

like image 711
Yogesh_D Avatar asked Oct 03 '13 06:10

Yogesh_D


People also ask

How do I get rid of Java Lang ArrayIndexOutOfBoundsException?

In order to avoid the java. lang. ArrayIndexOutOfBoundsException, you should always do the bound check before accessing array element e.g. Always remember that the array index starts at 0 and not 1 and an empty array has no element in it.

What causes Java Lang ArrayIndexOutOfBoundsException?

The ArrayIndexOutOfBoundsException is one of the most common errors in Java. It occurs when a program attempts to access an invalid index in an array i.e. an index that is less than 0, or equal to or greater than the length of the array.

What is a Java ArrayIndexOutOfBoundsException?

ArrayIndexOutOfBoundsException occurs when we access an array, or a Collection, that is backed by an array with an invalid index. This means that the index is either less than zero or greater than or equal to the size of the array.

What is WLS in Java?

Oracle WebLogic Server is a unified and extensible platform for developing, deploying and running enterprise applications, such as Java, for on-premises and in the cloud. WebLogic Server offers a robust, mature, and scalable implementation of Java Enterprise Edition (EE) and Jakarta EE.


2 Answers

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.

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

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.

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.

like image 85
eis Avatar answered Sep 19 '22 21:09

eis


Another problem, that I'm adding for prosperity because it caused me a lot of 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.

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

The solution is to tell WebLogic to use the version of Spring that is bundled with your web application, by adding the weblogic.xml in the WEB-INF directory (src/main/webbapp/WEB-INF if you're using 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.

like image 43
SeverityOne Avatar answered Sep 20 '22 21:09

SeverityOne