Wired Classloader or ClassPath issue


(lttle Lingzi) #1

This issue has been puzzled my several days:

Our system is WebSphere Liberty and Gradle 2.14+.

Putting the background: We have an EAR which has three component 1) external utility Jar ( having a method called decodingTheEncodedString(String), this method throws errors - see later) 2) internal utility Jar ( having a TO called DataTO for example) 3) An War which has a class called Processor which has a method called processData(). In this method, 1)'s decodingTheEncodedString(String) will be invoked and then 2)'s DataTO is constructed, but the error says that DataTO is not found. The errors are:

Caused by: java.lang.ClassNotFoundException: 2)'sDataTO
at com.ibm.ws.classloading.internal.AppClassLoader.findClassCommonLibraryClassLoaders(AppClassLoader.java:499)
at com.ibm.ws.classloading.internal.AppClassLoader.findClass(AppClassLoader.java:282)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.ibm.ws.classloading.internal.AppClassLoader.findOrDelegateLoadClass(AppClassLoader.java:477)
at com.ibm.ws.classloading.internal.AppClassLoader.loadClass(AppClassLoader.java:449)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at java.io.ObjectInputStream.resolveClass(Unknown Source)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at
1)'s decodingTheEncodedString(String)1)'sMehod

My theory is that the ClassLoder for 1) can’t see the classLoader for 2), and thus I just moved all the code from 1) into the 3) Processor class and thus there is no reference from 3) to 1), and then all is working. So this is my workaround, but I still need to make the code from 1) to its original place (I=i.e. 1)as it can be reused all around.

Then what is the solution? How to control the classLoader’s visibility in Gradle? Thanks a lot.