?
Solved

Writing to Tomcat Log and Serialize Bean

Posted on 2004-10-14
4
Medium Priority
?
551 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 1300 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

A walk-through example of how to obtain and apply new DID phone numbers to your cloud PBX enabled users that are configured in Office 365. Whether you have 1, 10 or 100+ users in your tenant, it's quite easy to get them phone-enabled and making/rece…
Geo-targeting is the practice of distributing content based on a person’s location, as best as you can determine it. Let’s look at some ways you could successfully use this tactic. The following tips and case studies could lead to meaningful results.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

650 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