Troubleshooting
Problem
Double-byte characters in business objects are not correctly encoded in SystemOut.log when using the "print BO to log" standard snippet.
Symptom
Double-byte characters in business objects are encoded incorrectly, and are written in SystemOut.log when user uses the "print BO to log" standard snippet. The SystemOut.log is written after the component uses the "print BO to log" standard snippet is executed on WebSphere Process Server.
Cause
The product is working as designed. The "print BO to log" snippet considers the BO as a binary object when writing it to the log file; The BO is declared to have "UTF-8" encoding in the beginning of the file, while the log file on windows is saved as cp1252 encoding by default.
Resolving The Problem
There are two recommendations :
1) In server log view, when viewing the BO entry with the unicode characters, user can copy the BO content to a text editor (e.g notepad ) and save the file. Then use a viewer, e.g. internet explorer, to open the file and set the encoding to be UTF-8 to view the file.
- 1a) Alternatively, use the the "Load from Server Log Directory" action in server log view and select the "UTF-8" encoding to view the log. View the log this way, the BO content will show up properly. However the rest of the log contents may not show up properly.
2) If user chooses to change the encoding of how BO is saved to the log file in the Visual Snippet:
Switch to the Java pane in the visual snippet editor and specify the encoding there, as follow :
- com.ibm.websphere.bo.BOXMLSerializer srv = (com.ibm.websphere.bo.BOXMLSerializer) new com.ibm.websphere.sca.ServiceManager().locateService("com/ibm/websphere/bo/BOXMLSerializer");
try {
commonj.sdo.Type type = input1.getType();
java.util.HashMap options = new java.util.HashMap(); <--
options.put("ENCODING", "CP1252"); <--
srv.writeDataObjectWithOptions(input1, type.getURI(), type.getName(), java.lang.System.out, options); <--
}
catch ( java.io.IOException io ) {
}
Then, the BO will be serialized as cp1252 to the log file and user will be able to view the content of the BO in the log file properly. However, the caveat of this is that it will not work on all platforms (since the log could be serialized differently on each platform) and it may cause corruption of data.
Was this topic helpful?
Document Information
Modified date:
15 June 2018
UID
swg21422452