You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Michael B Allen <io...@gmail.com> on 2023/01/31 21:04:17 UTC

How to debug 404s / How to enable error log

This is embarrassing. I have apparently forgotten how to operate Tomcat.

I just downloaded openjdk 17, Tomcat 10.1.5 to a clean Windows 10, upacked
everything, created a myapp-base with a .bat like:

--8<-- bin\start.bat --8<--

setlocal

set "JRE_HOME=C:\tmp\java17"
set "CATALINA_HOME=C:\tmp\tomcat10"
set "CATALINA_BASE=C:\tmp\myapp-base"

%CATALINA_HOME%\bin\catalina.bat start

--

Copied webapp files into the webapps dir.

On bin\start I get some INFO in the console like:

Jan 31, 2023 3:46:02 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
Jan 31, 2023 3:46:02 PM org.apache.catalina.startup.Catalina load
INFO: Server initialization in [797] milliseconds
Jan 31, 2023 3:46:02 PM org.apache.catalina.core.StandardService
startInternal
INFO: Starting service [Catalina]
Jan 31, 2023 3:46:02 PM org.apache.catalina.core.StandardEngine
startInternal
INFO: Starting Servlet engine: [Apache Tomcat/10.1.5]
Jan 31, 2023 3:46:02 PM org.apache.catalina.startup.HostConfig
deployDirectory
INFO: Deploying web application directory [C:\tmp\myapp-base\webapps\myapp]
Jan 31, 2023 3:46:02 PM org.apache.catalina.startup.ContextConfig
getDefaultWebXmlFragment
INFO: No global web.xml found
Jan 31, 2023 3:46:03 PM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable
debug logging for this logger for a complete list of JARs that were scanned
but no TLDs were found in them. Skipping unneeded JARs during scanning can
improve startup time and JSP compilation time.
Jan 31, 2023 3:46:03 PM org.apache.catalina.startup.HostConfig
deployDirectory
INFO: Deployment of web application directory
[C:\tmp\myapp-base\webapps\myapp] has finished in [656] ms
Jan 31, 2023 3:46:03 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
Jan 31, 2023 3:46:03 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in [765] milliseconds

The myapp servlet filter init runs. A localhost access log is created in
myapp-base\logs.

But trying to access anything through localhost:8080 or remotely by
hostname fails with nothing but 404:

10.22.10.30 - - [31/Jan/2023:15:14:49 -0500] "GET /myapp/ HTTP/1.1" 404 682
10.22.10.30 - - [31/Jan/2023:15:14:49 -0500] "GET /favicon.ico HTTP/1.1"
404 682
0:0:0:0:0:0:0:1 - - [31/Jan/2023:15:22:43 -0500] "GET / HTTP/1.1" 404 682
0:0:0:0:0:0:0:1 - - [31/Jan/2023:15:22:43 -0500] "GET /favicon.ico
HTTP/1.1" 404 682
0:0:0:0:0:0:0:1 - - [31/Jan/2023:15:22:49 -0500] "GET /myapp HTTP/1.1" 302 -
0:0:0:0:0:0:0:1 - - [31/Jan/2023:15:22:49 -0500] "GET /myapp/ HTTP/1.1" 404
682
0:0:0:0:0:0:0:1 - - [31/Jan/2023:15:22:53 -0500] "GET /myapp/index.jsp
HTTP/1.1" 404 682

So now I'm just trying to find out how to enable an error log and for the
life of me I'm completely blanking.

How does one enable a debug log? The documentation about such things is
pretty cryptic.

How can I diagnose this further?

Thanks,
Mike

Re: [solved] How to debug 404s / How to enable error log

Posted by Michael B Allen <io...@gmail.com>.
On Tue, Jan 31, 2023 at 5:48 PM Konstantin Kolinko <kn...@gmail.com>
wrote:

> and your configuration is missing
> catalina.properties
> context.xml
> logging.properties
>
> files that are required for proper operation.
>

Thanks.

I have confirmed that also copying logging.properties results in a
logs/catalina.2023-02-01.log file being created.

For posterity (mostly for me actually), the complete procedure for creating
a proper CATALINA_BASE is the following:

Directories that need to be created in CATALINA_BASE are:

bin
conf
logs
work
webapps
temp

Files that need to be copied from CATALINA_HOME\conf to CATALINA_BASE\conf
are:

