每次启动glassfish服务器时我都会遇到这个问题。服务器启动正常,但由于此错误,我的记录器输出不会记录到server.log文件。这似乎是glassfish版本2.1中的一个错误。因为我正在运行的应用程序不支持更高版本,所以我无法转移到更高版本。当从MyEclipse IDE启动glassfish并建议从IDE停止服务器然后从命令行重新启动它时,大多数在线帖子报告此错误。我总是从终端启动我的服务器仍然得到这个错误。我真的很困惑,没有查看我的日志就无法进行太多调试。有人可以建议一个合适的解决方法吗?
这真烦人。帮助将非常感激。 提前谢谢。
-client
-XX:+UnlockDiagnosticVMOptions
-XX:MaxPermSize=192m
-Xmx512m
-XX:NewRatio=2
-XX:+LogVMOutput
-XX:LogFile=/home/aakanksha/softwares/glassfish/domains/visionael/logs/jvm.log
-cp
/home/aakanksha/softwares/glassfish/lib/jhall.jar:/home/aakanksha/softwares/glassfish/lib/appserv-launch.jar
com.sun.enterprise.server.PELaunch
start
recursive call into SystemOutandErrhandler
java.lang.RuntimeException: recursivecall
at com.sun.enterprise.server.logging.SystemOutandErrHandler$LoggingByteArrayOutputStream.flush(SystemOutandErrHandler.java:359)
at java.io.PrintStream.write(PrintStream.java:449)
at com.sun.enterprise.server.logging.SystemOutandErrHandler$LoggingPrintStream.write(SystemOutandErrHandler.java:293)
at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:220)
at sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:281)
at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:124)
at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:134)
at java.io.OutputStreamWriter.write(OutputStreamWriter.java:220)
at java.io.Writer.write(Writer.java:157)
at java.util.logging.StreamHandler.publish(StreamHandler.java:209)
at java.util.logging.ConsoleHandler.publish(ConsoleHandler.java:105)
at java.util.logging.Logger.log(Logger.java:573)
at java.util.logging.Logger.doLog(Logger.java:598)
at java.util.logging.Logger.log(Logger.java:621)
at com.sun.enterprise.server.logging.SystemOutandErrHandler$LoggingByteArrayOutputStream.flush(SystemOutandErrHandler.java:368)
at java.io.PrintStream.write(PrintStream.java:449)
at com.sun.enterprise.server.logging.SystemOutandErrHandler$LoggingPrintStream.write(SystemOutandErrHandler.java:293)
at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:220)
at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:290)
at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:294)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:140)
at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229)
at java.util.logging.StreamHandler.flush(StreamHandler.java:242)
at java.util.logging.ConsoleHandler.publish(ConsoleHandler.java:106)
at java.util.logging.Logger.log(Logger.java:573)
at java.util.logging.Logger.doLog(Logger.java:598)
at java.util.logging.Logger.log(Logger.java:662)
at com.sun.enterprise.server.ApplicationServer.printStartupInfo(ApplicationServer.java:618)
at com.sun.enterprise.server.ApplicationServer.onInitialization(ApplicationServer.java:170)
at com.sun.enterprise.server.ondemand.OnDemandServer.onInitialization(OnDemandServer.java:103)
at com.sun.enterprise.server.PEMain.run(PEMain.java:399)
at com.sun.enterprise.server.PEMain.main(PEMain.java:336)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:622)
at com.sun.enterprise.server.PELaunch.main(PELaunch.java:415)
答案 0 :(得分:0)
从GLASSFISH-6164开始,解决方法列为:
如果我在调用之前将System.out和System.err重置为指向临时文件 readConfiguration并不要将它们重置为指向记录器然后一切 工作正常。
您可以创建一个自定义LogManager,在调用readConfiguration时执行该变通办法。然后在启动时使用java.util.logging.manager系统属性安装自定义LogManager。
public class ConsoleLogManager extends LogManager {
@Override
public void readConfiguration() throws IOException, SecurityException {
final PrintStream out = System.out;
final PrintStream err = System.err;
System.setOut(off());
try {
System.setErr(off());
try {
super.readConfiguration();
} finally {
System.setErr(err);
}
} finally {
System.setOut(out);
}
}
@Override
public void readConfiguration(InputStream ins) throws IOException, SecurityException {
final PrintStream out = System.out;
final PrintStream err = System.err;
System.setOut(off());
try {
System.setErr(off());
try {
super.readConfiguration(ins);
} finally {
System.setErr(err);
}
} finally {
System.setOut(out);
}
}
@Override
public void reset() throws SecurityException {
final PrintStream out = System.out;
final PrintStream err = System.err;
System.setOut(off());
try {
System.setErr(off());
try {
super.reset();
} finally {
System.setErr(err);
}
} finally {
System.setOut(out);
}
}
private static PrintStream off() {
return new PrintStream(new ByteArrayOutputStream());
}
}
另一种解决方法是包装System.out和System.in打印流,并在检测到重入时不执行任何操作。您可以使用自定义LogManager来安装它们。