users@glassfish.java.net

FODC0002: java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8

From: <glassfish_at_javadesktop.org>
Date: Sun, 15 Aug 2010 16:09:31 PDT

Hi All,

I am getting the following error when reading secondary xml documents using document() in XSLT 2.0 stylesheet from within an EJB (Glassfish 2.1) container:

[b]Recoverable error on line 8
  FODC0002: java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 sequence.[/b]

The transformation snippet in Java is as follows:

      TransformerFactory transformerFactory = new net.sf.saxon.TransformerFactoryImpl();
      transformerFactory.setAttribute("http://saxon.sf.net/feature/sourceParserClass","org.apache.xml.resolver.tools.ResolvingXMLReader");

      FileInputStream stylesheet = new FileInputStream("C:/stylesheet.xsl");
      Transformer transformer = transformerFactory.newTransformer(new StreamSource(stylesheet));
      JDOMSource source = new JDOMSource(mainJDomDocument);
      JDOMResult result = new JDOMResult();

      transformer.transform(source, result);

The relevant lines in C:/stylesheet.xsl is:

 1 <?xml version="1.0" encoding="ISO-8859-1"?>
  2 <xsl:stylesheet version="2.0"
  3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  4 xmlns:xs="http://www.w3.org/2001/XMLSchema"
  5 exclude-result-prefixes="ns">
  6
  7 <xsl:template match="/">
  8 <xsl:apply-templates select="document('file:///C:/car.xml'))/catalog">
         ...........
 15 </xsl:apply-templates>
 16 </xsl:template>
 17
 18 .........

All xml documents have been encoded with UTF-8. Changing encoding on C:/stylesheet.xsl to UTF-8 did not make any difference. This application have been working fine until they are moved in EJB 3.0 (Glassfish 2.1) container. It appears that it is the EJB container which has overrided the way these secondary documents have been read using a different method that checks the encoding.

I am running JDK 1.6.0_17, Netbeans 6.7, XSLT 2.0 (Saxon 9.1), JDOM 1.1 on Windows XP.

Any suggestion would be appreciated.

Thanks a lot,

Jack
[Message sent by forum member 'htran_888']

http://forums.java.net/jive/thread.jspa?messageID=480253