server.xml
tomcat-users.xml
web.xml
catalina.properties
context.xml
logging.properties

A minimal bin/run.sh for Linux might look like:

#!/bin/sh

export JRE_HOME=/usr/local/java11
export CATALINA_HOME=/path/to/tomcat10
export CATALINA_BASE=/path/to/myapp-base

${CATALINA_HOME}/bin/catalina.sh run "$@"

A minimal bin\run.bat for Windows might look like:

setlocal

set "JRE_HOME=C:\tmp\java17"
set "CATALINA_HOME=C:\tmp\tomcat10"
set "CATALINA_BASE=C:\tmp\myapp-base"

%CATALINA_HOME%\bin\catalina.bat start

Mike

--
Michael B Allen
Java AD DS Integration
http://www.ioplex.com/

Re: [solved] How to debug 404s / How to enable error log

Posted by Konstantin Kolinko <kn...@gmail.com>.
ср, 1 февр. 2023 г. в 00:51, Michael B Allen <io...@gmail.com>:
>
> ├───conf
> │   │   server.xml
> │   │   tomcat-users.xml
> │   │   web.xml

> > It assumes that you are familiar with java.util.logging.
> >
>
> That's unfortunate.  It would be so much nicer if it was a simple one-liner.

It is configured with logging.properties file, and your configuration is missing
catalina.properties
context.xml
logging.properties

files that are required for proper operation.

Best regards,
Konstantin Kolinko

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


Re: [solved] How to debug 404s / How to enable error log

Posted by Michael B Allen <io...@gmail.com>.
On Tue, Jan 31, 2023 at 4:33 PM Konstantin Kolinko <kn...@gmail.com>
wrote:

> > INFO: No global web.xml found
>
> The above message is odd.
> Essentially, it means that the file %CATALINA_BASE%\conf\web.xml does not
> exist.
>

Solved.

That was it. After copying over the conf/web.xml into myapp-base/conf, the
app now works.

The REALLY embarrassing thing is that I just asked about this on Nov 15,
2021 and even after taking notes about it, I failed to include the web.xml
in my notes.

How have you configured your %CATALINA_BASE% directory?
>

These are all of the files that give me what appear to be a working config:

C:\tmp\myapp-base>tree /f
Folder PATH listing
Volume serial number is BAF1-D00E
C:.
│   cmd.lnk
│
├───bin
│       start.bat
│
├───conf
│   │   server.xml
│   │   tomcat-users.xml
│   │   web.xml
│   │
│   └───Catalina
│       └───localhost
├───logs
│       myapp.log
│       localhost_access_log.2023-01-31.txt
│
├───temp
├───webapps
│   └───myapp
│       │   index.jsp
│       │
│       └───WEB-INF
│           │   example.prp
│           │   web.xml
│           │
│           └───lib
│                   myapp-jakarta-1.2.3.jar
│
└───work
    └───Catalina
        └───localhost
            └───myapp
                └───org
                    └───apache
                        └───jsp
                                index_jsp.class
                                index_jsp.java


>
>
> The conf/web.xml configures all the defaults, shared by all web
> applications.
> That includes
> - declaration of DefaultServlet
> - declaration of JspServlet
> - "welcome-file-list"
> - "mime-mapping"s
>
> > How does one enable a debug log? The documentation about such things is
> > pretty cryptic.
>
> It assumes that you are familiar with java.util.logging.
>

That's unfortunate.  It would be so much nicer if it was a simple one-liner.

Mike

Re: How to debug 404s / How to enable error log

Posted by Konstantin Kolinko <kn...@gmail.com>.
ср, 1 февр. 2023 г. в 00:04, Michael B Allen <io...@gmail.com>:
>
> This is embarrassing. I have apparently forgotten how to operate Tomcat.
>

Welcome!

The main help file for running Tomcat is RUNNING.txt,
with additional information in webapps/docs/setup.html and
webapps/docs/windows-service-howto.html

