Java thread runner encounters null pointer

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Java thread runner encounters null pointer

Van Parunak
This is similar to Taylor Anderson's question of 1/2015--I'm getting a
null pointer exception (sometimes) while running.

> FATAL [Thread-11] 12:11:07,786 repast.simphony.ui.GUIScheduleRunner -
> RunTimeException when running the schedule
> Current tick (122.0)
> java.lang.NullPointerException
>     at saf.v3d.scene.VComposite.removeChild(VComposite.java:65)
>     at
> repast.simphony.visualizationOGL2D.NetworkLayerOGL2D.update(NetworkLayerOGL2D.java:87)
>     at
> repast.simphony.visualizationOGL2D.DisplayOGL2D.update(DisplayOGL2D.java:408)
>     at
> repast.simphony.visualization.engine.DisplayComponentControllerAction$DisplayUpdater.execute(DisplayComponentControllerAction.java:44)
>     at
> repast.simphony.engine.schedule.DefaultAction.execute(DefaultAction.java:38)
>     at
> repast.simphony.engine.schedule.ScheduleGroup.executeList(ScheduleGroup.java:205)
>     at
> repast.simphony.engine.schedule.ScheduleGroup.execute(ScheduleGroup.java:238)
>     at repast.simphony.engine.schedule.Schedule.execute(Schedule.java:352)
>     at
> repast.simphony.ui.GUIScheduleRunner$ScheduleLoopRunnable.run(GUIScheduleRunner.java:52)
>     at java.lang.Thread.run(Thread.java:745)
However, the bottom of the trace takes me, not to my code, but to
java.lang.Thread.run, which appears to be properly guarded:

>    @Override
>     public void run() {
>         if (target != null) {
>             target.run();
>         }
>     }
What might I be doing in my code to trigger this? The stack trace
doesn't include any of my methods.

------------------------------------------------------------------------------
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Java thread runner encounters null pointer

Van Parunak
I've been fiddling with the scenario for this, which includes both a
continuous space and a network projection. When I delete the network
projection, the fault disappears. Thoughts?


On 9/9/16 12:16 PM, Van Parunak wrote:

> This is similar to Taylor Anderson's question of 1/2015--I'm getting a
> null pointer exception (sometimes) while running.
>
>> FATAL [Thread-11] 12:11:07,786 repast.simphony.ui.GUIScheduleRunner -
>> RunTimeException when running the schedule
>> Current tick (122.0)
>> java.lang.NullPointerException
>>     at saf.v3d.scene.VComposite.removeChild(VComposite.java:65)
>>     at
>> repast.simphony.visualizationOGL2D.NetworkLayerOGL2D.update(NetworkLayerOGL2D.java:87)
>>     at
>> repast.simphony.visualizationOGL2D.DisplayOGL2D.update(DisplayOGL2D.java:408)
>>     at
>> repast.simphony.visualization.engine.DisplayComponentControllerAction$DisplayUpdater.execute(DisplayComponentControllerAction.java:44)
>>     at
>> repast.simphony.engine.schedule.DefaultAction.execute(DefaultAction.java:38)
>>     at
>> repast.simphony.engine.schedule.ScheduleGroup.executeList(ScheduleGroup.java:205)
>>     at
>> repast.simphony.engine.schedule.ScheduleGroup.execute(ScheduleGroup.java:238)
>>     at
>> repast.simphony.engine.schedule.Schedule.execute(Schedule.java:352)
>>     at
>> repast.simphony.ui.GUIScheduleRunner$ScheduleLoopRunnable.run(GUIScheduleRunner.java:52)
>>     at java.lang.Thread.run(Thread.java:745)
> However, the bottom of the trace takes me, not to my code, but to
> java.lang.Thread.run, which appears to be properly guarded:
>
>>    @Override
>>     public void run() {
>>         if (target != null) {
>>             target.run();
>>         }
>>     }
> What might I be doing in my code to trigger this? The stack trace
> doesn't include any of my methods.


------------------------------------------------------------------------------
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Java thread runner encounters null pointer

srcnick
Van,

You could see this if the object was removed the display twice. That in turn could occur if the node was removed from the network twice. I thought we had guards in the network code to prevent that (i.e. the second remove is just ignored), but perhaps not. Can you check if you are removing the same agent more than once from the context? The removal from the context would trigger the removal from the network and then the display.

Nick

