Lance,

On 9/20/24 09:23, Campbell, Lance wrote:
I was wrong. I did confirm what code was causing the issue. In my servlet at 
the top I did this:

cookie[index].setMaxAge(0);
resp.addCookie(cookie[index]);

Then at the bottom of the code I did:

resp.sendRedirect(".....");

When I commented out the code relating to the cookies it then worked.  I 
believe that if you call resp.sendRedirect you may not be able to do anything 
else with the resp. This is just a guess.

You might be able to do things with the response *if* the response has not been "committed". A response is "committed" when the first bytes -- usually the full set of headers and possibly some of the response body -- have actually been sent to the network interface.

Once that happens, the only thing you can really do is destroy the response body and show the user an ugly page.

None of this stuff is related to your original report of AJP errors. Check the max_packet_size on httpd and the packetSize in Tomcat, as Mark suggested.

We recently upgraded from Tomcat 8 -> Tomcat 9 in production and we were surprised to find similar errors in spite of configurations that should have been identical to our previous version. A re-sync of the packet size configuration got everything working perfectly again.

-chris

-----Original Message-----
From: Mark Thomas <ma...@apache.org>
Sent: Friday, September 20, 2024 1:23 AM
To: users@tomcat.apache.org
Subject: Re: Error migrating to Tomcat 10.1

On 19/09/2024 21:16, Campbell, Lance wrote:
I think I might have found the issue.  I built my web app with Java 8 and 
Tomcat 9 using version 4.0 of the web-app species originally.  This was a 
servlet mapping I had:

<servlet-mapping>
      <servlet-name>NavigationServlet</servlet-name>
      <url-pattern>*.navigation</url-pattern>
    </servlet-mapping>

Notice the url-pattern. It has *.navigation.

Now I am using Java 17 and Tomcat 10.1 with version 5.0 of the web-app specs.  
Is the above allowed with a URL redirection?

Yes.


  I think the *.xyz might be the issue with HttpServletResponse sendRedirect .
  > > Thoughts?

Unlikely related given the error you are seeing.

Mark



Thanks


-----Original Message-----
From: Mark Thomas <ma...@apache.org>
Sent: Thursday, September 19, 2024 2:52 PM
To: users@tomcat.apache.org
Subject: Re: Error migrating to Tomcat 10.1

On 19/09/2024 20:19, Campbell, Lance wrote:
I am using the latest Tomcat 10.1

Java 17

Apache Web server communicates with an application server running tomcat.  The 
application name is webtools.

I am migrating a working app from Tomcat 9 to Tomcat 10.1.

Does your AJP connector in Tomcat 9 have a packetSize attribute? If
yes, you need to copy that across to 10.1

You can also check your work configuration on httpd for max_packet_size.
The two values have to agree.

Mark



I am getting this error in the tomcat app after sending a web request. It seems 
like it is starting to load things. Then I see the below:

19-Sep-2024 13:54:54.086 INFO [main]
org.apache.catalina.startup.HostConfig.deployDescriptor Deployment of
deployment descriptor
[/....../webtools/conf/Catalina/localhost/ROOT.xml] has finished in
[3,782] ms
19-Sep-2024 13:54:54.089 INFO [main]
org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler
["ajp-nio-0:0:0:0:0:0:0:0-8149"]
19-Sep-2024 13:54:54.101 INFO [main]
org.apache.catalina.startup.Catalina.start Server startup in [3873]
milliseconds
19-Sep-2024 13:54:55.332 SEVERE [ajp-nio-0:0:0:0:0:0:0:0-8149-exec-1] 
org.apache.coyote.ajp.AjpMessage.checkOverflow Overflow error for buffer adding 
[113] bytes at position [8085]
           java.lang.ArrayIndexOutOfBoundsException
                   at 
org.apache.coyote.ajp.AjpMessage.checkOverflow(AjpMessage.java:242)
                   at 
org.apache.coyote.ajp.AjpMessage.appendBytes(AjpMessage.java:211)
                   at 
