wood burning stoves*
The moose likes JBoss/WildFly and the fly likes default character set seems not work in my jboss environment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "default character set seems not work in my jboss environment" Watch "default character set seems not work in my jboss environment" New topic
Author

default character set seems not work in my jboss environment

Rainer Rettweiler
Greenhorn

Joined: Dec 07, 2009
Posts: 3
Hi.

I have a wired problem within my jboss environment.

See the following test coding:



Explanation:

Line-1: The greek character lambda is encoded in the String utf8lambda. The encoding used is explicitly given by parameter. This line of code is not dependend from any encoding properties of the envirorment.
Line-2: Prints out the name of the default character set. This is the character set used for String encoding by default, it comes from envirorment properties. It is set via java runtime parameter "-Dfile.encoding=UTF8".
Line-3: Prints out the bytes of the encoded lambda String. The method String.getBytes() without parameter should use "the plattform's default character set".
Line-4: Prints out the bytes of the encoded lambda String. The method String.getBytes(String charsetName) uses this given character set to decode the string.

The expected output of this would be:

UTF-8
bytes: -50,-69
bytes: -50,-69

Line 3 and 4 result in the same output, because the in both cases the default character set is used for decoding.
I get this output as I run this in a stand-alone java app on my unix server.

But as I run this in the jboss on on the same unix server, I get:

UTF-8
bytes: 63,63
bytes: -50,-69

The method String.getBytes() without parameter seems not to use the default character set, but mayby US-ASCII instead. Why? What can I do make my java behave as expected here?

Background to this problem is, that we are doing some webservice calls via axis, that use utf8 coded string. Special characters are scrambled, e.g. greek characters result in a small square (63). This does always happen, if String.getBytes() uses the wrong encoding. There seems to be a direct relation.

Any hints are welcome - this is very urgent - thanks a lot!

Attached you find the system properties of my environment, get with System.getProperties():


Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10142
    
165

Background to this problem is, that we are doing some webservice calls via axis, that use utf8 coded string.


Probably at the HTTP Connector level, you need to set the "URIEncoding" attribute: Connector config doc. From what i see in your logs, you are using JBoss 4.2.x. So the server.xml will be in JBOSS_HOME/server/< servername>/deploy/jboss-web.deployer


[My Blog] [JavaRanch Journal]
Rainer Rettweiler
Greenhorn

Joined: Dec 07, 2009
Posts: 3
Probably at the HTTP Connector level, you need to set the "URIEncoding" attribute


Thank you very much Jaikiran for your reponse!

But isn't this parameter only concerning URL encodig, but not content encoding of HTTP requests? Nevertheless, I tried it, but the results keep the same. Same output of my test coding (of corse) and also same results with the greek characters in the webservice calls. The receiver of the ws calls just gets a string with bytes 63,63 instead of -50,-69.

Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10142
    
165

Rainer Rettweiler wrote:
But isn't this parameter only concerning URL encodig, but not content encoding of HTTP requests?

Oops, i misunderstood your earlier post as web requests.

Rainer Rettweiler wrote:
Nevertheless, I tried it, but the results keep the same. Same output of my test coding (of corse) and also same results with the greek characters in the webservice calls.



Do you have any relevant piece of code on how you invoke these webservices? I don't have much experience around webservices, so the code might give some hints.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

I would rather ask why your code needs to convert characters to bytes in the first place. Or if there's some reason, I would ask why you are forced to use the system's default character set.
Rainer Rettweiler
Greenhorn

Joined: Dec 07, 2009
Posts: 3
Paul Clapham wrote:I would rather ask why your code needs to convert characters to bytes in the first place. Or if there's some reason, I would ask why you are forced to use the system's default character set.


My code does not have to convert strings into bytes. I just put this few test lines of code to show where I guess the problem lies.

The webservice call we do is:

public java.lang.String sendSMS(java.lang.String phoneNumber, java.lang.String message) throws java.rmi.RemoteException;

We use a web service client generated with the eclipse wizard, using axis1, selecting bottom-up-java-bean-web-service-client. All classes concerning web service are generated with this wizard. The call takes a string "message". This string needs to contain greek characters. I see no possibility to explicitly set the encoding here.

When I debug the HTTP request made by sendSMS, I see that the greek characters are defekt already in this HTTP request. This is no problem on the web service host side. My HTTP request is already wrong. To me it looks like somewhere in the request generation the default encoding is used, but the wrong one. Therefore my test with String.getBytes().

But this is only the case on my unix server. The same binaries run perfekt on my PC. Same jboss, same jdk, same application ear.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: default character set seems not work in my jboss environment