Uploaded image for project: 'OptaPlanner'
  1. OptaPlanner
  2. PLANNER-318

AnchorShadowVariable responsible for NullPointerException creating a ScoreDirector

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Minor Minor
    • 6.3.0.CR2
    • 6.2.0.Final
    • None
    • None

      The variable "firstStandstill" is the anchor root of the chain. In previous releases we computed the value in our code, the new OptaPlanner release has the annotation @AnchorShadowVariable to do this automatically.

      When we set the annotation, we get java.lang.NullPointerException: null

      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_71]
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_71]
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_71]
      	at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_71]
      	at org.optaplanner.core.impl.domain.common.ReflectionPropertyAccessor.executeGetter(ReflectionPropertyAccessor.java:62) ~[optaplanner-core-6.2.0.Final.jar:6.2.0.Final]
      	at org.optaplanner.core.impl.domain.solution.descriptor.SolutionDescriptor.extractEntityCollection(SolutionDescriptor.java:543) ~[optaplanner-core-6.2.0.Final.jar:6.2.0.Final]
      	at org.optaplanner.core.impl.domain.solution.descriptor.SolutionDescriptor.getEntityListByEntityClass(SolutionDescriptor.java:390) ~[optaplanner-core-6.2.0.Final.jar:6.2.0.Final]
      	at org.optaplanner.core.impl.domain.entity.descriptor.EntityDescriptor.extractEntities(EntityDescriptor.java:401) ~[optaplanner-core-6.2.0.Final.jar:6.2.0.Final]
      	at org.optaplanner.core.impl.domain.variable.inverserelation.ExternalizedSingletonInverseVariableSupply.resetWorkingSolution(ExternalizedSingletonInverseVariableSupply.java:50) ~[optaplanner-core-6.2.0.Final.jar:6.2.0.Final]
      	at org.optaplanner.core.impl.domain.variable.listener.VariableListenerSupport.demand(VariableListenerSupport.java:83) ~[optaplanner-core-6.2.0.Final.jar:6.2.0.Final]
      	at org.optaplanner.core.impl.domain.variable.anchor.AnchorShadowVariableDescriptor.buildVariableListener(AnchorShadowVariableDescriptor.java:86) ~[optaplanner-core-6.2.0.Final.jar:6.2.0.Final]
      	at org.optaplanner.core.impl.domain.variable.listener.VariableListenerSupport.buildVariableListeners(VariableListenerSupport.java:69) ~[optaplanner-core-6.2.0.Final.jar:6.2.0.Final]
      	at org.optaplanner.core.impl.domain.variable.listener.VariableListenerSupport.linkVariableListeners(VariableListenerSupport.java:54) ~[optaplanner-core-6.2.0.Final.jar:6.2.0.Final]
      	at org.optaplanner.core.impl.score.director.AbstractScoreDirector.<init>(AbstractScoreDirector.java:76) ~[optaplanner-core-6.2.0.Final.jar:6.2.0.Final]
      	at org.optaplanner.core.impl.score.director.drools.DroolsScoreDirector.<init>(DroolsScoreDirector.java:47) ~[optaplanner-core-6.2.0.Final.jar:6.2.0.Final]
      	at org.optaplanner.core.impl.score.director.drools.DroolsScoreDirector.buildScoreDirector(DroolsScoreDirectorFactory.java:20) ~[classes/:6.2.0.Final]
      

      when calling solver.getScoreDirectorFactory().buildScoreDirector() during initialization when the solution of the solver is still null. (solver not yet started, no solution set yet).

      So we decided not to use @AnchorShadowVariable yet.

      Suggestion: fix this, so that you can create a scoreDirector before starting the solver the first time.

              gdesmet@redhat.com Geoffrey De Smet (Inactive)
              romanstumm Roman Stumm (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: