[JAVA] [Opens aml] NoClassDefFoundError occurs when migrating from Tomcat to weblogic

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

[Opens aml] NoClassDefFoundError occurs when migrating from Tomcat to weblogic
Changes when migrating from Spring Boot 1.5 to Spring Boot 2.0
Changes when migrating from Spring Boot 2.0 to Spring Boot 2.2
Precautions when migrating from VB6.0 to JAVA
Migrating from Eclipse server function (Tomcat) to Embed Tomcat
What to do if ClassNotFoundException occurs when starting Tomcat
Migrating from vargrant to docker
How to write and notes when migrating from VB to JAVA
Notes on character encoding when migrating from windows to Mac
What I thought about when I started migrating from Java to Kotlin
Notes on migrating from CircleCI 1.0 to 2.0
What to do when javax.batch.operations.JobStartException occurs
What to do when a javax.el.PropertyNotWritableException occurs
Troubleshooting when raising Mastodon from v3.0.x to v3.1.x
Summary of points I was worried about when migrating from java to kotlin
NoClassDefFoundError occurred when trying to call an Android function from Unity via jar