Fast Classpath Scanner on Websphere Liberty

11 views
Skip to first unread message

Raimond Kempees

unread,
Jun 22, 2017, 7:19:17 AM6/22/17
to FastClasspathScanner-Users
Hi,

I use the fast-classpath-scanner in WebSphere to load some annotated classes based on package name:

final FastClasspathScanner scanner = new FastClasspathScanner("x.y.z");
final ScanResult scanResult = scanner.scan();

for (Map.Entry<String, ClassInfo> classInfoEntry : scanResult.getClassNameToClassInfo().entrySet()) {
   
LOG.info(classInfoEntry.getValue().getClassName());
   processClass
(classInfoEntry.getValue());
}

While this works fine in other application servers, it doesnt work on WAS Liberty - in the log I do not see the classes loaded of jar files inside the war, but only the ibm classes.

What do I have to do / set to get hold of jar files / classes inside the war file? I looked at the https://github.com/lukehutch/fast-classpath-scanner/wiki/4.-Working-with-nonstandard-ClassLoaders page and I couldn't determine whether I need to configure a custome ClassLoaderHandler.

Could someone help me out?

Thanks!

Luke Hutchison

unread,
Jun 22, 2017, 12:09:58 PM6/22/17
to Raimond Kempees, FastClasspathScanner-Users
Hi Raimond,

This probably just means that Websphere Liberty has its own custom classloader that is not yet supported. If you could please create a minimal testcase project that demonstrates the problem, so that I can reproduce, I'll take a shot at figuring out how to support this classloader.

Thanks,
Luke


--
You received this message because you are subscribed to the Google Groups "FastClasspathScanner-Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fastclasspathscanner-users+unsub...@googlegroups.com.
To post to this group, send email to fastclasspathscanner-users@googlegroups.com.
Visit this group at https://groups.google.com/group/fastclasspathscanner-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/fastclasspathscanner-users/32ec8862-c1a2-4e51-bd1c-fbd0c844eca8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raimond Kempees

unread,
Jun 24, 2017, 3:20:35 AM6/24/17
to Luke Hutchison, FastClasspathScanner-Users
Hi Luke,

I managed to solve this by writing a WebsphereLibertyClassLoaderHandler. After some debugging, I found that WAS WLP uses two classloaders:

com.ibm.ws.classloading.internal.AppClassLoader
com.ibm.ws.classloading.internal.ThreadContextLoader (from the top of my head)

In the AppClassLoader WAS stores path references totally different than normal, so there's quite some reflection needed to get the proper paths. 

The class file is attached. Happy to donate to you if you think it's the right way to go. If not - I am eager to learn how it should be done. :)

Many thanks!

Raimond

On Thu, Jun 22, 2017 at 6:09 PM, Luke Hutchison <luke....@gmail.com> wrote:
Hi Raimond,

This probably just means that Websphere Liberty has its own custom classloader that is not yet supported. If you could please create a minimal testcase project that demonstrates the problem, so that I can reproduce, I'll take a shot at figuring out how to support this classloader.

Thanks,
Luke

On Thu, Jun 22, 2017 at 4:19 AM, Raimond Kempees <kem...@gmail.com> wrote:
Hi,

I use the fast-classpath-scanner in WebSphere to load some annotated classes based on package name:

final FastClasspathScanner scanner = new FastClasspathScanner("x.y.z");
final ScanResult scanResult = scanner.scan();

for (Map.Entry<String, ClassInfo> classInfoEntry : scanResult.getClassNameToClassInfo().entrySet()) {
   
LOG.info(classInfoEntry.getValue().getClassName());
   processClass
(classInfoEntry.getValue());
}

While this works fine in other application servers, it doesnt work on WAS Liberty - in the log I do not see the classes loaded of jar files inside the war, but only the ibm classes.

What do I have to do / set to get hold of jar files / classes inside the war file? I looked at the https://github.com/lukehutch/fast-classpath-scanner/wiki/4.-Working-with-nonstandard-ClassLoaders page and I couldn't determine whether I need to configure a custome ClassLoaderHandler.

Could someone help me out?

Thanks!

--
You received this message because you are subscribed to the Google Groups "FastClasspathScanner-Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fastclasspathscanner-users+unsubsc...@googlegroups.com.
WebsphereLibertyClassLoaderHandler.java

Luke Hutchison

unread,
Jun 24, 2017, 6:09:38 AM6/24/17
to Raimond Kempees, FastClasspathScanner-Users
Hi Raimond,

Thank you for all your work on this! This is great. The code looks right to me, without looking at the details of the classloader itself (but if it works for you, it's good enough for an initial checkin, and we can tweak it in future if another Liberty user finds a case that this code doesn't cover).  Feel free to submit GitHub pull requests for changes in future, but I checked the code in that you sent. Please confirm that it is OK to license your code under the MIT license, the same as the rest of FCS.

This ClassLoaderHandler will be in the next release (2.2.2). I'm waiting on another ClassLoaderHandler that another user is working on, and some info on a Windows OS-level hard lockup bug report that somebody filed, so it might be a few days before I push out that release.

Many thanks,
Luke




To unsubscribe from this group and stop receiving emails from it, send an email to fastclasspathscanner-users+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages