Create a program that performs SAML authentication using the opensaml library NoClassDefFoundError occurs when deploying to weblogic server after checking operation in Tomcat environment. The java version is 6. The version of opsensaml is 2.6.6.
When I tried google, the same phenomenon was described below.
https://stackoverflow.com/questions/30227152/opensaml-throws-java-lang-noclassdeffounderror-only-on-weblogic
It was written above that if you delete the following library, it will work for the time being, so when I tried the same on this server, it certainly worked. ・ Com.bea.core.bea.opensaml2_1.0.0.0_6-1-0-0 ・ This m. Bea. this. Bea. Pensa ml_1.0.0.0.0_6-1-0-0
On the contrary, when I placed the above library in the Tomcat environment and tried to operate it, the same error as in the weblogic environment occurred.
From the above results, when I investigated the problem line of the library load order, it was described below.
http://otndnld.oracle.co.jp/document/products/wls/docs92/programming/classloading.html#wp1082452
Apparently weblogic takes precedence over the library directory (~ / WEB-INF / lib /) placed in the app. There is a directory of the library to load, and this time it seems that an error occurred because there is no opensaml class called from the application placed here in the above opensaml that exists there.
So, when I checked whether the opensaml library placed here could be prioritized, it was possible by specifying the package name you want to prioritize with the [prefer-application-packages] tag in weblogic.xml, so set the corresponding tag to weblogic.xml. After adding it, the problem was solved (see the document below).
https://docs.oracle.com/cd/E72987_01/wls/WLPRG/classloading.htm https://docs.oracle.com/cd/E28613_01/web.1211/b65890/weblogic_xml.htm
The following is the added content.
<prefer-web-inf-classes>false</prefer-web-inf-classes>
<prefer-application-packages>
<package-name>org.opensaml.*</package-name>
</prefer-application-packages>
When using the prefer-application-packages tag, it seems necessary to specify false in the prefer-web-inf-classes tag. By the way, if you want to give priority to loading all the libraries placed in the application, you should specify true in the prefer-web-inf-classes tag.
http://otndnld.oracle.co.jp/document/products/wls/docs92/webapp/weblogic_xml.html
The full text of the xml is below.
weblogic.xml
<?xml version='1.0' encoding='UTF-8'?>
<weblogic-web-app xmlns="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.3/weblogic-web-app.xsd">
<session-descriptor></session-descriptor>
<jsp-descriptor></jsp-descriptor>
<container-descriptor>
<prefer-web-inf-classes>false</prefer-web-inf-classes>
<prefer-application-packages>
<package-name>org.opensaml.*</package-name>
</prefer-application-packages>
</container-descriptor>
<context-root>/</context-root>
<wl-dispatch-policy>******</wl-dispatch-policy>
</weblogic-web-app>
Maybe the same problem will come up again, so leave it alone.
Recommended Posts