Why does running a MATLAB Builder for Java 1.1 (R2007a) servlet and a non-MATLAB servlet simultaneously in Tomcat (Unix) prevent correct print stream output?

I have a non-MATLAB Java servlet that is running on a Tomcat server on a Unix machine. This servlet writes to System.out and the written output appears as expected.
When deploying and running a MATLAB-compiled Builder for Java component as a servlet alongside the non-MATLAB servlet, the output as written by the first servlet are neither appearing correctly nor being captured in any log files.

 Accepted Answer

This issue only appears when deploying MATLAB Builder for Java components on Unix machines. MATLAB Compiler Runtime (MCR) initialization modifies the Java output streams to allow built-in text printing functions (e.g., DIARY) to work properly.
To work around this issue, in your Java code which accesses the MATLAB Builder for Java component, save the output streams, initialize the first MCR based component, and then reset the output streams as follows:
PrintStream out = System.out;
PrintStream err = System.err;
FooComponent f = new FooComponent();
System.setOut(out);
System.setErr(err);

More Answers (0)

Products

Release

R2007a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!