From: David W. <d.a...@st...> - 2011-08-26 08:47:32
|
Hello Nick, That was indeed the problem, i forgot to make a reference to the contexts that are created in the ContextCreator. Thanks for your response, David Watson Nick Collier wrote: > > David, > > Its more likely cityContext is null. Try setting a break point and > stepping through the code and inspect the variables to see which or null. > Alternatively, print out all the variables. > > Nick > > On Aug 24, 2011, at 8:19 AM, David Watson wrote: > >> >> Hello Everybody, >> >> I have been faced with a problem for a couple of days now. When i run my >> model i get the following error: >> >> Shop: 1currentCoordinate:-1.5167303701124346-1.5167303701124346 >> The value of j is: 1 >> Shop: 2Coordinate:-1.5163776299854885-1.5163776299854885 >> At position 2 now >> currentCoordinate:-1.5167303701124346-1.5167303701124346 >> Tried to call: public void >> carriercontext.Carrier.execution()java.lang.reflect.InvocationTargetException >> at >> carriercontext.Carrier$$FastClassByCGLIB$$b39fefa1.invoke(<generated>) >> at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53) >> at >> repast.simphony.engine.schedule.CallBackAction.execute(CallBackAction.java:127) >> at >> repast.simphony.engine.schedule.ThreadedAction$ActionRunner.run(ThreadedAction.java:102) >> at java.lang.Thread.run(Unknown Source) >> Caused by: java.lang.NullPointerException >> at citycontext.DistanceTable.createDistanceTable(DistanceTable.java:86) >> at vrp.MyObjectiveFunction.<init>(MyObjectiveFunction.java:69) >> at vrp.VRP.<init>(VRP.java:31) >> at carriercontext.Carrier.startVRP(Carrier.java:198) >> at carriercontext.Carrier.execution(Carrier.java:74) >> ... 5 more >> >> As you can see, the error is presumably caused by the NullPointer >> exception. >> The code that is throwing this exception is: >> shp = ShopList.get(i); >> currentCoord = shp.getShopCoordinate(); >> /*currentCoord = >> ContextCreator.getShopGeography(). >> >> getGeometry(ShopList.get(i)).getCentroid().getCoordinate();*/ >> >> shp2 = ShopList.get(j); >> destCoord = shp2.getShopCoordinate(); >> /*destCoord = ContextCreator.getShopGeography(). >> >> getGeometry(ShopList.get(j)).getCentroid().getCoordinate();*/ >> >> This is throwing the exception--->currentRoad = >> cityContext.findRoadAtCoordinates(currentCoord); >> destRoad = >> cityContext.findRoadAtCoordinates(destCoord); >> >> What i can't seem to figure out is the reason for this exception because >> the >> variable currentCoord is not equal to NULL when passed to the method. I >> have >> validated this by printing the value of currentCoord: >> currentCoordinate:-1.5167303701124346-1.5167303701124346. Why would it >> throw >> this exception, is there something i am overlooking? >> >> Can somebody help me with this i am really getting stuck now. >> >> Kind regards, >> >> David Watson >> >> -- >> View this message in context: >> http://old.nabble.com/Error-java.lang.reflect.InvocationTargetException-tp32325942p32325942.html >> Sent from the repast-interest mailing list archive at Nabble.com. >> >> >> ------------------------------------------------------------------------------ >> EMC VNX: the world's simplest storage, starting under $10K >> The only unified storage solution that offers unified management >> Up to 160% more powerful than alternatives and 25% more efficient. >> Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev >> _______________________________________________ >> Repast-interest mailing list >> Rep...@li... >> https://lists.sourceforge.net/lists/listinfo/repast-interest > > > ------------------------------------------------------------------------------ > EMC VNX: the world's simplest storage, starting under $10K > The only unified storage solution that offers unified management > Up to 160% more powerful than alternatives and 25% more efficient. > Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev > _______________________________________________ > Repast-interest mailing list > Rep...@li... > https://lists.sourceforge.net/lists/listinfo/repast-interest > > -- View this message in context: http://old.nabble.com/Error-java.lang.reflect.InvocationTargetException-tp32325942p32340239.html Sent from the repast-interest mailing list archive at Nabble.com. |