• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Unicode convert problem with Jboss in Linux

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have faced with an issue where UTF-8 characters are not correctly formatted ONLY in the Jboss (jboss-5.1.0.GA-3) instance running on Linux.

For an instance: BORĂ…S is converted to BOR?S at Linux jboss instance.

When I copy and configure the same jboss instance to run at Windows (SP3) it works perfectly.

Also I have change the default setting in Linux by including JAVA_OPTS=-Dfile.encoding=UTF-8 in .bashrc and run.sh files.

Any suggestions or workarounds ?
 
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are your JSPs, HTMLs, property files etc. saved with the UTF-8 encoding ??
 
isuru chamarasinghe
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Larsen,

Thank you for the prompt reply.

I have exposed a jsp to upload a xml file using the post method. I will be obtaining the file as a FormFile using struts in the Action class as follwos:

FormFile file = theForm.getFile();

Secondly, I retrieve the file data as byte array

byte[] buf = file.getFileData();

When I view the result of above buf variable at runtime it is clear that the unicode has been converted to a non recognized character.
 
Rene Larsen
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try put URIEncoding="UTF-8" in the HTTP connector - in the file JBOSS/server/default/deploy/jbossweb.sar/server.xml

Like this:
 
isuru chamarasinghe
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I include the

URIEncoding="UTF-8"

attribute to HTTP Connector tag in jbossweb.sar/server.xml and restart the instance. No luck. same result.
 
Rene Larsen
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And you have tried all these steps too ??

1) struts-config:

2) included a jsp page directive:

3) included a meta tag within the html page itself:


What happens IF the uploaded file has the right encoding - UTF-8 ?? and not an unknown randomly type.
 
isuru chamarasinghe
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Larsen,

I have tired out all those but same result thank you very much for the guidance. Now I have identified the problem is on the server side and not in the view.

I realize that by trying to save the byte array obtain from the File into an xml file in jboss tmp folder and it contains the correct Unicode.

In my scenario the uploaded file is straight away sent to a message queue to be processed by an MDB. So the flow is as follow:

Upload the XML ---> Obtain the byte[] from the file ---> put it on a JMS queue ---> picked by a MDB to process

When the posted Message is cast to a TextMessage and process, the Unicode is been incorrectly converted.

Is there is any specific configuration I have to do in the JMS queue in order to convert it to the correct Unicode?
 
Rene Larsen
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On google I found this answer: http://stackoverflow.com/questions/2973576/encoding-a-jms-textmessage

Maybe it also works on JBoss (it should work there too)
 
isuru chamarasinghe
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No Larsen,

It doesn't work with Jboss MQ.

I bedbug the Message Listener and found out that JBossTextMessage.getText() contains the file data with incorrect Unicode characters.

Any way of specifying the type of the Message before putting it to the Jboss MQ?
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JBoss AS-5 does not use JBoss MQ. It uses JBoss Messaging. Are you sure you are looking at the right classes?
 
isuru chamarasinghe
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes it is Jboss Messaging as Jaikiran said but do you think this will have an effect on this Unicode issue ?
 
isuru chamarasinghe
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Finally I was able to find a solution, BUT the solution is still a blackbox. If anyone have the answer to WHY it has failed/successful please update the thread. Till it is solved I will let the thread open.

Solution at a glance :
1. Captured the file contents as a byte arry and wrote it to a xml file in jboss tmp folder using FileOutputStream
2. When posting to the jboss Message queue, I used the explicitly wrote xml file (1st step) using a FileInputStream as a byte array and pass it as the Message body.

Code example:

View: JSP page with a FormFile

Controller Class :UploadAction.java



Foot Note: I think it is something to do with the Linux/Windows default file saving type. eg: Windows default : ANSI.
reply
    Bookmark Topic Watch Topic
  • New Topic