Re: Grinder/Jython fails to find class in imported library

Olivier <[email protected]> Wed, 18 Mar 2015 20:35:38 +0100
Newsgroups gmane.comp.java.grinder.user
Message-ID <[email protected]>
The jackson library is already in your classpath
 you have to reduce the jars used to launch your worker and not use the grinder.jar
Cheers

-----Message d'origine-----
De : "Maciej Gawinecki" <[email protected]>
Envoyé : ‎16/‎03/‎2015 15:57
À : "[email protected]" <[email protected]>
Objet : [Grinder-use] Grinder/Jython fails to find class in imported library

Hi,

I'm learning Grinder 3.11 to script my performance tests. Here's my test script written in Jython:
----------------
from java.lang import ClassLoader
from com.fasterxml.jackson.databind import ObjectMapper
from java.net import URL, URLClassLoader

cl = ClassLoader.getSystemClassLoader()
for url in cl.getURLs():
    print url.getFile()

class TestRunner:
    def __call__(self):
        self.test_scenario()
----------------
When I launch it with Grinder I keep getting the following error
----------------
2015-03-16 11:52:56,783 ERROR krk-mpfxv-16: aborting process - Java exception initialising test script
net.grinder.scriptengine.jython.JythonScriptExecutionException: Java exception initialising test script
        from com.fasterxml.jackson.databind import ObjectMapper
        File "/Users/mgawinec/projects/grinder-test/src/test/resources/./krk-mpfxv-file-store/current/grinder.py", line 4, in <module>
java.lang.NoClassDefFoundError: Could not initialize class com.fasterxml.jackson.databind.ObjectMapper
        at java.lang.Class.forName0(Native Method) ~[na:1.8.0_05]
        at java.lang.Class.forName(Class.java:340) ~[na:1.8.0_05]
----------------
When I commented the import for jackson library and printed the jars in classpath with the rest of the script I got 

----------------
/Users/xx/projects/grinder-test/src/test/resources/lib/grinder.jar
/Users/xx/projects/grinder-test/src/test/resources/lib/jackson-databind-2.2.3.jar
/Users/xx/projects/grinder-test/src/test/resources/lib/htmlcleaner-2.6.1.jar
/Users/xx/projects/grinder-test/src/test/resources/lib/jackson-core-2.0.0.jar
/Users/xx/projects/grinder-test/src/test/resources/lib/grinder-dcr-agent-3.11.jar
----------------
And after double-checking I can confirm that ObjectMapper class is in the right package in the jackson-databind-2.2.3.jar.
I didn't have such problems with other external libraries in Jython/Grinder combination. 
How can I find what is the root cause of the problem?
Thanks a lot,
Maciej

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/

_______________________________________________
grinder-use mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/grinder-use