Solved

Writing to Tomcat Log and Serialize Bean

Posted on 2004-10-14
4
536 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
In this blog we highlight approaches to managed security as a service.  We also look into ConnectWise’s value in aiding MSPs’ security management and indicate why critical alerting is a necessary integration.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

705 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