commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Antony Scerri (JIRA)" <>
Subject [jira] Commented: (DAEMON-100) Thread.currentThread().getContextClassLoader() == null when the program is runned by Prunsrv
Date Fri, 25 Jun 2010 19:57:50 GMT


Antony Scerri commented on DAEMON-100:

Sorry to do this a little messily but i have a number of different contribution so a single
patch isnt possible. I believe the solution to this problem which I encountered whilst handling
an application hosting an RMI registry which was generating class not found exception when
registering objects because of this lack of fully supporting class loader is the modification
of the __apxJavaWorkerThread method in javajni.c. I have attached an updated version of this
method with just the parts relating to this problem.

Essentialy all it does is after the native thread is attached to the VM (which is different
from the one which creates the main class. It checks to see if a thread context class loader
can be found, this is incase the same thread that created the main class is now being used
in which case it should already have one. I know this isnt the case at the moment but incase
the design changes i thought it worth putting it inside a check. If not it then gets the class
loader from the main class and assigns it to the current threads context class loader, therefore
providing a fully functional class loader for the thread itself.

There could be some more exception checking between all the calls added with appropriate failure
paths, but this should be enough to demonstrate the core fix. I have succesffuly used this
to get a java application loaded on windows through the prunsrv.exe that creates an RMI registry
and registers objects appropriately.

> Thread.currentThread().getContextClassLoader() == null when the program is runned by
> --------------------------------------------------------------------------------------------
>                 Key: DAEMON-100
>                 URL:
>             Project: Commons Daemon
>          Issue Type: Bug
>          Components: Procrun
>         Environment: Win XP, jre1.5.0_11,<path to a file with
following content>:
> grant  {
>     permission "", "";
>     permission com.sun.rmi.rmid.ExecPermission "<<ALL FILES>>";
>     permission com.sun.rmi.rmid.ExecOptionPermission "*";
> };
>            Reporter: Anton Vodonosov
>         Attachments: __apxJavaWorkerThread.txt, DaemonLoader.patch
> Thread.currentThread().getContextClassLoader() == null when the program is runned by
Prunsrv, but when we run the same system using java.exe, Thread.currentThread().getContextClassLoader()
is not null.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message