jodd和jetty classNotFound(org.eclipse.jetty.client.api.Result)

时间:2015-06-07 11:17:51

标签: jodd

我有一个使用jodd 3.6.6的应用程序构建,当我尝试在jetty9上运行它时,它无法初始化Madvoc:

    1377 [ERROR] j.m.Madvoc.startNewWebApplication:161 - Madvoc startup failure.
jodd.madvoc.MadvocException: Scan classpath error; <--- java.lang.ClassNotFoundException: Class not found: org.eclipse.jetty.client.api.Result
    at jodd.madvoc.config.AutomagicMadvocConfigurator.configure(AutomagicMadvocConfigurator.java:85)
    at jodd.madvoc.config.AutomagicMadvocConfigurator.configure(AutomagicMadvocConfigurator.java:65)
    at jodd.madvoc.WebApplication.configure(WebApplication.java:255)
    at jodd.madvoc.Madvoc.start(Madvoc.java:238)
    at jodd.madvoc.Madvoc.startNewWebApplication(Madvoc.java:157)
    at jodd.madvoc.MadvocServletFilter.init(MadvocServletFilter.java:45)
    at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:138)
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:852)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:298)
    at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1349)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1342)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:505)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
    at org.eclipse.jetty.server.Server.start(Server.java:387)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
    at org.eclipse.jetty.server.Server.doStart(Server.java:354)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at net.sourceforge.eclipsejetty.starter.jetty9.Jetty9Adapter.start(Jetty9Adapter.java:68)
    at net.sourceforge.eclipsejetty.starter.common.AbstractJettyLauncherMain.launch(AbstractJettyLauncherMain.java:85)
    at net.sourceforge.eclipsejetty.starter.jetty9.Jetty9LauncherMain.main(Jetty9LauncherMain.java:42)
Caused by: jodd.io.findfile.FindFileException: Scan entry error: EntryData{org.eclipse.jetty.client.api.Result'}; <--- java.lang.ClassNotFoundException: Class not found: org.eclipse.jetty.client.api.Result
    at jodd.io.findfile.ClassFinder.scanEntry(ClassFinder.java:391)
    at jodd.io.findfile.ClassFinder.scanJarFile(ClassFinder.java:292)
    at jodd.io.findfile.ClassFinder.scanPath(ClassFinder.java:261)
    at jodd.io.findfile.ClassFinder.scanPaths(ClassFinder.java:226)
    at jodd.madvoc.config.AutomagicMadvocConfigurator.configure(AutomagicMadvocConfigurator.java:83)
    ... 22 more
Caused by: jodd.madvoc.MadvocException: Invalid Madvoc result class: org.eclipse.jetty.client.api.Result; <--- java.lang.ClassNotFoundException: Class not found: org.eclipse.jetty.client.api.Result
    at jodd.madvoc.config.AutomagicMadvocConfigurator.onEntry(AutomagicMadvocConfigurator.java:108)
    at jodd.io.findfile.ClassFinder.scanEntry(ClassFinder.java:389)
    ... 26 more

相同的应用程序在tomcat上运行没有问题。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

好的,应该很简单:只需跳过netty类的扫描。

以下是解释:在Madvoc中,您可以选择使用Result类(source)来处理结果(documentation)。简而言之,如果您有一个Result类型的字段,Madvoc会将其用于此功能。

所以看起来Netty有相同的类名,因此错误。为了防止这种情况(直到我们更好地识别),只需跳过扫描完整的类路径,并使扫描程序仅扫描您的类 - 这也将改善启动性能。以下是如何做到这一点:

默认情况下,AutomagicMadvocConfigurator用于配置操作(通过扫描路径)。获取此实例(例如,在WebApplication中)并配置它(因为它是ClassFinder子类)。所以我所做的是:

classFinder.setExcludeAllEntries(true);
classFinder.setIncludedEntries(myapp.getClass().getPackage().getName() + ".*");
classFinder.setIncludedJars("somejar.jar", "myapp*.jar");

这将缩小正在搜索的类路径。

如果您需要更多帮助,请与我们联系。同时,我们肯定会做出改变,所以这种情况再也不会发生了!