Embedded Tomcat 5.5 and Java 1.6 PSA

danielh @ 12:28 pm November 27, 2007

Just a public service announcement, my guess is this particular circumstance will be pretty rare.

If you’ve been running embedded tomcat under a wrapper class you might have some problems when you go to java 1.6 and you watch stdin and stdout.

We ran an embedded instance in our application with a wrapper that communicates via stdin and stdout to our controlling application, piping if you will. It appears that unless you define a root logger the embedded instance will redirect stdout to a null output handler which means you no longer get output. This will mean if you’re writing status outputs to which another application is listening to it will appear to just stop.

try {
    FileHandler fileHandler = new FileHandler(File.createTempFile("embedded-tomcat", ".log").getAbsolutePath(), true);
    fileHandler.setFormatter(new SimpleFormatter());
    logger.addHandler(fileHandler);
    logger.setLevel(Level.ALL);
} catch (IOException e) {
   e.printStackTrace();
}

Also under java 1.6, make sure you redirect standard in when invoking java from a .net 2 process. This previously worked under 1.5 but probably shouldn’t have. My guess is java 1.6 ‘fixed’ a lot of stdin, out stream which meant coincidental behaviour that previously worked no longer does.

See http://www.mail-archive.com/users@tomcat.apache.org/msg36244.html for a thread where someone else was having a similar problem.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment