报错:
2013-07-05 10:59:49,111 ERROR [STDERR] [Fatal Error] :1:38: Invalid encoding name "UTF8".
2013-07-05 10:59:49,113 ERROR [STDERR] org.xml.sax.SAXParseException: Invalid encoding name "UTF8".
2013-07-05 10:59:49,115 ERROR [STDERR] at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
2013-07-05 10:59:49,116 ERROR [STDERR] at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
2013-07-05 10:59:49,117 ERROR [STDERR] at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
查看源码:
String encode = System.getProperty("file.encoding");
……
ByteArrayInputStream XMLFile = new ByteArrayInputStream(mxml.getBytes());
Document doc = builder.parse(XMLFile);
boot.log发现:23:11:31,291 DEBUG [ServerInfo] file.encoding: 8859_1
而另一台编码正常的机器是:22:59:13,351 DEBUG [ServerInfo] file.encoding: UTF8
file.encoding编码不是UTF8,需要修改;
修改/etc/profile,增加;
LC_ALL=en_US.utf8
LC_CTYPE=en_US.utf8
LANG=en_US.utf8
OUTPUT_CHARSET=en_US.utf8
LESSCHARSET='en_US.utf8'
export LC_ALL LC_CTYPE LANG OUTPUT_CHARSET LESSCHARSET LANG
命令行输入:locale,打印当前编码设置,没有warning什么的就是正常了;
重启JBOSS,编码显示正常;