net.sf.ehcache.CacheException: Error configuring from input stream. Initial cause was Invalid byte 1 of 1-byte UTF-8 sequence.

Terracotta Project Issue Tracker | Fiona OShea | 6 years ago
  1. 0

    Adding Jira for John Serock while his Jira setup is being fixed. When attempting to run an application, which uses Ehcache 1.5.0, on z/OS, an exception was thrown that was similar to this: net.sf.ehcache.CacheException: Error configuring from input stream. Initial cause was Invalid byte 1 of 1-byte UTF-8 sequence. at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:155) at net.sf.ehcache.CacheManager.parseConfiguration(CacheManager.java:266) at net.sf.ehcache.CacheManager.init(CacheManager.java:220) at net.sf.ehcache.CacheManager.<init>(CacheManager.java:202) at my.EhcacheTest.run(EhcacheTest.java:41) at my.EhcacheTest.main(EhcacheTest.java:25) Caused by: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 1 of 1-byte UTF-8 sequence. at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(Unknown Source) at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.arrangeCapacity(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.skipString(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(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 javax.xml.parsers.SAXParser.parse(Unknown Source) at javax.xml.parsers.SAXParser.parse(Unknown Source) at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:153) ... 5 more The default platform encoding on the z/OS system is IBM1047, the Latin-1 character set for EBCDIC hosts. The ehcache.xml configuration file on z/OS is UTF-8 encoded. The exception appears to be caused by the net.sf.ehcache.config.ConfigurationFactory's translateSystemProperties method. The Ehcache 1.5.0 version of the method is shown below: /** * Translates system properties which can be added as tokens to the config file using ${token} syntax. * <p/> * So, if the config file contains a character sequence "multicastGroupAddress=${multicastAddress}", and there is a system property * multicastAddress=230.0.0.12 then the translated sequence becomes "multicastGroupAddress=230.0.0.12" * * @param inputStream * @return a translated stream */ private static InputStream translateSystemProperties(InputStream inputStream) throws IOException { StringBuffer stringBuffer = new StringBuffer(); int c; while ((c = inputStream.read()) != -1) { stringBuffer.append((char) c); } String configuration = stringBuffer.toString(); Set tokens = extractPropertyTokens(configuration); Iterator tokenIterator = tokens.iterator(); while (tokenIterator.hasNext()) { String token = (String) tokenIterator.next(); String leftTrimmed = token.replaceAll("\\$\\{", ""); String trimmedToken = leftTrimmed.replaceAll("\\}", ""); String property = System.getProperty(trimmedToken); if (property == null) { if (LOG.isDebugEnabled()) { LOG.debug("Did not find a system property for the " + token + " token specified in the configuration.Replacing with \"\""); } } else { configuration = configuration.replaceAll("\\$\\{" + trimmedToken + "\\}", property); if (LOG.isDebugEnabled()) { LOG.debug("Found system property value of " + property + " for the " + token + " token specified in the configuration."); } } } return new ByteArrayInputStream(configuration.getBytes()); } The method (1) reads bytes from an input stream and creates a string from the bytes, (2) translates any system properties found in the string, and (3) converts the string to bytes and creates a input stream using the bytes. When the string is converted to bytes by the String.getBytes() method (i.e., configuration.getBytes() on the last line of the method), the default platform encoding is used to create the byte sequence. Because the default platform encoding was IBM1047, the String.getBytes() method returned an IBM1047 byte sequence instead of a UTF-8 byte sequence. Because the ehcache.xml configuration file did not contain an XML prologue specifying an encoding other than UTF-8, the SAX parser threw the MalformedByteSequenceException when it determined that the bytes in the input stream did not comprise a valid UTF-8 sequence.

    Terracotta Project Issue Tracker | 6 years ago | Fiona OShea
    net.sf.ehcache.CacheException: Error configuring from input stream. Initial cause was Invalid byte 1 of 1-byte UTF-8 sequence.
  2. 0

    Adding Jira for John Serock while his Jira setup is being fixed. When attempting to run an application, which uses Ehcache 1.5.0, on z/OS, an exception was thrown that was similar to this: net.sf.ehcache.CacheException: Error configuring from input stream. Initial cause was Invalid byte 1 of 1-byte UTF-8 sequence. at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:155) at net.sf.ehcache.CacheManager.parseConfiguration(CacheManager.java:266) at net.sf.ehcache.CacheManager.init(CacheManager.java:220) at net.sf.ehcache.CacheManager.<init>(CacheManager.java:202) at my.EhcacheTest.run(EhcacheTest.java:41) at my.EhcacheTest.main(EhcacheTest.java:25) Caused by: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 1 of 1-byte UTF-8 sequence. at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(Unknown Source) at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.arrangeCapacity(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.skipString(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(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 javax.xml.parsers.SAXParser.parse(Unknown Source) at javax.xml.parsers.SAXParser.parse(Unknown Source) at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:153) ... 5 more The default platform encoding on the z/OS system is IBM1047, the Latin-1 character set for EBCDIC hosts. The ehcache.xml configuration file on z/OS is UTF-8 encoded. The exception appears to be caused by the net.sf.ehcache.config.ConfigurationFactory's translateSystemProperties method. The Ehcache 1.5.0 version of the method is shown below: /** * Translates system properties which can be added as tokens to the config file using ${token} syntax. * <p/> * So, if the config file contains a character sequence "multicastGroupAddress=${multicastAddress}", and there is a system property * multicastAddress=230.0.0.12 then the translated sequence becomes "multicastGroupAddress=230.0.0.12" * * @param inputStream * @return a translated stream */ private static InputStream translateSystemProperties(InputStream inputStream) throws IOException { StringBuffer stringBuffer = new StringBuffer(); int c; while ((c = inputStream.read()) != -1) { stringBuffer.append((char) c); } String configuration = stringBuffer.toString(); Set tokens = extractPropertyTokens(configuration); Iterator tokenIterator = tokens.iterator(); while (tokenIterator.hasNext()) { String token = (String) tokenIterator.next(); String leftTrimmed = token.replaceAll("\\$\\{", ""); String trimmedToken = leftTrimmed.replaceAll("\\}", ""); String property = System.getProperty(trimmedToken); if (property == null) { if (LOG.isDebugEnabled()) { LOG.debug("Did not find a system property for the " + token + " token specified in the configuration.Replacing with \"\""); } } else { configuration = configuration.replaceAll("\\$\\{" + trimmedToken + "\\}", property); if (LOG.isDebugEnabled()) { LOG.debug("Found system property value of " + property + " for the " + token + " token specified in the configuration."); } } } return new ByteArrayInputStream(configuration.getBytes()); } The method (1) reads bytes from an input stream and creates a string from the bytes, (2) translates any system properties found in the string, and (3) converts the string to bytes and creates a input stream using the bytes. When the string is converted to bytes by the String.getBytes() method (i.e., configuration.getBytes() on the last line of the method), the default platform encoding is used to create the byte sequence. Because the default platform encoding was IBM1047, the String.getBytes() method returned an IBM1047 byte sequence instead of a UTF-8 byte sequence. Because the ehcache.xml configuration file did not contain an XML prologue specifying an encoding other than UTF-8, the SAX parser threw the MalformedByteSequenceException when it determined that the bytes in the input stream did not comprise a valid UTF-8 sequence.

    Terracotta Project Issue Tracker | 6 years ago | Fiona OShea
    net.sf.ehcache.CacheException: Error configuring from input stream. Initial cause was Invalid byte 1 of 1-byte UTF-8 sequence.
  3. 0

    generate pdf with apex listener 2.0

    Oracle Community | 4 years ago | 517154
    com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 1 of 1-byte UTF-8 sequence.
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    MalformedByteSequenceException running standalone

    Eclipse Bugzilla | 6 years ago | ed
    java.lang.RuntimeException: Problems running workflow GeneratePivotModel: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 1 of 1-byte UTF-8 sequence.
  6. 0

    Selenium Web Driver : MalformedByteSequenceException Invalid byte 2 of 2-byte UTF-8 sequence

    Stack Overflow | 4 years ago | KingJames
    com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 2 of 2-byte UTF-8 sequence.

    4 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException

      Invalid byte 1 of 1-byte UTF-8 sequence.

      at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte()
    2. Java RT
      SAXParser.parse
      1. com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(Unknown Source)
      2. com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(Unknown Source)
      3. com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(Unknown Source)
      4. com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.arrangeCapacity(Unknown Source)
      5. com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.skipString(Unknown Source)
      6. com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
      7. com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
      8. com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
      9. com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
      10. com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
      11. com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
      12. javax.xml.parsers.SAXParser.parse(Unknown Source)
      13. javax.xml.parsers.SAXParser.parse(Unknown Source)
      13 frames
    3. Ehcache
      CacheManager.<init>
      1. net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(ConfigurationFactory.java:153)
      2. net.sf.ehcache.CacheManager.parseConfiguration(CacheManager.java:266)
      3. net.sf.ehcache.CacheManager.init(CacheManager.java:220)
      4. net.sf.ehcache.CacheManager.<init>(CacheManager.java:202)
      4 frames
    4. my
      EhcacheTest.main
      1. my.EhcacheTest.run(EhcacheTest.java:41)
      2. my.EhcacheTest.main(EhcacheTest.java:25)
      2 frames