Thanks for reporting. That's a terminology bug. The Vehicle isn't both an entity and not an entity... A) It's an entity because it has @PlanningVariable and a shadow variable. B) But it's also not an entity because it doesn't have any genuine variables, and therefore ScoreDirector throws that NPE... (which should be a better error message too). I 'll fix this for 6.1, probably by discarding B).
Could you file a jira for this? https://issues.jboss.org/browse/PLANNER Workaround for 6.0.1: Presuming you're doing this in a ProblemFactChange, call scoreDirector.beforeProblemFactRemoved() instead of beforeEntityRemoved() => Treat it as a problem fact for that... but treat is as an entity for everything else. hth On 06-05-14 16:17, Hagai wrote: > Using OptaPlanner 6.0.1.Final with problem like vehiclerouting. > > In vehiclerouting the Vehicle and Customer are both planning entities. They > both implements the Standstill interface that is annotated with > @PlanningEntity and their collections are annotated with > @PlanningEntityCollectionProperty on the solution class. > > Flowing the code of VehicleRoutingPanel.insertLocationAndCustomer to insert > a new Vehicle to the solution, my code is failing when the new Vehicle is > reported to the score director: > scoreDirector.beforeEntityAdded(newVehicle); > > The exception is NullPointerException at > org.optaplanner.core.impl.domain.variable.listener.PlanningVariableListenerSupport.beforeEntityAdded(PlanningVariableListenerSupport.java:54) > > It looks like the PlanningVariableListenerSupport.entityVariableListenerMap > does not have item for the Vehicle entity, there is only one item for the > Customer entity in this map. > > I get the same problem when calling ScoreDirector.beforeEntityRemoved to > remove a Vehicle. > > Is this a bug or do I need to handle Vehicle entities differently? > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/NullPointerException-when-calling-ScoreDirector-beforeEntityAdded-with-new-Vehicle-tp4029434.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > _______________________________________________ > rules-users mailing list > [email protected] > https://lists.jboss.org/mailman/listinfo/rules-users > _______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
