Title: java.util.ServiceLoader doesn't find services when a .jar is added to sys.path
Type: behaviour Severity: major
Components: Core Versions: 2.5.1
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: amak, c.cerbo, zyasoft
Priority: Keywords:

Created on 2010-02-15.13:49:39 by c.cerbo, last changed 2012-03-19.20:00:45 by amak.

msg5529 (view) Author: Costantino Cerbo (c.cerbo) Date: 2010-02-15.13:49:38
The following code:
import sys
from org.jython.sandbox import ServiceLoaderTest

s = ServiceLoaderTest()

will produce this exception:
*sys-package-mgr*: processing new jar, '/home/c.cerbo/workspaces/jython/jython-sandbox/serviceloadertest.jar'
Traceback (most recent call last):
  File "", line 6, in <module>
	at org.jython.sandbox.ServiceLoaderTest.testServiceLoader(
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.lang.reflect.Method.invoke(

java.lang.Exception: java.lang.Exception: org.jython.sandbox.TestService not found

If serviceloadertest.jar is added to the env variable CLASSPATH before starting jython everything works fine.

A snipped from the java code:
ServiceLoader<TestService> services = ServiceLoader.load(TestService.class);
		Iterator<TestService> iter = services.iterator();

		TestService service = null;
		if (iter.hasNext()) {
			service =;

		if (service == null) {
			throw new Exception(TestService.class.getName() + " not found");
		} else {

Please authorize me to post files and I'll send a complete test case.
msg5530 (view) Author: Costantino Cerbo (c.cerbo) Date: 2010-02-15.13:51:57
The reason of this bug, if that ServiceLoader.load(..) doesn't use SyspathJavaLoader as classload, thefore is unable to find the resource "/META-INF/services/org.jython.sandbox.TestService"
msg5972 (view) Author: Jim Baker (zyasoft) Date: 2010-08-15.17:18:27
Is this still an issue on trunk? It looks like a duplicate of #1455.

The problem with attachments at least has long been fixed.
msg6845 (view) Author: Alan Kennedy (amak) Date: 2012-03-19.19:53:55
Is this still an issue? No input from the user in over two years?

msg6849 (view) Author: Costantino Cerbo (c.cerbo) Date: 2012-03-19.19:58:39
Yes, it has been fixed. You can close this issue.
msg6851 (view) Author: Alan Kennedy (amak) Date: 2012-03-19.20:00:45
Closing, as per requester input.
Date User Action Args
2012-03-19 20:00:45amaksetstatus: open -> closed
resolution: fixed
messages: + msg6851
2012-03-19 19:58:39c.cerbosetmessages: + msg6849
2012-03-19 19:53:56amaksetnosy: + amak
messages: + msg6845
2010-08-15 17:18:27zyasoftsetnosy: + zyasoft
messages: + msg5972
2010-02-15 13:51:58c.cerbosetmessages: + msg5530
2010-02-15 13:49:39c.cerbocreate