On Thu, Oct 10, 2024 at 1:37 PM Donald I Macdonald
<donal...@sealgar.co.uk> wrote:
>
> Hi there,
>
> I've a tomcat 9.0.91 server (running on Corretto OpenJDK 17.0.12.7.1 +
> Amazon Linux 2023). It runs behind nginx (v1.24.0).
>
> The catalina log records a NPE SEVERE error every few seconds,
> complaining that the Host used in the getClientIdentifier method within
> the CrawlerSessionManagerValve is null. Full stack trace is:
>
> 10-Oct-2024 10:47:35.297 SEVERE [http-nio-8080-exec-5]
> org.apache.coyote.http11.Http11Processor.service Error processing request
>      java.lang.NullPointerException: Cannot invoke
> "org.apache.catalina.Host.getName()" because "host" is null
>          at
> org.apache.catalina.valves.CrawlerSessionManagerValve.getClientIdentifier(CrawlerSessionManagerValve.java:264)
>          at
> org.apache.catalina.valves.CrawlerSessionManagerValve.invoke(CrawlerSessionManagerValve.java:181)
>          at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:346)
>          at
> org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:388)
>          at
> org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
>          at
> org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:936)
>          at
> org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1791)
>          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)
>
> No doubt this is due to my own misconfiguration somewhere, but I'm not
> sure what to change to fix it. The server.xml has two <Host> directives,
> as follows (domain changed for privacy):
>
>       <Host name="dev.mysite.com"  appBase="webapps" unpackWARs="true"
> autoDeploy="true">
>          <Alias>devnew.mysite.com</Alias>
>           <Valve className="org.apache.catalina.valves.RemoteIpValve"
> protocolHeader="X-Forwarded-Proto"/>
>           <Valve className="org.apache.catalina.valves.AccessLogValve"
> directory="logs"
>                 prefix="dev_access_log" suffix=".txt"
>                 pattern="%h %l %u %t &quot;%r&quot; %s %b"
> rotatable="false" requestAttributesEnabled="true"/>
>        </Host>
>
>        <Host name="dev2.mysite.cin" appBase="/usr/local/tomcat/webapps2"
> unpackWARs="true" autoDeploy="true">
>            <Valve className="org.apache.catalina.valves.RemoteIpValve"
> protocolHeader="X-Forwarded-Proto"/>
>            <Valve className="org.apache.catalina.valves.AccessLogValve"
> directory="logs"
>              prefix="dev2_access_log" suffix=".log"
>              pattern="%h %l %u %t &quot;%r&quot; %s %b"
> rotatable="false" requestAttributesEnabled="true"/>
>        </Host>
>
> Acting on a hint in another forum post I tried turning sendFile off on
> the <Connector> (so it now looks like this):
>
>      <Connector port="8080" protocol="HTTP/1.1"
> connectionTimeout="20000" compression="off"
>          redirectPort="443" proxyPort="80" secure="true"
> URIEncoding="UTF-8" useSendfile="false"
>                 maxParameterCount="1000" />
>
> This had no effect other than (seemingly) to cause a fuller stack trace
> to be generated in the error log.
>
> The site appears to function normally, and serves content as it should,
> despite the error message. It is however a concern to me that perhaps
> some users (or bots?) *are* seeing errors.

The crawler valve seems to be defined on the Engine, but more
importantly it seems you have no default host ?

So the request is not being mapped and it would return 404 (but the
valve would need some extra null checks).

Rémy

>
>
> ---------------------------------------------------------------------
> 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