Bug 32428 - Classloader issue when reading serialized object from database.
Summary: Classloader issue when reading serialized object from database.
Status: RESOLVED INVALID
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Unknown (show other bugs)
Version: 5.0.28
Hardware: PC Windows 2000
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-29 14:54 UTC by Szalai Robert
Modified: 2004-11-29 10:11 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Szalai Robert 2004-11-29 14:54:18 UTC
I've set up a JDBC datasource for MySQL as it described in 
this page: 

http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-
howto.html

I've installed mysql-connector-java-3.0.9-stable-bin.jar in 
$CATALINA_HOME/common/lib

When I try to read a serialized object from a BLOB column, 
I always get ClassNotFoundException. 
The class of the object that I want to read is located in my
webapp's WEB-INF/classes directory.

Code: 

161   rs = stmt.executeQuery();
162			
163   if (rs.next()) {
164      DummyVO dummy = new DummyVO();
165      dummy.setId(rs.getLong(1));
...      ...
176      dummy.setEnv((Dummy) rs.getObject(9));
...      ...
179   }

Stacktrace:

java.sql.SQLException: Class not found: java.lang.ClassNotFoundException: 
sim.test.Dummy while reading serialized object
        at com.mysql.jdbc.ResultSet.getObject(ResultSet.java:1537)
        at org.apache.commons.dbcp.DelegatingResultSet.getObject(DelegatingResul
tSet.java:286)
        at sim.proba.dao.SimulationDAO.findById(SimulationDAO.java:176)
        at sim.proba.web.SimAction.getSimulation(SimAction.java:40)
        at sim.proba.web.ControlSimAction.execute(ControlSimAction.java:71)
        at org.apache.struts.action.RequestProcessor.processActionPerform(Reques
tProcessor.java:421)
        at org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
va:226)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:116
4)
        at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)

        at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

If this is the normal classloader behaivor, how can I read serialized object
from db?
Comment 1 Yoav Shapira 2004-11-29 19:11:44 UTC
The class needs to be available to the common/lib classloader if you're using 
container-managed datasources.  It can't just be in WEB-INF/lib, since 
common/lib can't see WEB-INF/lib.  This is not a Tomcat bug.