File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Reading a serialized object, Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Reading a serialized object, Tomcat" Watch "Reading a serialized object, Tomcat" New topic
Author

Reading a serialized object, Tomcat

Dominik Glodzik
Greenhorn

Joined: Mar 22, 2011
Posts: 2
Hello everyone,

I seem to have a problem with my JSP application running on Apache Tomcat/6.0.14.

I catch the following exception:
org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11.XToolkit

This happens when I tried to read in a file containing a serialized object.


The class of the object, which is being red, contains an instance of a Swing class ImageIcon. This works fine on GlassFish on my machine, but gives an error when uploaded to Tomcat.

I'd welcome any suggestions how to read in the serialized object.

Dominik
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1016
The server you are running on is a *nix type?
Most probably without a monitor?
Check out headless mode to see if it might help: http://java.sun.com/developer/technicalArticles/J2SE/Desktop/headless/

I'm not sure if it will or not. The sun.* classes are not really intended for general use
Can you come up with a better approach than serializing java objects?
Dominik Glodzik
Greenhorn

Joined: Mar 22, 2011
Posts: 2
Hey,

thank you VERY much, it works.

Yes, the server runs Linux with no display.

To switch Tomcat to a headless mode, add the following line to catalina.sh
export CATALINA_OPTS=-Djava.awt.headless=true

Dominik


 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Reading a serialized object, Tomcat
 
Similar Threads
Storing Serializable Objects in files
Problem in Locating a properties File (Not the Struts application.properties)
Serializing classes with hashmaps
ClassNotFoundException when deserialized from tomcat web app
Problem in Serialization?