Jetty MultipartFormDataInput未被分派

时间:2016-01-26 12:36:41

标签: java jboss jetty resteasy multipartform-data

我正在开发一个Jetty Servlet,它应该用于上传文件和一些参数,但是MultipartFormDataInput会抛出异常。但是到目前为止,码头网络服务器的开始是预期的。

代码如下所示:

@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
public void createApp(MultipartFormDataInput ressources, @Suspended AsyncResponse response);

当请求调用此servlet时,抛出以下异常:

java.lang.NoClassDefFoundError: Could not initialize class org.apache.james.mime4j.storage.DefaultStorageProvider
at java.lang.Class.forName0(Native Method) ~[?:1.8.0_60]
at java.lang.Class.forName(Class.java:348) ~[?:1.8.0_60]
at org.apache.logging.log4j.core.util.Loader.initializeClass(Loader.java:285) ~[log4j-core-2.0.2.jar:2.0.2]
at org.apache.logging.log4j.core.impl.ThrowableProxy.loadClass(ThrowableProxy.java:500) ~[log4j-core-2.0.2.jar:2.0.2]
at org.apache.logging.log4j.core.impl.ThrowableProxy.toExtendedStackTrace(ThrowableProxy.java:621) [log4j-core-2.0.2.jar:2.0.2]
at org.apache.logging.log4j.core.impl.ThrowableProxy.<init>(ThrowableProxy.java:146) [log4j-core-2.0.2.jar:2.0.2]
at org.apache.logging.log4j.core.impl.Log4jLogEvent.getThrownProxy(Log4jLogEvent.java:323) [log4j-core-2.0.2.jar:2.0.2]
at org.apache.logging.log4j.core.impl.Log4jLogEvent.serialize(Log4jLogEvent.java:429) [log4j-core-2.0.2.jar:2.0.2]
at org.apache.logging.log4j.core.appender.AsyncAppender.append(AsyncAppender.java:153) [log4j-core-2.0.2.jar:2.0.2]
at org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:97) [log4j-core-2.0.2.jar:2.0.2]
at org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:428) [log4j-core-2.0.2.jar:2.0.2]
at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:407) [log4j-core-2.0.2.jar:2.0.2]
at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:365) [log4j-core-2.0.2.jar:2.0.2]
at org.apache.logging.log4j.core.Logger.logMessage(Logger.java:112) [log4j-core-2.0.2.jar:2.0.2]
at org.apache.logging.slf4j.Log4jLogger.log(Log4jLogger.java:374) [log4j-slf4j-impl-2.0.2.jar:2.0.2]
at org.eclipse.jetty.util.log.JettyAwareLogger.log(JettyAwareLogger.java:607) [jetty-util-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.util.log.JettyAwareLogger.warn(JettyAwareLogger.java:431) [jetty-util-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.util.log.Slf4jLog.warn(Slf4jLog.java:69) [jetty-util-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:667) ~[jetty-servlet-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) ~[jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) ~[jetty-servlet-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) ~[jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) ~[jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52) ~[jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) ~[jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.server.Server.handle(Server.java:497) ~[jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) [jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) [jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) [jetty-io-9.2.10.v20150310.jar:9.2.10.v20150310]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_60]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_60]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_60]

如果我删除了MultipartFormDataInput参数,一切都按预期工作。我的代码出了什么问题?

更新

此后还有另一条输出消息:

2016-01-26 13:20:00,152 WARN  [pool-2-thread-15] ? (:) - badMessage: java.lang.IllegalStateException: too much data after closed for HttpChannelOverHttp@46c1358f{r=1,c=false,a=IDLE,uri=-}

更新2

这是我的专家依赖。

<dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-multipart-provider</artifactId>
        <version>3.0.9.Final</version>
        <exclusions>
            <exclusion>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

1 个答案:

答案 0 :(得分:1)

stacktrace告诉你你的slf4j + log4j设置没有正确配置。

您的设置中的某些内容正在尝试将日志发送到需要正常运行EventListener类的appender。

由于某种原因,该课程无法初始化。应该有更多的记录事件(可能更早)指出原因。

来自Apache James Mime4j网站......

  

Apache James Mime4J为普通rfc822和MIME格式的电子邮件流提供了一个解析器MimeStreamParser。

也许您的log4j设置尝试在某些事件上发送电子邮件?

关于HttpChannelOverHttp&#34关闭后关于&#34;太多数据的警告消息;是servlet错误输出而不是处理请求主体内容的结果。忽略该警告,并首先解决基本问题。