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

PlanningSolution class do not carry its annotation when coming from a different module

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • None
    • None
    • None
    • Hide

      To reproduce the issue, create a class with the annotation @PlanningSolution and the .xml config file (along with the drl and entityClass) in a module. Create a new module (for example a spring-boot web api) and in it create a new scoreManager from the config file : 

      solverFactory = SolverFactory.createFromXmlResource("solver/mySolverConfig.xml");
      scoreManager = ScoreManager.create(solverFactory); 
      Show
      To reproduce the issue, create a class with the annotation @PlanningSolution and the .xml config file (along with the drl and entityClass) in a module. Create a new module (for example a spring-boot web api) and in it create a new scoreManager from the config file :  solverFactory = SolverFactory.createFromXmlResource( "solver/mySolverConfig.xml" ); scoreManager = ScoreManager.create(solverFactory);
    • NEW
    • NEW

      Hello,

      I opened that StackOverflow question : https://stackoverflow.com/questions/70261160/optaplanner-spring-beancreationexception?noredirect=1#comment124221433_70261160 

      Long story short:  

      There are two modules, A and B, one module contains the @PlanningSolution class and the configuration files . The module B creates the solverConfig, solverFactory, scoreManager, etc. (referencing the needed classes from module A).

      When creating a scoreManager (same for solverManager) from the instantiated SolverConfig (using config from module A) in module B, the following exception occurs : 

      nested exception is java.lang.IllegalStateException: The solutionClass (class be.my.domain.MySolution) has been specified as a solution in the configuration, but does not have a @PlanningSolution annotation.
          at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:627) 

      Note, be.my.domain.MySolution does have the correction annotation.

      This will raise the mentioned exception. 

      The current workaround is to put the code from module A under module B, not ideal, but that works. 

      Note this bug showed up when we migrate Optaplanner from v7.28 to v8.13 (and now 8.14)

              Unassigned Unassigned
              crommvardek Cyril Carlier (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: