From: Costantino C. <re...@bu...> - 2010-02-15 13:59:01
|
New submission from Costantino Cerbo <c....@gm...>: The following code: --- import sys sys.path.append("serviceloadertest.jar") from org.jython.sandbox import ServiceLoaderTest s = ServiceLoaderTest() s.testServiceLoader() --- 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 "test_serviceloader.py", line 6, in <module> s.testServiceLoader() at org.jython.sandbox.ServiceLoaderTest.testServiceLoader(ServiceLoaderTest.java:19) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) 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 = iter.next(); } if (service == null) { throw new Exception(TestService.class.getName() + " not found"); } else { System.out.println(service.sayHello("Costantino")); } --- Please authorize me to post files and I'll send a complete test case. ---------- components: Core messages: 5529 nosy: c.cerbo severity: major status: open title: java.util.ServiceLoader doesn't find services when a .jar is added to sys.path type: behaviour versions: 2.5.1 _______________________________________ Jython tracker <re...@bu...> <http://bugs.jython.org/issue1556> _______________________________________ |