Message5529

Author c.cerbo
Recipients c.cerbo
Date 2010-02-15.13:49:38
SpamBayes Score 9.992007e-15
Marked as misclassified No
Message-id <1266241779.73.0.00197510240253.issue1556@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2010-02-15 13:49:39c.cerbosetrecipients: + c.cerbo
2010-02-15 13:49:39c.cerbosetmessageid: <1266241779.73.0.00197510240253.issue1556@psf.upfronthosting.co.za>
2010-02-15 13:49:39c.cerbolinkissue1556 messages
2010-02-15 13:49:39c.cerbocreate