Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 330419

Summary: reloading webapp duplicates StandardDescriptorProcessor
Product: [RT] Jetty Reporter: AngerClown <angerclown>
Component: serverAssignee: Jan Bartel <janb>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: janb, jetty-inbox
Version: unspecified   
Target Milestone: 7.2.x   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description AngerClown CLA 2010-11-16 21:03:05 EST
Build Identifier: 7.2.0.v20101020

Looking at JMX output in JConsole, I noticed that the web app context seems to be duplicating servlet mappings after a restart.

Running dump() just after the server has started shows this partial output:
...
 +-SessionHandler@3e4a9a7d started
    +-ConstraintSecurityHandler@6b754699 started
       +-[]
       +-/={TRACE={RoleInfo,F,C[]}}
       +-ServletHandler@13a78071 started
          +-[/]=>default{...}
          +-[*.jsp, *.jspf, *.jspx, *.xsp, *.JSP, *.JSPF, *.JSPX, .XSP]=>jsp{...}
...

After a restart, dump() returns:
+-SessionHandler@3e4a9a7d started
    +-ConstraintSecurityHandler@6b754699 started
       +-[]
       +-/={TRACE={RoleInfo,F,C[]}}
       +-ServletHandler@13a78071 started
          +-[/]=>default{...}
          +-[*.jsp, *.jspf, *.jspx, *.xsp, *.JSP, *.JSPF, *.JSPX, *.XSP]=>jsp{...}
          +-[/]=>default{...}
          +-[*.jsp, *.jspf, *.jspx, *.xsp, *.JSP, *.JSPF, *.JSPX, *.XSP]=>jsp{...}

Notice the servlet mappings are duplicated. If the webapp is reloaded again, there are 3 mappings for each servlet.

Further investigation shows that the following line in WebXmlConfiguration.configure() is to blame:
        context.getMetaData().addDescriptorProcessor(new StandardDescriptorProcessor());

Each time the app is configured (reloaded), it will add a new StandardDescriptorProcessor(). This processor is not removed in deconfigure(), so the web.xml files are processed multiple times.

Logic in other classes makes sure that the actual servlets are not loaded multiple times which is probably why this bug is not immediately apparent.

Reproducible: Always

Steps to Reproduce:
1. Create a webapp with at least 1 servlet mapping
2. Call webapp.dump()
3. Reload the webapp without stopping the server
4. Rerun webapp.dump()
Comment 1 Jan Bartel CLA 2010-11-16 22:30:46 EST
Fixed in trunk rev 2529.