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

Bug 351040

Summary: Wrong URL for web-app_2_5.xsd in generated ROOT webapp for Tomcat
Product: [WebTools] WTP ServerTools Reporter: Konstantin Kolinko <knst.kolinko>
Component: jst.serverAssignee: Elson Yuen <eyuen7>
Status: RESOLVED FIXED QA Contact: Elson Yuen <eyuen7>
Severity: normal    
Priority: P3 CC: cbridgha, david_williams, eyuen7, kaloyan, naci.dai, neil.hauge, raghunathan.srinivasan, shr31223, thatnitind
Version: unspecifiedFlags: eyuen7: pmc_approved? (david_williams)
eyuen7: pmc_approved? (raghunathan.srinivasan)
eyuen7: pmc_approved? (naci.dai)
eyuen7: pmc_approved? (neil.hauge)
cbridgha: pmc_approved+
eyuen7: pmc_approved? (kaloyan)
Target Milestone: 3.6 RC1   
Hardware: PC   
OS: Windows XP   
See Also: https://git.eclipse.org/r/109241
Whiteboard: PMC_approved
Attachments:
Description Flags
Patch for TomcatVersionHelper.java of org.eclipse.jst.server.tomcat.core plugin eyuen7: iplog+, eyuen7: review+

Description Konstantin Kolinko CLA 2011-07-03 23:20:28 EDT
Build Identifier: 20110615-0604

I observe this issue when running a web project deployed on Tomcat 7.0.
In this case Eclipse IDE configures a dummy ROOT webapp for Tomcat, and the problem is that web.xml file in this webapp is wrong.

The content of the file ${workspace}/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/ROOT/WEB-INF/web.xml is:
[[[
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd" version="2.5">
</web-app>
]]]

The values of xmlns attribute and xsi:schemaLocation attribute are wrong.

The correct location of web-app_2_5.xsd schema is [1] - note that there is "javaee" instead of "j2ee" in the URL. The namespace value in the xmlns attribute should also contain "javaee" - see targetNamespace value in [1].

 [1]: http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd

If Tomcat 7 is configured with "STRICT_SERVLET_COMPLIANCE" option set to true, it detects this error. Without this additional configuration the issue goes unnoticed.  Detailed steps to reproduce are below.

Reproducible: Always

Steps to Reproduce:
Using eclipse 3.7 (Indigo) for JavaEE developers,

1. download Apache Tomcat 7.0.16 
from http://tomcat.apache.org/download-70.cgi
-> Binary Distributions -> Core -> zip (apache-tomcat-7.0.16.zip),
unpack it somewhere

2. Start Eclipse IDE with a new workspace.

3. Add Tomcat 7.0 as a server runtime environment:

That is:
3.1 Go to menu Window -> Preferences, in the "Preferences" dialog
 go to Server -> Runtime Environments page,
 click "Add.." button to add a new server runtime.
3.2 In "New Server Runtime Environment" dialog
 - Select Apache -> Apache Tomcat v7.0 item,
 - click "Next >" button.
 - In "Tomcat installation directory" field:
 select the folder where you unpacked tomcat 7.0.16
 - Click "Finish" button.
3.3 You returned to the "Preferences" dialog. Press "OK" to close it.
 
4. Create a new Server

That is:
4.1 Go to "Servers" view (Window -> Show View -> Servers)
4.2 Do right-click on empty space inside the view, in popup menu select "New > Server"
4.3 Select Apache -> Tomcat v7.0 Server. Click "Next" button.
Click "Add All >>"  button to deploy the test project on the server.
Click Finish.

5. Configure Tomcat to run in "STRICT_SERVLET_COMPLIANCE" mode:

In the Project Explorer view there is a project "Servers". Find there a file named "catalina.properties" and open it for editing. Add the following line to the end of the file:

org.apache.catalina.STRICT_SERVLET_COMPLIANCE=true

Save and close the file.


6. Start the Server in the Servers view.


7. Tomcat starts, but the following error message and stack trace is printed in the Console view:

