Feature Requests item #1524019, was opened at 2006-07-17 21:12 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=684978&aid=1524019&group_id=119783
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Priority: 5 Submitted By: Ittay Dror (ittayd) Assigned to: Nobody/Anonymous (nobody) Summary: working with plugins (classloaders) Initial Comment: We're using plugins similar to Eclipse's to decouple functionality. Each plugin's classes run in their own class loader. specifically, a plugin can have a MyPage class (this is done by having our implementation of Application that iterates over the XXXPage classes for each plugin and uses mount and url coding strategy to make the XXXPage accessible from a url) We've encountered a problem in onNewBrowserWindow(). it uses Objects.cloneObject(), which uses serialization to implement deep copy. It serializes the object and then uses ObjectInputStream to reconstruct the object. ObjectInputStream resolves classes by using a class loader that is associated with the execution stack. At the point of cloning, the execution stack contains only wicket / tomcat classes, so the class loader it finds is WebClassLoader. This class loader knows only of the classes under WEB-INF. so when it encounters a class name that belongs to a plugin (and hence is not in WEB-INF, but in the plugin's jar, in a separate folder), it fails to resolve it. This can be solved by changing cloneObject to use the class loader associated with the object to be cloned. This class loader is guarenteed to work (since the instance of the object is used, then all classes of objects contained in this object (as fields) are resolveable by the object - through its associated class loader) more specifically, it means using a subclass of ObjectInputStream that resolves classes using the object's class loader. here is the revised method (the important change is the overrided resolveClass in the annonymous class): public static Object cloneObject(final Object object) { if (object == null) { return null; } else { try { final ByteArrayOutputStream out = new ByteArrayOutputStream(256); ObjectOutputStream oos = new ObjectOutputStream(out); oos.writeObject(object); ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(out .toByteArray())) { protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { String className = desc.getName(); return Class.forName(className, true, object.getClass().getClassLoader()); } }; return ois.readObject(); } catch (ClassNotFoundException e) { throw new WicketRuntimeException("Internal error cloning object", e); } catch (IOException e) { throw new WicketRuntimeException("Internal error cloning object", e); } } } ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=684978&aid=1524019&group_id=119783 ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Wicket-develop mailing list Wicket-develop@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-develop