java.lang.ArrayIndexOutOfBoundsException while Deploying app in WLS 12

孤街浪徒 提交于 2019-12-01 05:43:12

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.

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 .

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!