04.07.2011 6:38:24 org.apache.tomcat.util.digester.Digester error
SEVERE: Parse Error at line 23 column 19: TargetNamespace.1: Expecting namespace 'http://java.sun.com/xml/ns/j2ee', but the target namespace of the schema document is 'http://java.sun.com/xml/ns/javaee'.
org.xml.sax.SAXParseException: TargetNamespace.1: Expecting namespace 'http://java.sun.com/xml/ns/j2ee', but the target namespace of the schema document is 'http://java.sun.com/xml/ns/javaee'.
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaErr(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaError(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.constructTrees(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.findSchemaGrammar(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
	at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1543)
	at org.apache.catalina.startup.ContextConfig.parseWebXml(ContextConfig.java:1759)
	at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1266)
	at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:896)
	at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:322)
(...)

The line numbers above are for not-yet-released tomcat 7.0.17.
(7.0.16 has the same behaviour).

8. The consequence is that the ROOT webapp does not start. In the logs:

04.07.2011 6:38:24 org.apache.catalina.startup.ContextConfig configureStart
SEVERE: Marking this application unavailable due to previous error(s)

For Tomcat the absence of the ROOT webapp means that default error processing will be disabled. E.g., if you try to access http://localhost:8080/foo you will observe a blank page, instead of pretty error 404 page.


Originally I observed the issue in Eclipse Helios Service Release 2, Build id: 20110301-1815, with all current updates. It is reproducible in Eclipse Indigo Build Id: 20110615-0604 by the above steps as well.


Searching for the "http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd" string through all plugins in Eclipse Indigo for JavaEE developers finds only three files that contain this string:

 Tomcat60Handler.class
 Tomcat70Handler.class
 TomcatVersionHelper.class

in \org\eclipse\jst\server\tomcat\core\internal\ in org.eclipse.jst.server.tomcat.core_1.1.300.v20110427.jar
Comment 1 Nitin Dahyabhai CLA 2011-07-13 19:52:38 EDT
Konstantin, which step actually creates that web.xml file?
Comment 2 Konstantin Kolinko CLA 2011-07-13 20:06:25 EDT
(In reply to comment #1)
> Konstantin, which step actually creates that web.xml file?

This one:
> 6. Start the Server in the Servers view.

When the server is starting for the first time the .metadata\.plugins\org.eclipse.wst.server.core\tmp<number>\  directory is created.

The said web.xml file is wtpwebapps\ROOT\WEB-INF\web.xml inside that directory.
Comment 3 Konstantin Kolinko CLA 2013-11-12 17:41:05 EST
Any hope on fixing this issue?

The file to patch is 
http://git.eclipse.org/c/servertools/webtools.servertools.git/plain/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatVersionHelper.java

In the value of constant "DEFAULT_WEBXML_SERVLET25" there are 3 occurrences of
  http://java.sun.com/xml/ns/j2ee
All of them have to be replaced with
  http://java.sun.com/xml/ns/javaee
Comment 4 Konstantin Kolinko CLA 2013-11-12 17:45:43 EST
Created attachment 237409 [details]
Patch for TomcatVersionHelper.java of org.eclipse.jst.server.tomcat.core plugin

A patch to fix the 3 typos.
It was prepared with `svn diff --old --new`.
Comment 5 Elson Yuen CLA 2014-05-21 11:27:53 EDT
    Explain why you believe this is a stop-ship defect. Or, if it is a "hotbug" (requested by an adopter) please document it as such. 
This fix is requested by adopter via the mailing list. 

    Is there a work-around? If so, why do you believe the work-around is insufficient? 
If the "STRICT_SERVLET_COMPLIANCE" is set to true on the tomcat server configuration, the user will see an error.  The only workaround is to turn off that option which is not ideal.

    How has the fix been tested? Is there a test case attached to the bugzilla record? Has a JUnit Test been added? 
I have tested the described scenario to confirm the change fixes the problem.

    Give a brief technical overview. Who has reviewed this fix? 
Changed the incorrect default schema URL for servlet 2.5 web. This change only affect tomcat servers. Elson Yuen has reviewed the fix.

    What is the risk associated with this fix? 
The risk is low since only schema URL has been changed.
Comment 6 Elson Yuen CLA 2014-05-21 17:40:59 EDT
Changes released to 3.6.
Comment 7 Konstantin Kolinko CLA 2014-05-24 15:54:57 EDT
Thank you!

I tested the current integration build (wtp4x-I-3.6.0-20140523174643). It works correctly.
Comment 8 Eclipse Genie CLA 2017-10-11 16:42:29 EDT
New Gerrit change created: https://git.eclipse.org/r/109241