I have been trying to fix a NullPointerException for awhile now and I am completely stumped. It is occurring in a 'seize' block, but I cannot determine what exactly is causing it.
I have a feeling it could be the code I have inputted into the seize block due to the fact that I am a beginner.
I am trying to seize another agent and send it to different parts of the world via a parameter within the 'order' agent that contains a value from 1 to 8.
On seize unit I have the following code:
if (agent.missionLocation <= 1); KC30resource1.moveTo(main.AsiaRegion.randomPointInside());
{
if (agent.missionLocation <= 2); KC30resource1.moveTo(main.AfricaRegion.randomPointInside());
}
{
if (agent.missionLocation <= 3); KC30resource1.moveTo(main.MiddleeastRegion.randomPointInside());
}
{
if (agent.missionLocation <= 4); KC30resource1.moveTo(main.EuropeRegion.randomPointInside());
}
{
if (agent.missionLocation <= 5); KC30resource1.moveTo(main.NAmericaRegion.randomPointInside());
}
{
if (agent.missionLocation <= 6); KC30resource1.moveTo(main.SAmericaRegion.randomPointInside());
}
{
if (agent.missionLocation <= 7); KC30resource3.moveTo(main.AustraliaNzRegion.randomPointInside());
}
{
if (agent.missionLocation <= 8); KC30resource2.moveTo(main.PacificRegion.randomPointInside());
}
Could this be the reason why it is happening?
Exception during discrete event execution:
NullPointerException
java.lang.NullPointerException
at com.anylogic.libraries.processmodeling.Seize.a(Unknown Source)
at com.anylogic.libraries.processmodeling.Seize.a(Unknown Source)
at com.anylogic.libraries.processmodeling.Seize.a(Unknown Source)
at com.anylogic.libraries.processmodeling.Seize.a(Unknown Source)
at com.anylogic.libraries.processmodeling.Seize.a(Unknown Source)
at com.anylogic.libraries.processmodeling.Seize.a(Unknown Source)
at com.anylogic.libraries.processmodeling.Seize.a(Unknown Source)
at com.anylogic.libraries.processmodeling.Seize$16.a(Unknown Source)
at com.anylogic.libraries.processmodeling.Seize$16.action(Unknown Source)
at com.anylogic.libraries.processmodeling.AsynchronousExecutor_xjal.executeActionOf(Unknown Source)
at com.anylogic.engine.EventTimeout.execute(Unknown Source)
at com.anylogic.engine.Engine.f(Unknown Source)
at com.anylogic.engine.Engine.gj(Unknown Source)
at com.anylogic.engine.Engine.e(Unknown Source)
at com.anylogic.engine.Engine$m.run(Unknown Source)
Expected results are that the unit will fly to the GISregion specified in the code. Each 'MoveTo' block for each region is connect to the Seize block.
Thank you in advance.
