1

我正在学习 Grinder 3.11 来编写我的性能测试脚本。这是我用 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()

当我使用 Grinder 启动它时,我不断收到以下错误

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]

当我评论库的导入jackson并用我得到的其余脚本在类路径中打印罐子时

/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

在仔细检查之后,我可以确认ObjectMapper该类在jackson-databind-2.2.3.jar.

我在 Jython/Grinder 组合中的其他外部库没有这样的问题。

我怎样才能找到问题的根本原因?

4

1 回答 1

1

这意味着 ObjectMapper 正在调用 CLASSPATH 中缺少的类。

于 2015-04-16T17:53:22.180 回答