/    Sign up×
Community /Pin to ProfileBookmark

In tomcat6, System.err.println or System.out.println don’t seem to work

I know I’m bound to be doing something stupid. This is code I haven’t worked on in about two years, then on tomcat 5, and I set up a brand new tomcat6 server and began to work on it again.

Note the log.write’s in here, and the initDB, initAppInfo, etc.:

[code]
public class AppInitializer implements ServletContextListener
{
public void contextInitialized(ServletContextEvent e)
{
log.write(“n************nAppInitializer::ContextInitialized entrance”);

ServletContext sc= e.getServletContext();
log.write(“AppInitializer::ContextInitializer: context name='” + sc.getServletContextName() + “‘”);
log.write(“AppInitializer::ContextInitializer: context path='” + sc.getContextPath() + “‘”);

// Order is important!! Need the database
initDB(sc);
initAppInfo(sc);
initXRef(sc);

log.write(“AppInitializer::Seems to have run OKn*******************n”);
}
[/code]

Here is log.write:

[code]
public void write(String msg) // Need to do more with this later
{ // (e. g., timestamp, logging levels, etc.)
System.out.println(“n************ In write **************n”);
System.err.println(“n************ In write **************n”);
if(msg == null || msg.length() == 0)
{
System.err.println(“<null>”);
return;
}
if(msg.substring(0, 1).equals(“n”) || (msg.length() > 5 && msg.substring(0, 4).equals(“****”)) || !AddTs)
System.err.println(msg);
else
System.err.println(getTimestamp() + “: ” + msg);
System.err.flush();
}
[/code]

And, here’s catalina*.log:

[quote]

Aug 4, 2009 9:03:34 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Aug 4, 2009 9:03:34 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 753 ms
Aug 4, 2009 9:03:34 PM org.apache.catalina.users.MemoryUserDatabase save
WARNING: User database is not persistable – no write permissions on directory
Aug 4, 2009 9:03:34 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Aug 4, 2009 9:03:34 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.18
Aug 4, 2009 9:03:35 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class utils
.AppInitializer
java.lang.NullPointerException
at dbMgr.dbUtils.dbGetMaxSessions(dbUtils.java:99)
at utils.AppInitializer.initAppInfo(AppInitializer.java:92)
at utils.AppInitializer.contextInitialized(AppInitializer.java:38)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:
3843)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:7
91)
at org.apache.catalina.core.ContainerBase.access$000(ContainerBase.java:123)
at org.apache.catalina.core.ContainerBase$PrivilegedAddChild.run(ContainerBase.
java:145)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:769)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:627)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553
)

[/quote]

You can see that it got an exception in initAppInfo (third line into exception print), but none of the prior System.err.println or System.out.println’s printed.

TIA,
anw

to post a comment
Java

1 Comments(s)

Copy linkTweet thisAlerts:
@anwauthorAug 08.2009 — New data point: when I set the handler in my logging.properties file thusly,
<i>
</i>org.apache.catalina.core.ContainerBase.[Catalina].[info-dev].[/infoisland].level = ALL
org.apache.catalina.core.ContainerBase.[Catalina].[info-dev].[/infoisland].handlers = java.util.logging.ConsoleHandler

I get 0 bytes in the info-dev log (which used to have the aforementioned expception in it). Where is my console going?
×

Success!

Help @anw spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...