User: mulder
Date: 00/09/07 05:40:08
Modified: src/main/org/jboss/ejb/plugins/jaws/jdbc JDBCCommand.java
Log:
Use the proper ClassLoader for objects serialized into the DB.
Revision Changes Path
1.9 +19 -6 jboss/src/main/org/jboss/ejb/plugins/jaws/jdbc/JDBCCommand.java
Index: JDBCCommand.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/jaws/jdbc/JDBCCommand.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- JDBCCommand.java 2000/09/04 16:17:54 1.8
+++ JDBCCommand.java 2000/09/07 12:40:08 1.9
@@ -52,7 +52,7 @@
* utility methods that database commands may need to call.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Justin Forder</a>
- * @version $Revision: 1.8 $
+ * @version $Revision: 1.9 $
*/
public abstract class JDBCCommand
{
@@ -434,12 +434,13 @@
return null;
if(destination.isAssignableFrom(result.getClass()))
return result;
+// DEBUG else System.out.println("Got a "+result.getClass().getName()+":
'"+result+"' while looking for a "+destination.getName());
// Also we should detect the EJB references here
// Get the underlying byte[]
- byte[] bytes = rs.getBytes(idx);
+ byte[] bytes = result instanceof byte[] ? (byte[])result : rs.getBytes(idx);
if( bytes == null ) {
result = null;
@@ -451,18 +452,18 @@
// Use the class loader to deserialize
try {
- ObjectInputStream ois = new ObjectInputStream(bais);
+ WorkaroundInputStream ois = new WorkaroundInputStream(bais);
result = ois.readObject();
if(!destination.isAssignableFrom(result.getClass())) {
+ System.out.println("Unable to load a ResultSet column into a
variable of type '"+destination.getName()+"' (got a "+result.getClass().getName()+")");
result = null;
- System.out.println("Unable to load a ResultSet column into a
variable of type '"+destination.getName()+"'");
}
ois.close();
} catch (IOException e) {
- throw new SQLException("Unable to load a ResultSet column into a
variable of type '"+destination.getName()+"'");
+ throw new SQLException("Unable to load a ResultSet column into a
variable of type '"+destination.getName()+"': "+e);
} catch (ClassNotFoundException e) {
- throw new SQLException("Unable to load a ResultSet column into a
variable of type '"+destination.getName()+"'");
+ throw new SQLException("Unable to load a ResultSet column into a
variable of type '"+destination.getName()+"': "+e);
}
}
@@ -639,4 +640,16 @@
}
}
}
+
+ class WorkaroundInputStream extends ObjectInputStream {
+ public WorkaroundInputStream(java.io.InputStream source) throws
IOException, java.io.StreamCorruptedException{
+ super(source);
+ }
+ protected Class resolveClass(java.io.ObjectStreamClass v) throws
IOException, ClassNotFoundException {
+ try {
+ return Class.forName(v.getName(), false,
Thread.currentThread().getContextClassLoader());
+ } catch(Exception e) {}
+ return super.resolveClass(v);
+ }
+ }
}