> On Sep 9, 2016, at 1:24 PM, Van Parunak <[hidden email]> wrote:
>
> I've been fiddling with the scenario for this, which includes both a
> continuous space and a network projection. When I delete the network
> projection, the fault disappears. Thoughts?
>
>
> On 9/9/16 12:16 PM, Van Parunak wrote:
>> This is similar to Taylor Anderson's question of 1/2015--I'm getting a
>> null pointer exception (sometimes) while running.
>>
>>> FATAL [Thread-11] 12:11:07,786 repast.simphony.ui.GUIScheduleRunner -
>>> RunTimeException when running the schedule
>>> Current tick (122.0)
>>> java.lang.NullPointerException
>>>    at saf.v3d.scene.VComposite.removeChild(VComposite.java:65)
>>>    at
>>> repast.simphony.visualizationOGL2D.NetworkLayerOGL2D.update(NetworkLayerOGL2D.java:87)
>>>    at
>>> repast.simphony.visualizationOGL2D.DisplayOGL2D.update(DisplayOGL2D.java:408)
>>>    at
>>> repast.simphony.visualization.engine.DisplayComponentControllerAction$DisplayUpdater.execute(DisplayComponentControllerAction.java:44)
>>>    at
>>> repast.simphony.engine.schedule.DefaultAction.execute(DefaultAction.java:38)
>>>    at
>>> repast.simphony.engine.schedule.ScheduleGroup.executeList(ScheduleGroup.java:205)
>>>    at
>>> repast.simphony.engine.schedule.ScheduleGroup.execute(ScheduleGroup.java:238)
>>>    at
>>> repast.simphony.engine.schedule.Schedule.execute(Schedule.java:352)
>>>    at
>>> repast.simphony.ui.GUIScheduleRunner$ScheduleLoopRunnable.run(GUIScheduleRunner.java:52)
>>>    at java.lang.Thread.run(Thread.java:745)
>> However, the bottom of the trace takes me, not to my code, but to
>> java.lang.Thread.run, which appears to be properly guarded:
>>
>>>   @Override
>>>    public void run() {
>>>        if (target != null) {
>>>            target.run();
>>>        }
>>>    }
>> What might I be doing in my code to trigger this? The stack trace
>> doesn't include any of my methods.
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Repast-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Java thread runner encounters null pointer

Van Parunak

Hmm. The population of agents is constant once initialized. I do add and remove edges in the network, only in one place, where I maintain a size-limited ArrayList of edges with the greatest edge weights. Here's the code--it's the only place (other than the builder class) that touches the Network class. I only remove edges that I've just verified to exist. But it does seem that something is wrong in my interaction with the network projection, since when I no longer display it, the problem goes away...

private ArrayList<RepastEdge<Document>> myNbrs;
public void addNbr(Document doc, double sim)
{
    Context<Object> context = ContextUtils.getContext(myParent);
    Network<Object> net = (Network<Object>) context.getProjection("close nbrs");
        
    // Generate the new edge
    RepastEdge newEdge = new RepastEdge(myParent, doc, false, sim);
    RepastEdge oldEdge = null;
    
    if (curSize < maxSize)
    {
        curSize += 1;
        myNbrs.add(newEdge);
        net.addEdge(newEdge);
    }
    else
    { // In this case, curSize stays the same
        double minWeight = Double.MAX_VALUE;
        for (RepastEdge<Document> ed : myNbrs) {
            if (ed.getWeight() < minWeight ) // this is guaranteed to succeed for the first edge in the list
            {
                minWeight = ed.getWeight();
                oldEdge = ed;
            }
        }
        if (newEdge.getWeight() > minWeight) { // If this happens, replace the current oldEdge
            myNbrs.remove(oldEdge); // from my size-limited ArrayList
            net.removeEdge(oldEdge); // from the overall network
            myNbrs.add(newEdge);
            net.addEdge(newEdge);
        }
    }
}


On 9/9/16 2:32 PM, Nick Collier wrote:
Van,

You could see this if the object was removed the display twice. That in turn could occur if the node was removed from the network twice. I thought we had guards in the network code to prevent that (i.e. the second remove is just ignored), but perhaps not. Can you check if you are removing the same agent more than once from the context? The removal from the context would trigger the removal from the network and then the display.

Nick

On Sep 9, 2016, at 1:24 PM, Van Parunak [hidden email] wrote:

I've been fiddling with the scenario for this, which includes both a 
continuous space and a network projection. When I delete the network 
projection, the fault disappears. Thoughts?


On 9/9/16 12:16 PM, Van Parunak wrote:
This is similar to Taylor Anderson's question of 1/2015--I'm getting a 
null pointer exception (sometimes) while running.

FATAL [Thread-11] 12:11:07,786 repast.simphony.ui.GUIScheduleRunner - 
RunTimeException when running the schedule
Current tick (122.0)
java.lang.NullPointerException
   at saf.v3d.scene.VComposite.removeChild(VComposite.java:65)
   at 
repast.simphony.visualizationOGL2D.NetworkLayerOGL2D.update(NetworkLayerOGL2D.java:87)
   at 
repast.simphony.visualizationOGL2D.DisplayOGL2D.update(DisplayOGL2D.java:408)
   at 
repast.simphony.visualization.engine.DisplayComponentControllerAction$DisplayUpdater.execute(DisplayComponentControllerAction.java:44)
   at 
repast.simphony.engine.schedule.DefaultAction.execute(DefaultAction.java:38)
   at 
repast.simphony.engine.schedule.ScheduleGroup.executeList(ScheduleGroup.java:205)
   at 
repast.simphony.engine.schedule.ScheduleGroup.execute(ScheduleGroup.java:238)
   at 
repast.simphony.engine.schedule.Schedule.execute(Schedule.java:352)
   at 
repast.simphony.ui.GUIScheduleRunner$ScheduleLoopRunnable.run(GUIScheduleRunner.java:52)
   at java.lang.Thread.run(Thread.java:745)
However, the bottom of the trace takes me, not to my code, but to 
java.lang.Thread.run, which appears to be properly guarded:

  @Override
   public void run() {
       if (target != null) {
           target.run();
       }
   }
What might I be doing in my code to trigger this? The stack trace 
doesn't include any of my methods.

------------------------------------------------------------------------------
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest

    

--
H. Van Dyke Parunak, Ph.D.
President, ABC Research, LLC

Superior solutions through Agent-Based and Complex systems
email: van.parunak@...
cell: 734 395 3253
www.ABCResearch.org

------------------------------------------------------------------------------

_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Loading...