Issues with using java.net.http libraries in Cytoscape Apps

34 views
Skip to first unread message

Indraneel Ghosh

unread,
Jun 13, 2021, 2:13:58 AMJun 13
to cytoscape-app-dev
Hi,
I am trying to make an enrichment analysis Cytoscape app which uses the gProfiler API as part of my GSoC 2021 project.
I had written some code that uses java.net.http for making API requests. This is causing Cytoscape to throw an error "App failed to start". Before I started using this implementation my app was working fine.

To test the implementation of my GET and POST request code, I implemented another project which uses the exact same implementation and it works. 

Is there something that I am missing in my Cytoscape implementations that is preventing the app from starting? 
Any help would be useful.

Thanks and Regards
Indraneel Ghosh

Scooter Morris

unread,
Jun 14, 2021, 11:34:20 PMJun 14
to cytoscape-app-dev
Hi Indraneel,
  Welcome to OSGi!  So, I strongly suspect that the issue is that the http jar isn't getting included in your bundle.  Looking at your pom file, I see this:


<dependency>

    <groupId>org.apache.httpcomponents</groupId>

    <artifactId>httpclient</artifactId>

    <version>4.5</version>

    <optional>true</optional>
 
</dependency>

which is correct.  However, you are missing some key instructions in the configuration instructions further up in your pom.  Here is an example from one of mine:

            <Embed-Dependency>*;scope=!provided</Embed-Dependency>
            <Embed-Transitive>true</Embed-Transitive>
            <Import-Package>*;resolution:=optional</Import-Package>

The <Embed-Dependency> clause allows me to say "embed everything unless I add the provided scope"  This gives me a lot more control than having to add each jar I want to embed in the stanza.  And, what you were missing is the <Import-Package> bit, which specifically says that if <optional> is true, we want to import it.  If you make those changes, the app *should* start (unless something else is going on :-)).

-- scooter

Indraneel Ghosh

unread,
Jun 17, 2021, 12:24:52 PMJun 17
to cytoscape-app-dev
Hi,
Thanks for the reply Scooter. I am able to make my project start successfully now.

I am following up on another issue that I am facing right now on this thread while firing a API request as part of a task.

I am unable to execute my tasks successfully. I have been looking at multiple repositories to understand how task managers interact with a task. Cytoscape projects tend to have fairly different ways of implementing this interaction. Is there a suggested process that one should follow while implementing task management? Could you please share some suggestions on what would be the correct way to implementing the task manager?
 I have been trying to implement my taskManager the way in which BiNGO had but my task is not running[The task never completes. I suspect that it goes into a deadlock.].
I am making use of the SynchronousTaskManager for implementing the task management system. 

I am adding the implementations by BINGO that I referred to and my implementation for some context.

I have followed a similar approach in my project:

Is there something wrong with my approach? How can I handle the race conditions?

Thanks and Regards 
Indraneel Ghosh

Indraneel Ghosh

unread,
Jun 17, 2021, 3:43:04 PMJun 17
to cytoscape-app-dev
We really shouldn't be using a CyAction.  Instead, you should simply implement your ProfilerPlugin as a TaskFactory and a Task.  CyActions were initially to support doing fancy things with cascading menus, but we really don't need it anymore.  So, you would want a "ProfilerPluginTaskFactory" and a ProfilerPluginTask.  The properties used when you register the taskfactory will indicate the menu structure.  This would have to be done eventually to support automation, so we might as well get it done now.   
Reply all
Reply to author
Forward
0 new messages