Solved

Writing to Tomcat Log and Serialize Bean

Posted on 2004-10-14
4
518 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
java.util.concurrent.Callable way of creating threads 2 102
EJB MDB example 4 79
authenticate preemptively soap ui option 3 123
Suggestion on WebSite Template Sites 6 82
When we talk about DevOps toolchains, I sometimes wonder how many people really get what we’re talking about. I don’t know if it’s just semantics or tone or something else, but sometimes I think it just sounds like buzzword sausage. So it’s always …
A customer recently asked me about anti-malware and the different deployment options available for his business. Daily news about cyberattacks, zero-day vulnerabilities, and companies that suffered a security breach made him wonder if the endpoint a…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Edureka is one of the fastest growing and most effective online learning sites.  We are here to help you succeed.

911 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