gsmet opened a new pull request, #3177:
URL: https://github.com/apache/incubator-kie-optaplanner/pull/3177
Legacy @ConfigRoot classes support will be dropped soon from Quarkus and
Quarkus 3.15+ already supports @ConfigMapping interfaces so we can move this
project to the new infrastructure.
One thing that is important is that you are currently using runtime config
at static init - which means that it's build time for native images and this is
not correct - and disallowed.
I fixed it but the important consequence of this is that the solver will be
initialized at runtime, including when building native image.
This commit is still incomplete though as I end up with some class loader
issues and I didn't have the time to go further.
Here is the class loader issue I end up with with my changes. It might be a
dumb mistake but what I thought would be a simple change ended up being a bit
of a rabbit hole so I'm leaving it at that. Creating the PR as I thought
someone might be interested to pursue it further.
```
[ERROR]
org.optaplanner.benchmark.quarkus.OptaPlannerBenchmarkProcessorBenchmarkConfigTest
Time elapsed: 0.593 s <<< ERROR!
org.junit.jupiter.api.extension.TestInstantiationException: Failed to create
test instance
at io.quarkus.test.QuarkusUnitTest.beforeAll(QuarkusUnitTest.java:716)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: java.lang.RuntimeException:
java.lang.reflect.InvocationTargetException
at
io.quarkus.runner.bootstrap.RunningQuarkusApplicationImpl.instance(RunningQuarkusApplicationImpl.java:90)
at io.quarkus.test.QuarkusUnitTest.beforeAll(QuarkusUnitTest.java:708)
... 1 more
Caused by: java.lang.reflect.InvocationTargetException
at java.base/java.lang.reflect.Method.invoke(Method.java:569)
at
io.quarkus.runner.bootstrap.RunningQuarkusApplicationImpl.instance(RunningQuarkusApplicationImpl.java:88)
... 2 more
Caused by: java.lang.LinkageError: loader constraint violation: when
resolving method 'void
org.optaplanner.benchmark.config.SolverBenchmarkConfig.setSolverConfig(org.optaplanner.core.config.solver.SolverConfig)'
the class loader io.quarkus.bootstrap.classloading.QuarkusClassLoader
@3f350e2b of the current class,
org/optaplanner/benchmark/quarkus/OptaPlannerBenchmarkRecorder, and the class
loader 'app' for the method's defining class,
org/optaplanner/benchmark/config/SolverBenchmarkConfig, have different Class
objects for the type org/optaplanner/core/config/solver/SolverConfig used in
the signature (org.optaplanner.benchmark.quarkus.OptaPlannerBenchmarkRecorder
is in unnamed module of loader
io.quarkus.bootstrap.classloading.QuarkusClassLoader @3f350e2b, parent loader
io.quarkus.bootstrap.classloading.QuarkusClassLoader @5dfe144;
org.optaplanner.benchmark.config.SolverBenchmarkConfig is in unnamed module of
loader 'app')
at
org.optaplanner.benchmark.quarkus.OptaPlannerBenchmarkRecorder.updateBenchmarkConfigWithRuntimeProperties(OptaPlannerBenchmarkRecorder.java:78)
at
org.optaplanner.benchmark.quarkus.OptaPlannerBenchmarkRecorder.lambda$benchmarkConfigSupplier$0(OptaPlannerBenchmarkRecorder.java:57)
at io.quarkus.arc.runtime.ArcRecorder$4.apply(ArcRecorder.java:137)
at io.quarkus.arc.runtime.ArcRecorder$4.apply(ArcRecorder.java:134)
at
org.optaplanner.benchmark.config.PlannerBenchmarkConfig_jQ0LrSuk-Q8ejoc5zd7QE0_QkLU_Synthetic_Bean.createSynthetic(Unknown
Source)
at
org.optaplanner.benchmark.config.PlannerBenchmarkConfig_jQ0LrSuk-Q8ejoc5zd7QE0_QkLU_Synthetic_Bean.doCreate(Unknown
Source)
at
org.optaplanner.benchmark.config.PlannerBenchmarkConfig_jQ0LrSuk-Q8ejoc5zd7QE0_QkLU_Synthetic_Bean.create(Unknown
Source)
at
org.optaplanner.benchmark.config.PlannerBenchmarkConfig_jQ0LrSuk-Q8ejoc5zd7QE0_QkLU_Synthetic_Bean.get(Unknown
Source)
at
org.optaplanner.benchmark.config.PlannerBenchmarkConfig_jQ0LrSuk-Q8ejoc5zd7QE0_QkLU_Synthetic_Bean.get(Unknown
Source)
at
io.quarkus.arc.impl.CurrentInjectionPointProvider.get(CurrentInjectionPointProvider.java:48)
at
org.optaplanner.benchmark.quarkus.OptaPlannerBenchmarkBeanProvider_ProducerMethod_benchmarkFactory_rQ7QoTazk6Wv0BPV1PrJ986ZnAc_Bean.doCreate(Unknown
Source)
at
org.optaplanner.benchmark.quarkus.OptaPlannerBenchmarkBeanProvider_ProducerMethod_benchmarkFactory_rQ7QoTazk6Wv0BPV1PrJ986ZnAc_Bean.create(Unknown
Source)
at
org.optaplanner.benchmark.quarkus.OptaPlannerBenchmarkBeanProvider_ProducerMethod_benchmarkFactory_rQ7QoTazk6Wv0BPV1PrJ986ZnAc_Bean.create(Unknown
Source)
at
io.quarkus.arc.impl.AbstractSharedContext.createInstanceHandle(AbstractSharedContext.java:119)
at
io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:38)
at
io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:35)
at io.quarkus.arc.impl.LazyValue.get(LazyValue.java:32)
at
io.quarkus.arc.impl.ComputingCache.computeIfAbsent(ComputingCache.java:69)
at
io.quarkus.arc.impl.ComputingCacheContextInstances.computeIfAbsent(ComputingCacheContextInstances.java:19)
at
io.quarkus.arc.impl.AbstractSharedContext.get(AbstractSharedContext.java:35)
at
org.optaplanner.benchmark.quarkus.OptaPlannerBenchmarkBeanProvider_ProducerMethod_benchmarkFactory_rQ7QoTazk6Wv0BPV1PrJ986ZnAc_Bean.get(Unknown
Source)
at
org.optaplanner.benchmark.quarkus.OptaPlannerBenchmarkBeanProvider_ProducerMethod_benchmarkFactory_rQ7QoTazk6Wv0BPV1PrJ986ZnAc_Bean.get(Unknown
Source)
at
org.optaplanner.benchmark.quarkus.OptaPlannerBenchmarkProcessorBenchmarkConfigTest_Bean.doCreate(Unknown
Source)
at
org.optaplanner.benchmark.quarkus.OptaPlannerBenchmarkProcessorBenchmarkConfigTest_Bean.create(Unknown
Source)
at
org.optaplanner.benchmark.quarkus.OptaPlannerBenchmarkProcessorBenchmarkConfigTest_Bean.get(Unknown
Source)
at
org.optaplanner.benchmark.quarkus.OptaPlannerBenchmarkProcessorBenchmarkConfigTest_Bean.get(Unknown
Source)
at
io.quarkus.arc.impl.InstanceImpl.getBeanInstance(InstanceImpl.java:325)
at io.quarkus.arc.impl.InstanceImpl.getInternal(InstanceImpl.java:309)
at io.quarkus.arc.impl.InstanceImpl.get(InstanceImpl.java:190)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]