[rules-users] NullPointerException when calling ScoreDirector.beforeEntityAdded with new Vehicle

Hagai hagai.shatz at gmail.com
Tue May 6 10:17:59 EDT 2014


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.


More information about the rules-users mailing list