Getting Jodd Jerry: NoClassDefFoundError语言 - jodd/exception/Un



我正在尝试在我的java项目中使用Jodd的Jerry模块,为此我下载了Jodd-Lagarto- 3.4.5 jar 并添加到类路径中。我开始编写如下所示的代码。

public void testJerryParserCreation() {
    Jerry.JerryParser jerryParser = Jerry.jerry();
    ((LagartoDOMBuilder) jerryParser.getDOMBuilder()).enableXmlMode();
    Jerry doc = jerryParser.parse("<xml>   <book isbn='123'> <name>Foo<br></name>   </book></xml>");
    Jerry name = doc.$("book name");
    assertEquals("Foo", name.text());
    assertEquals("<xml><book isbn="123"><name>Foo<br></br></name></book></xml>", doc.html());
}

但是在上面第一行本身的测试中,它给出了以下异常。 这里可能有什么问题。我的罐子不正确吗?

java.lang.NoClassDefFoundError: jodd/exception/UncheckedException
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at jodd.jerry.Jerry$JerryParser.createLagartoDOMBuilder(Jerry.java:82)
    at jodd.jerry.Jerry$JerryParser.<init>(Jerry.java:75)
    at jodd.jerry.Jerry.jerry(Jerry.java:123)
    at com.veersoft.JerryParserTest.testJerryParserCreation(JerryParserTest.java:22)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException: jodd.exception.UncheckedException
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 39 more

很简单:) jodd-lagarto模块取决于jodd-core缺少类的模块(以及Lagarto使用的其他实用程序)。检查下载页面以查看所有模块和依赖项。对于您的版本,可能还依赖于slf4j记录器(最近已将其删除)。

您也可以考虑使用一些依赖项管理工具,例如 gradlemaven。比所有依赖项都会自动下载。

如果可能,请尝试使用最新版本的 Jodd :)此时是 3.4.10;3.5快出来了。新版本包含一些与Lagarto相关的重要改进,修复和性能提升:)享受!

相关内容

  • 没有找到相关文章

最新更新