org.apache.coyote.ajp.AjpMessage.appendByteChunk(AjpMessage.java:197)
                   at 
org.apache.coyote.ajp.AjpMessage.appendBytes(AjpMessage.java:181)
                   at 
org.apache.coyote.ajp.AjpProcessor.prepareResponse(AjpProcessor.java:991)
                   at 
org.apache.coyote.AbstractProcessor.action(AbstractProcessor.java:377)
                   at org.apache.coyote.Response.action(Response.java:210)
                   at org.apache.coyote.Response.commit(Response.java:464)
                   at 
org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:285)
                   at 
org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:244)
                   at 
org.apache.catalina.connector.Response.finishResponse(Response.java:421)
                   at 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:373)
                   at 
org.apache.coyote.ajp.AjpProcessor.service(AjpProcessor.java:431)
                   at 
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
                   at 
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:904)
                   at 
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1741)
                   at 
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
                   at 
org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1190)
                   at 
org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
                   at 
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63)
                   at java.base/java.lang.Thread.run(Thread.java:840)

This is my server.xml file:

<?xml version='1.0' encoding='utf-8'?> <Server port="8145"
shutdown="SHUTDOWN">

     <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
     <Listener className="org.apache.catalina.core.AprLifecycleListener" />
     <Listener 
className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
     <Listener 
className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
     <Listener
className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"
/>

     <Service name="Catalina">

       <Connector  port="8149"
                   address="::"
                   secretRequired="false"
                   allowedRequestAttributesPattern=".*"
                   enableLookups="false"
                   redirectPort="8443"
                   protocol="AJP/1.3"
                   tomcatAuthentication="false"
                   acceptCount="100"
                   maxThreads="400"
                   minSpareThreads="50"
                   URIEncoding="UTF-8"
                   maxPostSize="20971520"/>

       <Engine name="Catalina" defaultHost="localhost">

         <Host name="localhost" appBase="webapps" unpackWARs="true"
autoDeploy="true">

         </Host>
       </Engine>
     </Service>
</Server>

Error in the jk.log on apache running mod_jk:

[Thu Sep 19 14:11:06.896 2024] [18915:140692079404800] [error]
ajp_unmarshal_response::jk_ajp_common.c (786): (webtools) NULL header
value [Thu Sep 19 14:11:06.896 2024] [18915:140692079404800] [error]
ajp_process_callback::jk_ajp_common.c (1937): (webtools)
ajp_unmarshal_response failed [Thu Sep 19 14:11:06.896 2024]
[18915:140692079404800] [info] ajp_service::jk_ajp_common.c (2774):
(webtools) sending request to tomcat failed (recoverable), because of
server error (attempt=1) [Thu Sep 19 14:11:06.997 2024] [18915:140692079404800] 
[info] ajp_send_request::jk_ajp_common.c (1623): (webtools) did not receive 
END_RESPONSE, closing socket -1 [Thu Sep 19 14:11:07.127 2024] 
[18915:140692079404800] [error] ajp_unmarshal_response::jk_ajp_common.c (786): 
(webtools) NULL header value [Thu Sep 19 14:11:07.127 2024] 
[18915:140692079404800] [error] ajp_process_callback::jk_ajp_common.c (1937): 
(webtools) ajp_unmarshal_response failed [Thu Sep 19 14:11:07.127 2024] 
[18915:140692079404800] [info] ajp_service::jk_ajp_common.c (2774): (webtools) 
sending request to tomcat failed (recoverable), because of server error 
(attempt=2) [Thu Sep 19 14:11:07.128 2024] [18915:140692079404800] [error] 
ajp_service::jk_ajp_common.c (2795): (webtools) connecting to tomcat failed 
(rc=-3, errors=1, client_errors=0).
[Thu Sep 19 14:11:07.128 2024] [18915:140692079404800] [info]
jk_handler::mod_jk.c (2991): Service error=-3 for worker=webtools


Thanks,

Lance Campbell



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to