问题
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!
回答1:
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.
回答2:
For me, it was about usage of Java 8 stream lambda in a private
method of a class which was a Spring Bean. Weblogic version - 12c , 12.1.3 ) in Eclipse IDE.
I guess there was a problem in bean creation in Spring 3.1 with Java 8.
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());
,
I started receiving this java.lang.ArrayIndexOutOfBoundsException
while deploying to server.
So when I changed code to iterate over Set<String>
and add to Set<Long>
after parsing , error was gone.
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 .
回答3:
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.
来源:https://stackoverflow.com/questions/19152655/java-lang-arrayindexoutofboundsexception-while-deploying-app-in-wls-12