Bug 46908

Summary: tomcat-users.xml has invalid encoding "cp1252" when using endorsed library xercesImpl.jar
Product: Tomcat 6 Reporter: Stuart <apache>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Severity: normal CC: apache
Priority: P2    
Version: 6.0.18   
Target Milestone: default   
Hardware: PC   
OS: Windows Vista   

Description Stuart 2009-03-24 22:41:53 UTC
tomcat-users.xml has invalid encoding "cp1252" when using endorsed library xercesImpl.jar when tomcat is run for the first time.

(in tomcat.6.0.16 the default encoding for the file was utf-8... now for tomcat.6.0.18 it is cp1252)

We have an installation process for our software which: 
1. Installs our software
2. Fires up the windows installation for tomcat.6.0.18
3. configures the endorsed java options by modifying the registry setting for tomcat  (ie -Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation\Tomcat 6.0\endorsed)
4. copies the endorsed jar files to the endorsed directory
5. deploys our application's war file to the webapps directory.
6. attempts to start tomcat

The generated exception is:
INFO: Starting Servlet Engine: Apache Tomcat/6.0.18
Mar 25, 2009 4:06:37 PM org.apache.tomcat.util.digester.Digester fatalError
SEVERE: Parse Fatal Error at line 1 column 40: Invalid encoding name "cp1252".
org.xml.sax.SAXParseException: Invalid encoding name "cp1252".
	at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)

My workaround for this problem is to deploy a copy of tomcat-users.xml file with the encoding set to "utf-8" to the conf directory before tomcat is attempted to be started. (ie between steps 5 and 6 above).  Once tomcat is started, this file is overwritten anyway.
Comment 1 Mark Thomas 2009-03-25 10:03:56 UTC
The change to cp1252 is as a result of bug 45332.

When you use xerces via the endorsed mechanism, the feature http://apache.org/xml/features/allow-java-encodings is false so cp1252 isn't recognised.

I'll look at using the IANA names.
Comment 2 Mark Thomas 2009-03-25 10:55:47 UTC
A fix has been made in trunk and proposed for 6.0.x.

I took a different approach (which will only work with xerces) that tries to configure the xml parser to support the java encoding names.
Comment 3 Mark Thomas 2009-05-22 08:00:07 UTC
This has been fixed in 6.0.x and will be included in 6.0.21 onwards.