将war文件上传到tomcat时出现IllegalArgumentException

时间:2016-01-13 09:11:44

标签: java maven tomcat tomcat7 maven-tomcat-plugin

使用maven-tomcat7-plugin将我的Web应用程序部署到tomcat管理器时遇到问题。问题似乎与传输有关,但在传输完成之前不会触发。 transfere返回ok状态,但传输的文件是0kb,应该是大约50Mb。

如果我手动将war文件放在webapps文件夹中,它会自动启动。但是,如果我使用管理器gui或插件,我会收到此错误。

INFO: Manager: Uploading WAR file to C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\spa-test.war.tmp
jan 13, 2016 9:52:13 FM org.apache.catalina.core.ApplicationContext log
SEVERE: Manager: managerServlet.check[/spa-test]
java.lang.IllegalArgumentException: Header message of length [65,532] received but the packetSize is only [8,192]
    at org.apache.coyote.ajp.AjpProcessor.readMessage(AjpProcessor.java:383)
    at org.apache.coyote.ajp.AjpProcessor.receive(AjpProcessor.java:334)
    at org.apache.coyote.ajp.AbstractAjpProcessor$SocketInputBuffer.doRead(AbstractAjpProcessor.java:1188)
    at org.apache.coyote.Request.doRead(Request.java:438)
    at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:290)
    at org.apache.tomcat.util.buf.ByteChunk.substract(ByteChunk.java:449)
    at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:315)
    at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:167)
    at org.apache.catalina.manager.ManagerServlet.uploadWar(ManagerServlet.java:1609)
    at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:723)
    at org.apache.catalina.manager.ManagerServlet.doPut(ManagerServlet.java:456)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:653)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
    at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:190)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)

任何想法如何处理?

这就是我的stderr日志所说的:

13-Jan-2016 09:50:49.901 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\manager has finished in 47 ms
13-Jan-2016 09:50:49.901 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-bio-8080"]
13-Jan-2016 09:50:49.948 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-bio-8009"]
13-Jan-2016 09:50:49.948 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 37024 ms
13-Jan-2016 09:52:13.949 SEVERE [ajp-bio-8009-exec-1] org.apache.coyote.ajp.AjpMessage.processHeader Invalid message received with signature 65530

这是我的访问日志所说的:

10.23.73.76 - userName [13/Jan/2016:10:33:13 +0100] "POST /manager/html/upload?org.apache.catalina.filters.CSRF_NONCE=<EditedOut> HTTP/1.1" 500 3840

这是我的服务器配置文件:

<?xml version='1.0' encoding='utf-8'?>
<Server port="8005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

  <GlobalNamingResources>
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

  <Service name="Catalina">
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
    <Engine name="Catalina" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>

      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />
      </Host>
    </Engine>
  </Service>
</Server>

如果您需要有关配置的更多信息,请询问。

谢谢!

1 个答案:

答案 0 :(得分:2)

问题是我正在使用tomcat_iis_connector isapimodule连接IIS后面的tomcatmanager。此管理器配置为使用65536的数据包大小。因此我不得不像这样更改我的tomcat服务器配置。

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" packetSize="65536"/>

这会将最大接受数据包大小设置为与iis连接器相同,而不是默认值8MB。以下是tomcat docs对数据包大小的反馈。

  

此属性以字节为单位设置最大AJP数据包大小。最大值   value为65536.它应与max_packet_size指令相同   为mod_jk配置。通常没有必要改变   最大包大小。已经出现了默认值的问题   发送证书或证书链时报告。默认   价值是8192。