Unexpected exception while handling listener: org.cytoscape.view.model.events.NetworkViewAddedListener

31 views
Skip to first unread message

Juan Garcia

unread,
May 3, 2021, 1:23:14 PMMay 3
to cytoscape-app-dev
Hi all,

I'm upgrading an old app developed some years ago to the new OSGi infastructure for Cytoscape 3.8.2.

I'm creating a new network and its corresponding networkView, but there is an exception:


2021-05-03 11:26:42,910 [SwingWorker-pool-23-thread-1] ERROR org.cytoscape.application.userlog - Unexpected exception while handling listener: org.cytoscape.view.model.events.NetworkViewAddedListener
java.lang.reflect.InvocationTargetException: null
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
at org.cytoscape.event.internal.CyListenerAdapter.fireEvent(CyListenerAdapter.java:120) [61:org.cytoscape.event-impl:3.8.2]
at org.cytoscape.event.internal.CyEventHelperImpl.fireEvent(CyEventHelperImpl.java:81) [61:org.cytoscape.event-impl:3.8.2]
at org.cytoscape.view.model.internal.CyNetworkViewManagerImpl.fireEvent(CyNetworkViewManagerImpl.java:205) [88:org.cytoscape.viewmodel-impl:3.8.2]
at org.cytoscape.view.model.internal.CyNetworkViewManagerImpl.addNetworkView(CyNetworkViewManagerImpl.java:194) [88:org.cytoscape.viewmodel-impl:3.8.2]
at org.cytoscape.view.model.internal.CyNetworkViewManagerImpl.addNetworkView(CyNetworkViewManagerImpl.java:165) [88:org.cytoscape.viewmodel-impl:3.8.2]
at oracle.graph.propertyGraph.client.visualization.cytoscape.CreatePropertyGraph.createPropertyGraph(CreatePropertyGraph.java:531) [121:oracle.spatial.propertyGraph.client.visualization.cytoscape:4.4.6]
at oracle.graph.propertyGraph.client.visualization.cytoscape.gui.LoadWindowRDBMSGraph.loadRandomNodes(LoadWindowRDBMSGraph.java:590) [121:oracle.spatial.propertyGraph.client.visualization.cytoscape:4.4.6]
at oracle.graph.propertyGraph.client.visualization.cytoscape.gui.LoadWindowRDBMSGraph.access$400(LoadWindowRDBMSGraph.java:80) [121:oracle.spatial.propertyGraph.client.visualization.cytoscape:4.4.6]
at oracle.graph.propertyGraph.client.visualization.cytoscape.gui.LoadWindowRDBMSGraph$DoLoad.doInBackground(LoadWindowRDBMSGraph.java:832) [121:oracle.spatial.propertyGraph.client.visualization.cytoscape:4.4.6]
at oracle.graph.propertyGraph.client.visualization.cytoscape.gui.LoadWindowRDBMSGraph$DoLoad.doInBackground(LoadWindowRDBMSGraph.java:796) [121:oracle.spatial.propertyGraph.client.visualization.cytoscape:4.4.6]
at javax.swing.SwingWorker$1.call(SwingWorker.java:304) [?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at javax.swing.SwingWorker.run(SwingWorker.java:343) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: java.lang.NullPointerException
at org.cytoscape.internal.select.RowViewTracker.handleEvent(RowViewTracker.java:79) ~[?:?]
... 20 more


This is the main code that I have been using and perfectly worked in the previous version:

CyActivator.cyNetworkManager.reset();
this.network = CyActivator.cyNetworkFactory.createNetwork();
this.network.getRow(network).set(CyNetwork.NAME,networkID);//the network's identifier
 createTable();// creates the node and edge tables
for each node...
this.network.addNode();

for each edge...
this.network.addEdge(nodeSource,nodeDestiny,true);

CyNetworkView view = CyActivator.networkViewFactory.createNetworkView(this.network);

CyActivator.cyNetworkManager.addNetwork(this.network);
CyActivator.networkViewManager.addNetworkView(view);

Even though the view seems to be there, it is not being shown. Not sure if I'm missing something...
any ideas?

Thanks,
Juan Garcia

cytoscapeErrorView.PNG

Juan Garcia

unread,
May 4, 2021, 12:48:56 PMMay 4
to cytoscape-app-dev
Hi all,

I tried exactly the sample-create-network-view code from the cytoscape-app-samples with the same error when trying to add the new network view.

public class CreateNetworkViewTask extends AbstractTask {

    private final CyNetworkFactory cnf;
    private final CyNetworkViewFactory cnvf;
    private final CyNetworkViewManager networkViewManager;
    private final CyNetworkManager networkManager;
    private final CyNetworkNaming cyNetworkNaming;

    public CreateNetworkViewTask(CyNetworkNaming cyNetworkNaming, CyNetworkFactory cnf, CyNetworkManager networkManager,
            CyNetworkViewFactory cnvf, final CyNetworkViewManager networkViewManager) {
        this.cnf = cnf;
        this.cnvf = cnvf;
        this.networkViewManager = networkViewManager;
        this.networkManager = networkManager;
        this.cyNetworkNaming = cyNetworkNaming;
    }

    @Override
    public void run(TaskMonitor monitor) {

        // Create an empty network
        CyNetwork myNet = this.cnf.createNetwork();
        
        if (myNet == null) {
            return;
        }

        // add a node to the network
        CyNode node1 = myNet.addNode();

        // set name for the new node
        myNet.getDefaultNodeTable().getRow(node1.getSUID()).set("name", "Node1");

        myNet.getDefaultNetworkTable().getRow(myNet.getSUID()).set("name", cyNetworkNaming.getSuggestedNetworkTitle("My Network"));

        this.networkManager.addNetwork(myNet);

        final Collection<CyNetworkView> views = networkViewManager.getNetworkViews(myNet);
        CyNetworkView myView = null;
        if (!views.isEmpty()) {
            myView = views.iterator().next();
        }

        if (myView == null) {
            // create a new view for my network
            myView = cnvf.createNetworkView(myNet);
            networkViewManager.addNetworkView(myView);
        } else {
            System.out.println("networkView already existed.");
        }

        // Set the variable destroyView to true, the following snippet of code
        // will destroy a view
        boolean destroyView = false;
        if (destroyView) {
            networkViewManager.destroyNetworkView(myView);
        }
    }

}


I also added a class that implements the NetworkViewAddedListener and the log successfully displays the corresponding output

public class PGNetworkViewAddedListener implements NetworkViewAddedListener{

    @Override
    public void handleEvent(NetworkViewAddedEvent e) {
        CyNetworkView networkView = e.getNetworkView();
        CyNetwork addedNetwork = networkView.getModel();
            logger.log(Level.INFO, "Added the network view: {0}  with model (network) {1} ", new Object[]{ networkView.getSUID(), addedNetwork.getSUID()});
    }
}


The error is thrown in the line that registers the networkView to the networkViewManager object: 


2021-05-04 11:31:36,850 [Task-Thread-3-Factory-0x174e86b4] ERROR org.cytoscape.application.userlog - Unexpected exception while handling listener: org.cytoscape.view.model.events.NetworkViewAddedListener
java.lang.reflect.InvocationTargetException: null
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
at org.cytoscape.event.internal.CyListenerAdapter.fireEvent(CyListenerAdapter.java:120) [61:org.cytoscape.event-impl:3.8.2]
at org.cytoscape.event.internal.CyEventHelperImpl.fireEvent(CyEventHelperImpl.java:81) [61:org.cytoscape.event-impl:3.8.2]
at org.cytoscape.view.model.internal.CyNetworkViewManagerImpl.fireEvent(CyNetworkViewManagerImpl.java:205) [88:org.cytoscape.viewmodel-impl:3.8.2]
at org.cytoscape.view.model.internal.CyNetworkViewManagerImpl.addNetworkView(CyNetworkViewManagerImpl.java:194) [88:org.cytoscape.viewmodel-impl:3.8.2]
at org.cytoscape.view.model.internal.CyNetworkViewManagerImpl.addNetworkView(CyNetworkViewManagerImpl.java:165) [88:org.cytoscape.viewmodel-impl:3.8.2]
at oracle.graph.propertyGraph.client.visualization.cytoscape.osgi.CreateNetworkViewTask.run(CreateNetworkViewTask.java:81) [122:oracle.spatial.propertyGraph.client.visualization.cytoscape:4.4.6]
at org.cytoscape.work.internal.task.JDialogTaskManager$TaskRunnable.innerRun(JDialogTaskManager.java:321) [93:org.cytoscape.work-swing-impl:3.8.2]
at org.cytoscape.work.internal.task.JDialogTaskManager$TaskRunnable.run(JDialogTaskManager.java:352) [93:org.cytoscape.work-swing-impl:3.8.2]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: java.lang.NullPointerException
at org.cytoscape.internal.select.RowViewTracker.handleEvent(RowViewTracker.java:79) ~[?:?]
... 17 more


I'm running out of ideas, what is the issue.

I'm running Cytoscape 3.8.2 with jdk 11.0.11 on a Windows 10

I'd appreciate any help on this

Thanks,

Juan Garcia

Juan Garcia

unread,
May 4, 2021, 1:40:17 PMMay 4
to cytoscape-app-dev
I'm checking the source code of the class RowViewTracker in the line 79, and the rendererId value comes null. The exception is thrown when is trying to verify: if (rendererId.equals(DING_ID))

public void handleEvent(final NetworkViewAddedEvent e) {
String rendererId = e.getNetworkView().getRendererId();
if(rendererId.equals(DING_ID)) {
DING_ID = rendererId; // optimization, makes calling equals() faster because reference equality
return;

Scooter Morris

unread,
May 6, 2021, 11:11:18 AMMay 6
to cytoscape-app-dev
My best guess is that somehow the renderer is not (yet) set.  Make sure to flush all events before trying to add the network view.

-- scooter
Reply all
Reply to author
Forward
0 new messages