Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 332517 - Logging from DefaultServlet next to useless - no information about attempted path for static resources
Summary: Logging from DefaultServlet next to useless - no information about attempted ...
Status: CLOSED FIXED
Alias: None
Product: Jetty
Classification: RT
Component: server (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: 7.1.x   Edit
Assignee: Greg Wilkins CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-14 08:03 EST by Cefn Hoile CLA
Modified: 2011-09-20 15:52 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Cefn Hoile CLA 2010-12-14 08:03:15 EST
Build Identifier: 

I'm attempting to serve a static css file using DefaultServlet. The log I've included below shows essentially no information which I can't already get from the 404 I can see in the browser. 

This is a feature request to get DefaultServlet to generate some kind of meaningful logging messages which indicate, for example, what path is being attempted to resolve /assets/style.css

I've tried almost every possible debugging property I can find from the myriad pages of 'how to get Jetty to do debugging'. My VM launch arguments currently look like this...

-DDEBUG -Dorg.eclipse.jetty.util.log.DEBUG=true -Dsystem_property_name.DEBUG=true -Djava.util.logging.config.file=src/main/java/webserver.logging.properties -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger 

I'm running Jetty as a servlet engine with Guice to wire paths. For reference, a snapshot of the simple test App I'm experimenting with is available here, including the Jetty launch config in ServerApp...
https://github.com/cefn/Spring-JPA-MVC-Postgres/tree/6118b7a02e555656416a46b91e7cd856f8a3b01b/src/main/java/com/cefn/filesystem/servlet 

Even if my code approach could be better, the thing I really need is meaningful errors! Not like the following, which gives me no idea where to put the 'assets' folder, or where the failure happened...

FINE: REQUEST /assets/style.css on org.eclipse.jetty.server.nio.SelectChannelConnector$3@124bd93
14-Dec-2010 12:50:25 org.eclipse.jetty.util.log.Slf4jLog debug
FINE: sessionManager=org.eclipse.jetty.server.session.HashSessionManager@ef7d74
14-Dec-2010 12:50:25 org.eclipse.jetty.util.log.Slf4jLog debug
FINE: session=null
14-Dec-2010 12:50:25 org.eclipse.jetty.util.log.Slf4jLog debug
FINE: servlet=org.eclipse.jetty.servlet.DefaultServlet-28943672
14-Dec-2010 12:50:25 org.eclipse.jetty.util.log.Slf4jLog debug
FINE: servlet holder=
14-Dec-2010 12:50:25 org.eclipse.jetty.util.log.Slf4jLog debug
FINE: chain=
14-Dec-2010 12:50:25 org.eclipse.jetty.util.log.Slf4jLog debug
FINE: call filter com.google.inject.servlet.GuiceFilter-3747816
14-Dec-2010 12:50:25 org.eclipse.jetty.util.log.Slf4jLog debug
FINE: RESOURCE /assets/style.css.gz=null
14-Dec-2010 12:50:25 org.eclipse.jetty.util.log.Slf4jLog debug
FINE: RESOURCE /assets/style.css=null
14-Dec-2010 12:50:25 org.eclipse.jetty.util.log.Slf4jLog debug
FINE: resource=null
14-Dec-2010 12:50:25 org.eclipse.jetty.util.log.Slf4jLog debug
FINE: RESPONSE /assets/style.css  404

Reproducible: Always

Steps to Reproduce:
1. Rely on DefaultServlet to serve static content
2. Observe silent 404 failure in the logs with no meaningful diagnostic information 
3. Attempt every possible Debug configuration property to see more information
4. Give up
Comment 1 Cefn Hoile CLA 2010-12-14 08:10:43 EST
Sorry, the updated file for this scenario, which provides configuration of paths to servlets is ServletContextAdaptor.java in this folder.

https://github.com/cefn/Spring-JPA-MVC-Postgres/blob/6fe00f7938a64d04c48151ed841ee54d923781cf/src/main/java/com/cefn/filesystem/servlet/

The build I'm using is from jetty-distribution 8.0.0M2 out of the org.eclipse maven.
Comment 2 Greg Wilkins CLA 2010-12-14 11:05:27 EST
Dear GRUMPY!

I do believe that we may have inadvertently reduced the level of useful
debugging with our recent changes to the resource cache.

The debug line with "resource=null" previously would never give a null result
and would reveal the path that was being attempted.

For now, turn off the resource cache (set  max cached files to 0 on the default
servlet) and you should get better debug output.

Also to confirm my diagnosis, what version of Jetty are you using?

we'll make sure we fix it for the next release.

regards
Comment 3 Cefn Hoile CLA 2010-12-14 11:39:08 EST
"Dear GRUMPY!" made me laugh. 

Thankyou for the feedback and the workaround. As noted in the original thread I'm using 8.0.0M2 from org.eclipse through maven.

The property 'resourceBase' was unset, (so the default path could have been read as null). I was attempting to work out what the default location served by DefaultServlet was if nothing was specified - aiming to place files in the  default location for a typical maven environment (e.g. src/main/webapp) rather than introducing lots of hard coded paths which could break.

I'm not using a web.xml configuration plus maven plugin, but instead launching Jetty direct. It seems in this configuration paths specified are relative to the 'working directory' rather than anything classloader-based.

Trying to find out what file path DefaultServlet would attempt without being overridden by specific path configuration was how I got in a knot. Perhaps this is an unsupported approach.

In the end I didn't understand what resource=null referred to anyway as I had very little context for what was being reported.

I do have a chip on my shoulder about error messages, but I'll keep my narky subject lines in order next time. Forgot to go back and check the bug title and build id before submitting, sorry. It's not helped by writing in 'British English' which always sounds more formal than intended. 

I'm very appreciative of the Jetty project. I have selected it as our servlet engine because it seems well engineered with minimal unnecessary complexity. Keep up the good work.
Comment 4 Greg Wilkins CLA 2011-01-10 08:21:13 EST
r2647

cheers
Comment 5 Jesse McConnell CLA 2011-09-20 15:52:18 EDT
Resolved -> Closed