Reputation: 2169
I am developing a Servlet which uses a POST to send the information. I am getting an exception depending where the servlet is deployed. If I deploy on a local JBoss EAP 7 it works like a charm. But, if I deploy into a remote server (JBoss EAP 7 too) i am getting the following error:
CODE
final InputStream is = new ByteArrayInputStream(xml);
doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(is);
ERROR
<message>
Failed to load XML: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Byte no válido 2 de la secuencia UTF-8 de 4 bytes
~ôJ뢺ÞjX³jwh•ªkyø«™§¬‚†Ú~*æiÊ+x„ÅÇ©¶*'ºè©`zw«j¹Z~*æip(Ú½©Z </message>
For more information the servlet has a jboss-deployment-structure.xml
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
<deployment>
<dependencies>
<module name="javax.api"/>
<module name="org.apache.santuario.xmlsec"/>
<module name="org.apache.xerces" />
<system export="true">
<paths>
<path name="com/sun/org/apache/xerces/internal/dom"/>
</paths>
</system>
</dependencies>
</deployment>
</jboss-deployment-structure>
Where the xerces library is implicated. I don´t understand if my problem is related to that xml , or I should change some encoding in the server/servlet code. Thnaks in advance.
Upvotes: 0
Views: 548
Reputation: 2707
Badulake,
What you are hitting looks like a encoding issue. When you don't specify encoding while converting a byte array to Java string, JVM uses the default encoding of the platform. In most cases the default encoding is utf-8 and that works great. However I have seen many OS installations where the encoding is simply US-ASCII.
If this is your issue, you can either set the default encoding as a JVM option on the Java command line or change the encoding on the platform to utf-8.
Upvotes: 1