Cytoscape 3 plugin development: load a XML file

245 views
Skip to first unread message

Koen Herten

unread,
May 4, 2012, 4:22:45 AM5/4/12
to cytoscape-discuss
Hi,

I am developing a plugin for Cytoscape 3. It will predict
transcription factors for a given gene set. I'm currently testing my
plugin and its working on Cytoscape 2.8.2, but I want it also
available if Cytoscape 3 is there for Cytoscape 3.
In my plugin there is an option to save the results to a XML (so it is
compatible with other programs in my lab). In Cytoscape 2.8.2 I use
XStream, but in Cytoscape 3 I get an error message:
Exception in thread "AWT-EventQueue-0"
java.lang.IllegalArgumentException: XPP3 pull parser library not
present. Specify another driver. For example: new XStream(new
DomDriver())

So, I figured out that Cytoscape 3 must have already the XStream
libary somewhere available. But when I remove my added XStream jar, I
still get the same message.

So is there a way to import XML given by the Cytoscape envirement? Or
is there another way to do it?

Thanks,

Koen

Jason Montojo

unread,
May 4, 2012, 1:42:16 PM5/4/12
to cytoscap...@googlegroups.com
Hi Koen,

How are you making your XStream JAR accessible to Cytoscape 3?  And is your app a simplified-style app or OSGi app?

Thanks,
Jason


--
You received this message because you are subscribed to the Google Groups "cytoscape-discuss" group.
To post to this group, send email to cytoscap...@googlegroups.com.
To unsubscribe from this group, send email to cytoscape-disc...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cytoscape-discuss?hl=en.


Koen Herten

unread,
May 7, 2012, 10:14:55 AM5/7/12
to cytoscape-discuss
Hi Jason,

my app is a simplified-style app. For the moment I make a big jar with
my code, the XStream jar (xstream-1.4.2.jar) and a kxml jar
(kxml2-2.3.0.jar) via an ant script (fatjar plugin of eclipse).
<?xml version="1.0"?>
<project name="iRegulon_Alpha.jar" default="main" basedir=".">
<target name="main">
<fatjar.build output="iRegulon_Alpha-v0.5.jar">
<fatjar.manifest manifestfile="src/iRegulon/Cytoscape-
Plugin"/>
<fatjar.filesource path="/home/koen/workspace/iRegulon/
bin" relpath=""/>
<fatjar.jarsource file="/home/koen/Downloads/
xstream-1.4.2.jar" relpath=""/>
<fatjar.jarsource file="/home/koen/Downloads/
kxml2-2.3.0.jar" relpath=""/>
</fatjar.build>
</target>
</project>

Then i import the jar in my code:
import com.thoughtworks.xstream.XStream;

This way worked fine in Cytoscape 2.8.2.

Thanks,
Koen

On May 4, 7:42 pm, Jason Montojo <jrr...@gmail.com> wrote:
> Hi Koen,
>
> How are you making your XStream JAR accessible to Cytoscape 3?  And is your
> app a simplified-style app or OSGi app?
>
> Thanks,
> Jason
>

Jason Montojo

unread,
May 8, 2012, 10:34:47 AM5/8/12
to cytoscap...@googlegroups.com
Hi Koen,

Cytoscape 3.0 provides XStream 1.3.1.  Technically, this isn't supposed to be happening because the platform's dependencies shouldn't be visible to app authors so we can avoid clashes like this one.  I'll open up a ticket in our issue tracker and see if we can get this resolved soon.

In the meantime, I think you're running into issues because XStream uses Java reflection to find a parser driver.  Cytoscape 3 runs inside an OSGi container that uses very strict class loading rules which doesn't play nicely with reflection.  You may need to explicitly specify a particular ClassLoader like this:

ReflectionProvider reflectionProvider = new PureJavaReflectionProvider();

HierarchicalStreamDriver driver = new KXml2Driver();
ClassLoader classLoader = YourPlugin.class.getClassLoader();

new XStream(reflectionProvider, driver, classLoader);

Also, you shouldn't be running your XML parsing code inside the AWT thread.  That can cause the UI to freeze.  You should be doing that within the context of a Task and hand it off to the TaskManager like this:

Task task = new AbstractTask() {
    @Override
    public void run(TaskMonitor taskMonitor) throws Exception {
        // Do XML parsing here
    }
};
adapter.getTaskManager().execute(new TaskIterator(task));

Hope this helps,
Jason
Reply all
Reply to author
Forward
0 new messages