我正在学习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
库的导入并在classpath中打印jar时,我得到了其余的脚本
/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组合中没有遇到其他外部库的问题。
如何找到问题的根本原因?
答案 0 :(得分:1)
这意味着ObjectMapper正在调用CLASSPATH中缺少的类。