简体   繁体   中英

Weblogic 12.2.1 and OpenSaml2 conflict

I have a spring boot web service application that uses opensaml dependency (an old version, 2.2.3). When I deploy to Weblogic I get:

Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Logger
        at org.opensaml.xml.XMLConfigurator.<clinit>(XMLConfigurator.java:60) ~[com.oracle.weblogic.security.opensaml2.jar:na]

The workaround I did is the same as this user: https://stackoverflow.com/a/20913280/2968729 . I renamed com.oracle.weblogic.security.opensaml2.jar so it would be ignored.

As described on the error, weblogic has his own opensaml2.jar that uses log4j which isn't present on my application classpath and that's why fails.

So the point is: I don't want to add log4j neither to use com.oracle.weblogic.security.opensaml2.jar but my opensaml from my classpath instead. What is the proper way to achieve this?

weblogic.xml:

<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app
        xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app
        http://xmlns.oracle.com/weblogic/weblogic-web-app/1.9/weblogic-web-app.xsd">
    <wls:container-descriptor>
        <wls:prefer-application-packages>
            <wls:package-name>org.slf4j</wls:package-name>
            <wls:package-name>ch.qos.logback.*</wls:package-name>
            <wls:package-name>org.opensaml</wls:package-name>
            <wls:package-name>org.apache.cxf</wls:package-name>
        </wls:prefer-application-packages>
    </wls:container-descriptor>
</wls:weblogic-web-app>

I already specify to use opensaml of my classpath so I dont understand what is happening.

So stupid: weblogic.xml was on the wrong place, so it was being ignored. I had it on src/main/resource folder.

It must be on src/main/webapp/WEB-INF/weblogic.xml

Notice there is webapp folder!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM