views:

85

answers:

1

This question contains java and ruby. I have a java program that I make a call to from ruby.

This code works under merb perfectly without any modifications.

This code will work under irb perfectly by setting $KCODE="UTF8".

For the life of me I can not get it to work under phusion passenger -- this is a problem since our production server is under passenger but I spend most of my time with mongrel or something on my dev machine.

The setup is extremely simple.

Here is the java code: import java.io.; import java.util.;

public class Simple {

    public static void main(String[] args) throws Exception {
      System.out.println("Ç");
    }

}

now here is the ruby code:

IO.popen("java -cp \"/home/me/pass\" Simple") do |f| @blah = f.read end

when ran under passenger/merb you should be able to do a Merb.logger.error(@blah) and get the EXACT same testdata -- like I said this works fine under merb and fine under irb if you set the KCODE but it does not work under passenger

UPDATE -- simplified everything

+1  A: 

The issue may be that the environment into which the java sub-process is launched is not correctly configured. A brute-force approach is to inject environment variables using the ENV hash. As an example:

ENV['LC_CTYPE'] = 'en_US.UTF-8'

You may also have to write a wrapper for your Java program that establishes the correct environment and works from there, or perhaps a modification to the Java program itself that forces UTF8 instead of reading the environment.

tadman
fuck yes!!!! dood -- I owe you a key!
feydr
err... I owe you a key -- nxt time I'm in Canada
feydr