将 war 文件上传到 tomcat 时发生 IllegalArgumentException
IllegalArgumentException when uploading war file to tomcat
我在使用 maven-tomcat7-plugin 将我的 Web 应用程序部署到 tomcat 管理器时遇到问题。该问题似乎与传输有关,但在传输完成之前不会触发。 transfere returns 状态正常,但是传输的文件是 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 "%r" %s %b" />
</Host>
</Engine>
</Service>
</Server>
如果您需要有关配置的更多信息,请询问。
谢谢!
问题是我正在使用 tomcat_iis_connector isapimodule 连接 IIS 后面的 tomcatmanager。该管理器配置为使用 65536 的数据包大小。因此我不得不像这样更改 AJP 连接器的 tomcat 服务器配置。
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" packetSize="65536"/>
这会将最大接受数据包大小设置为与 iis 连接器相同,而不是默认的 8MB。这是对数据包大小的 tomcat docs 的引用。
This attribute sets the maximum AJP packet size in Bytes. The maximum
value is 65536. It should be the same as the max_packet_size directive
configured for mod_jk. Normally it is not necessary to change the
maximum packet size. Problems with the default value have been
reported when sending certificates or certificate chains. The default
value is 8192.
我在使用 maven-tomcat7-plugin 将我的 Web 应用程序部署到 tomcat 管理器时遇到问题。该问题似乎与传输有关,但在传输完成之前不会触发。 transfere returns 状态正常,但是传输的文件是 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 "%r" %s %b" />
</Host>
</Engine>
</Service>
</Server>
如果您需要有关配置的更多信息,请询问。
谢谢!
问题是我正在使用 tomcat_iis_connector isapimodule 连接 IIS 后面的 tomcatmanager。该管理器配置为使用 65536 的数据包大小。因此我不得不像这样更改 AJP 连接器的 tomcat 服务器配置。
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" packetSize="65536"/>
这会将最大接受数据包大小设置为与 iis 连接器相同,而不是默认的 8MB。这是对数据包大小的 tomcat docs 的引用。
This attribute sets the maximum AJP packet size in Bytes. The maximum value is 65536. It should be the same as the max_packet_size directive configured for mod_jk. Normally it is not necessary to change the maximum packet size. Problems with the default value have been reported when sending certificates or certificate chains. The default value is 8192.