Solved

Writing to Tomcat Log and Serialize Bean

Posted on 2004-10-14
4
515 Views
Last Modified: 2007-12-19
1. Runtime Tomcat errors are placed into an appropriate
log file for the day under TOMCAT_HOME/logs. How do I
write exceptions that I catch from my code. Write now
they are written to System.out.println(); And the
System.out.println is my Tomcat Terminal, which is not very
big and will not hold a day's worth.

2. I have implemented Serializable and Runnable for a class
that I use as a bean in a jsp page. I call a function of
the class in the jsp page where i pass in the request
object. The class's function takes it as an argument
of HttpServletRequestWrapper. Though everything works
smoothly, Tomcat fails to ever make the class serializable.
The log below is yelling that it has something to do with
HttpServletRequestWrapper, I realize that it cannot be serializable.
The j2se documentation for serializable says that in this case
I should override
private void writeObject(java.io.ObjectOutputStream out)
     throws IOException
 private void readObject(java.io.ObjectInputStream in)
     throws IOException, ClassNotFoundException;


can someone elaborate?

Code for the jsp that uses class: http://www.uvm.edu/~nspence/exportsStatus.jsp
Code for the class: http://www.uvm.edu/~nspence/exportsServlet.java

Here is a log of the Serializable problem

2004-10-14 11:25:38 StandardManager[] Cannot serialize session attribute exports for session 8C519941DA39436D42D5CD0F89B5685C
java.io.NotSerializableException: javax.servlet.http.HttpServletRequestWrapper
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
      at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1332)
      at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1304)
      at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1247)
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
      at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
      at org.apache.catalina.session.StandardSession.writeObject(StandardSession.java:1441)
      at org.apache.catalina.session.StandardSession.writeObjectData(StandardSession.java:880)
      at org.apache.catalina.session.StandardManager.unload(StandardManager.java:536)
      at org.apache.catalina.session.StandardManager.stop(StandardManager.java:691)
      at org.apache.catalina.core.StandardContext.reload(StandardContext.java:2462)
      at org.apache.catalina.loader.WebappLoader$WebappContextNotifier.run(WebappLoader.java:1369)
      at java.lang.Thread.run(Thread.java:534)

2004-10-14 11:25:43 StandardManager[] IOException while loading persisted sessions: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: javax.servlet.http.HttpServletRequestWrapper
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: javax.servlet.http.HttpServletRequestWrapper
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1278)
      at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1845)
      at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1769)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
      at org.apache.catalina.session.StandardSession.readObject(StandardSession.java:1371)
      at org.apache.catalina.session.StandardSession.readObjectData(StandardSession.java:863)
      at org.apache.catalina.session.StandardManager.load(StandardManager.java:440)
      at org.apache.catalina.session.StandardManager.start(StandardManager.java:655)
      at org.apache.catalina.core.StandardContext.reload(StandardContext.java:2579)
      at org.apache.catalina.loader.WebappLoader$WebappContextNotifier.run(WebappLoader.java:1369)
      at java.lang.Thread.run(Thread.java:534)
Caused by: java.io.NotSerializableException: javax.servlet.http.HttpServletRequestWrapper
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
      at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1332)
      at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1304)
      at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1247)
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
      at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
      at org.apache.catalina.session.StandardSession.writeObject(StandardSession.java:1441)
      at org.apache.catalina.session.StandardSession.writeObjectData(StandardSession.java:880)
      at org.apache.catalina.session.StandardManager.unload(StandardManager.java:536)
      at org.apache.catalina.session.StandardManager.stop(StandardManager.java:691)
      at org.apache.catalina.core.StandardContext.reload(StandardContext.java:2462)
      ... 2 more
0
Comment
Question by:zania22
  • 2
  • 2
4 Comments
 
LVL 1

Author Comment

by:zania22
ID: 12309925
I realize that I cannot pass into my class the request object from the jsp. I must read the parameters and them pass then in, also have a function that tests a boolean so that the parameters are not read more than once. I must also add stuff to my session object as I am keeping a shoping cart like array of results,in the jsp. I attempt to do that in the class file also and it throws a null pointer exception when calling the passed in request object's getSession() function.
0
 
LVL 1

Author Comment

by:zania22
ID: 12309970
Any thoughts about how to write to Tomcat's currernt(for the day) log file
0
 
LVL 1

Accepted Solution

by:
Celdric earned 325 total points
ID: 12311355
About catching exceptions in a Log, I use Log4J in my webapp, its easy to install to Tomcat
plenty of Info about it out there and you only need to put a single line of code in
any Exception using the log method and sending the exception message as a parameter.
0
 
LVL 1

Expert Comment

by:Celdric
ID: 12335181
Wee! my 2nd correct question, thank you very much =D
Hope it helped, good luck with the Appenders!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
Is your company's data protection keeping pace with virtualization? Here are 7 dynamic ways to adapt to rapid breakthroughs in technology.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now