Using XMLEncoder

Code excerpt in mine IDEA plugin:

XMLEncoder encoder = new XMLEncoder(OutputStream);
encoder.writeObject(OBJECT_FROM_OUR_PLUGIN_CLASS);

Somethere in JDK classes there is call classForName of the class OBJECT_FROM_OUR_PLUGIN_CLASS name and this class is not found in the classloader (I suppose in classloader of JDK) and my object is not serialized. How to make my plugin class visible for JDK classes classloader in this case?

Just stack trace of the call, when ClassNotFoundException received on debuging:

AWT-EventQueue-1@2, priority=6, in group 'Idea Thread Group', status: 'RUNNING'
at com.intellij.util.lang.UrlClassLoader.findClass(UrlClassLoader.java:67)
at java.lang.ClassLoader.loadClass(ClassLoader.java:316)
at com.intellij.util.lang.UrlClassLoader._loadClass(UrlClassLoader.java:89)
at com.intellij.util.lang.UrlClassLoader.loadClass(UrlClassLoader.java:80)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at com.intellij.ide.plugins.cl.PluginClassLoader.loadClassFromParents(PluginClassLoader.java:59)
at com.intellij.ide.plugins.cl.PluginClassLoader._loadClass(PluginClassLoader.java:45)
at com.intellij.util.lang.UrlClassLoader.loadClass(UrlClassLoader.java:80)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.beans.Introspector.instantiate(Introspector.java:1.431)
at java.beans.Introspector.findExplicitBeanInfo(Introspector.java:410)
at java.beans.Introspector.]]>(Introspector.java:359)
at java.beans.Introspector.getBeanInfo(Introspector.java:159)
at java.beans.MetaData.getBeanInfo(MetaData.java:928)
at java.beans.MetaData.getBeanAttribute(MetaData.java:963)
at java.beans.MetaData.getPersistenceDelegate(MetaData.java:890)
at java.beans.Encoder.getPersistenceDelegate(Encoder.java:129)
at java.beans.Encoder.writeObject(Encoder.java:53)
at java.beans.XMLEncoder.writeObject(XMLEncoder.java:254)
at java.beans.Encoder.writeObject1(Encoder.java:186)
at java.beans.Encoder.cloneStatement(Encoder.java:199)
at java.beans.Encoder.writeStatement(Encoder.java:230)
at java.beans.XMLEncoder.writeStatement(XMLEncoder.java:328)
at java.beans.XMLEncoder.writeObject(XMLEncoder.java:257)

Please sign in to leave a comment.