> I just downloaded openjdk 17, Tomcat 10.1.5 to a clean Windows 10, upacked
> everything, created a myapp-base with a .bat like:
>
> --8<-- bin\start.bat --8<--
>
> setlocal
>
> set "JRE_HOME=C:\tmp\java17"
> set "CATALINA_HOME=C:\tmp\tomcat10"
> set "CATALINA_BASE=C:\tmp\myapp-base"
>
> %CATALINA_HOME%\bin\catalina.bat start
>
> --
>
> Copied webapp files into the webapps dir.
>
> On bin\start I get some INFO in the console like:
>
> Jan 31, 2023 3:46:02 PM org.apache.coyote.AbstractProtocol init
> INFO: Initializing ProtocolHandler ["http-nio-8080"]
> Jan 31, 2023 3:46:02 PM org.apache.catalina.startup.Catalina load
> INFO: Server initialization in [797] milliseconds
> Jan 31, 2023 3:46:02 PM org.apache.catalina.core.StandardService
> startInternal
> INFO: Starting service [Catalina]
> Jan 31, 2023 3:46:02 PM org.apache.catalina.core.StandardEngine
> startInternal
> INFO: Starting Servlet engine: [Apache Tomcat/10.1.5]
> Jan 31, 2023 3:46:02 PM org.apache.catalina.startup.HostConfig
> deployDirectory
> INFO: Deploying web application directory [C:\tmp\myapp-base\webapps\myapp]
> Jan 31, 2023 3:46:02 PM org.apache.catalina.startup.ContextConfig
> getDefaultWebXmlFragment
> INFO: No global web.xml found

The above message is odd.
Essentially, it means that the file %CATALINA_BASE%\conf\web.xml does not exist.

How have you configured your %CATALINA_BASE% directory?


The conf/web.xml configures all the defaults, shared by all web applications.
That includes
- declaration of DefaultServlet
- declaration of JspServlet
- "welcome-file-list"
- "mime-mapping"s

> Jan 31, 2023 3:46:03 PM org.apache.jasper.servlet.TldScanner scanJars
> INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable
> debug logging for this logger for a complete list of JARs that were scanned
> but no TLDs were found in them. Skipping unneeded JARs during scanning can
> improve startup time and JSP compilation time.
> Jan 31, 2023 3:46:03 PM org.apache.catalina.startup.HostConfig
> deployDirectory
> INFO: Deployment of web application directory
> [C:\tmp\myapp-base\webapps\myapp] has finished in [656] ms
> Jan 31, 2023 3:46:03 PM org.apache.coyote.AbstractProtocol start
> INFO: Starting ProtocolHandler ["http-nio-8080"]
> Jan 31, 2023 3:46:03 PM org.apache.catalina.startup.Catalina start
> INFO: Server startup in [765] milliseconds
>
> The myapp servlet filter init runs. A localhost access log is created in
> myapp-base\logs.
>
> But trying to access anything through localhost:8080 or remotely by
> hostname fails with nothing but 404:
>
> 10.22.10.30 - - [31/Jan/2023:15:14:49 -0500] "GET /myapp/ HTTP/1.1" 404 682
> 10.22.10.30 - - [31/Jan/2023:15:14:49 -0500] "GET /favicon.ico HTTP/1.1"
> 404 682
> 0:0:0:0:0:0:0:1 - - [31/Jan/2023:15:22:43 -0500] "GET / HTTP/1.1" 404 682
> 0:0:0:0:0:0:0:1 - - [31/Jan/2023:15:22:43 -0500] "GET /favicon.ico
> HTTP/1.1" 404 682
> 0:0:0:0:0:0:0:1 - - [31/Jan/2023:15:22:49 -0500] "GET /myapp HTTP/1.1" 302 -

At least the web application is there. A 302 redirect happens.

> 0:0:0:0:0:0:0:1 - - [31/Jan/2023:15:22:49 -0500] "GET /myapp/ HTTP/1.1" 404
> 682
> 0:0:0:0:0:0:0:1 - - [31/Jan/2023:15:22:53 -0500] "GET /myapp/index.jsp
> HTTP/1.1" 404 682

No JspServlet (to serve it as a JSP page), nor DefaultServlet (to
serve it as a plain downloadable file) are configured.

> So now I'm just trying to find out how to enable an error log and for the
> life of me I'm completely blanking.
>
> How does one enable a debug log? The documentation about such things is
> pretty cryptic.

It assumes that you are familiar with java.util.logging.

> How can I diagnose this further?
>

BTW,
Note that Tomcat 10+ implements JakartaEE Servlet specification.

If your web application is based on JavaEE Servlet specification,
it cannot be put into webapps as is, and has to be converted.

See Migration guide.
https://tomcat.apache.org/migration-10.html#Specification_APIs

Best regards,
Konstantin Kolinko

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