Link to home
Start Free TrialLog in
Avatar of zania22
zania22

asked on

Writing to Tomcat Log and Serialize Bean

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
Avatar of zania22
zania22

ASKER

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.
Avatar of zania22

ASKER

Any thoughts about how to write to Tomcat's currernt(for the day) log file
ASKER CERTIFIED SOLUTION
Avatar of Celdric
Celdric

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Wee! my 2nd correct question, thank you very much =D
Hope it helped, good luck with the Appenders!