Quarkus: Regression: 1.3.0.Final @Inject mock service in QuarkusTest Caused by: java.lang.IllegalAccessError:

Created on 20 Mar 2020  路  12Comments  路  Source: quarkusio/quarkus

Describe the bug
An Caused by: java.lang.IllegalAccessError: is thrown using @Mock

Expected behavior
@Mock service being injected

Actual behavior
Fails to pass tests:

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running cat.tmb.citaprevia.api.ApplicationVersionResourceTest
2020-03-20 14:17:35,107 INFO  [io.qua.sma.dep.processor] (build-63) Metric is disabled - vetoing the MetricDecorator
2020-03-20 14:17:39,295 WARN  [io.qua.res.dep.RestClientProcessor] (build-59) Unsupported default scope javax.inject.Default provided for rest client cat.tmb.citaprevia.api.services.qmatic.QMaticBasicAuthenticationService. Defaulting to
@Dependent.
2020-03-20 14:17:39,373 WARN  [io.qua.res.dep.RestClientProcessor] (build-59) Unsupported default scope javax.inject.Default provided for rest client cat.tmb.citaprevia.api.services.qmatic.QMaticCalendarAPIService. Defaulting to @Dependent.
2020-03-20 14:17:50,702 WARN  [io.qua.net.run.NettyRecorder] (Thread-95) Localhost lookup took more than one second, you need to add a /etc/hosts entry to improve Quarkus startup time. On Windows the path is C:\Windows\System32\Drivers\etc\hosts. See https://thoeni.io/post/macos-sierra-java/ for macOS details.
2020-03-20 14:17:50,861 INFO  [io.sma.rea.mes.ext.MediatorManager] (main) Deployment done... start processing
2020-03-20 14:17:50,864 INFO  [io.sma.rea.mes.imp.ConfiguredChannelFactory] (main) Found incoming connectors: [smallrye-kafka]
2020-03-20 14:17:50,864 INFO  [io.sma.rea.mes.imp.ConfiguredChannelFactory] (main) Found outgoing connectors: [smallrye-kafka]
2020-03-20 14:17:50,865 INFO  [io.sma.rea.mes.imp.ConfiguredChannelFactory] (main) Channel manager initializing...
2020-03-20 14:17:50,870 INFO  [io.sma.rea.mes.ext.MediatorManager] (main) Initializing mediators
2020-03-20 14:17:50,871 INFO  [io.sma.rea.mes.ext.MediatorManager] (main) Connecting mediators
14:17:50.875 [main] INFO  cat.tmb.citaprevia.api.rest.ApplicationStartup - The application CITA-PREVIA-API is starting...
14:17:50.877 [main] INFO  cat.tmb.citaprevia.api.rest.ApplicationStartup - - Application Version: 0.9.0
14:17:50.877 [main] INFO  cat.tmb.citaprevia.api.rest.ApplicationStartup - - Build timestamp: 2020-03-20T13:17:20Z
14:17:50.877 [main] INFO  cat.tmb.citaprevia.api.rest.ApplicationStartup - - Hostname: localhost
14:17:50.877 [main] INFO  cat.tmb.citaprevia.api.rest.ApplicationStartup - - Environment: prod
2020-03-20 14:17:50,950 ERROR [io.qua.application] (main) Failed to start application: java.lang.IllegalAccessError: class cat.tmb.citaprevia.integration.bo.mock.QMaticAuthorizationService_Observer_onStart_fd71b5e0b207b7d1ef838b94eaeff75e52b8f463 tried to access method cat.tmb.citaprevia.api.services.qmatic.QMaticAuthorizationService.onStart(Lio/quarkus/runtime/StartupEvent;)V (cat.tmb.citaprevia.integration.bo.mock.QMaticAuthorizationService_Observer_onStart_fd71b5e0b207b7d1ef838b94eaeff75e52b8f463 and cat.tmb.citaprevia.api.services.qmatic.QMaticAuthorizationService are in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @332796d3)
        at cat.tmb.citaprevia.integration.bo.mock.QMaticAuthorizationService_Observer_onStart_fd71b5e0b207b7d1ef838b94eaeff75e52b8f463.notify(QMaticAuthorizationService_Observer_onStart_fd71b5e0b207b7d1ef838b94eaeff75e52b8f463.zig:111)
        at io.quarkus.arc.impl.EventImpl$Notifier.notifyObservers(EventImpl.java:282)
        at io.quarkus.arc.impl.EventImpl$Notifier.notify(EventImpl.java:267)
        at io.quarkus.arc.impl.EventImpl.fire(EventImpl.java:69)
        at io.quarkus.arc.runtime.LifecycleEventRunner.fireStartupEvent(LifecycleEventRunner.java:23)
        at io.quarkus.arc.runtime.ArcRecorder.handleLifecycleEvents(ArcRecorder.java:109)
        at io.quarkus.deployment.steps.LifecycleEventsBuildStep$startupEvent55.deploy_0(LifecycleEventsBuildStep$startupEvent55.zig:77)
        at io.quarkus.deployment.steps.LifecycleEventsBuildStep$startupEvent55.deploy(LifecycleEventsBuildStep$startupEvent55.zig:36)
        at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:255)
        at io.quarkus.runtime.Application.start(Application.java:90)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at io.quarkus.runner.bootstrap.StartupActionImpl.run(StartupActionImpl.java:96)
        at io.quarkus.test.junit.QuarkusTestExtension.doJavaStart(QuarkusTestExtension.java:89)
        at io.quarkus.test.junit.QuarkusTestExtension.ensureStarted(QuarkusTestExtension.java:180)
        at io.quarkus.test.junit.QuarkusTestExtension.beforeAll(QuarkusTestExtension.java:208)
        at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeBeforeAllCallbacks$7(ClassBasedTestDescriptor.java:359)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeBeforeAllCallbacks(ClassBasedTestDescriptor.java:359)
        at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:189)
        at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:78)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:132)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
        at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
        at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
        at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
        at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
        at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
        at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
        at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:220)
        at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:188)
        at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:202)
        at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:181)
        at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128)
        at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:142)
        at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:117)
        at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
        at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)

2020-03-20 14:17:51,085 WARN  [io.qua.ver.run.VertxProducer] (main) `io.vertx.reactivex.core.Vertx` is deprecated  and will be removed in a future version - it is recommended to switch to `io.vertx.mutiny.core.eventbus.Vertx`
2020-03-20 14:17:51,089 INFO  [io.sma.rea.mes.ext.MediatorManager] (main) Cancel subscriptions
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 20.51 s <<< FAILURE! - in cat.tmb.citaprevia.api.ApplicationVersionResourceTest
[ERROR] testApplicationVersionEndpoint  Time elapsed: 0.003 s  <<< ERROR!
java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: Failed to start quarkus
        at io.quarkus.test.junit.QuarkusTestExtension.beforeEach(QuarkusTestExtension.java:164)
        at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeEachCallbacks$1(TestMethodTestDescriptor.java:154)
        at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeMethodsOrCallbacksUntilExceptionOccurs$5(TestMethodTestDescriptor.java:190)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeMethodsOrCallbacksUntilExceptionOccurs(TestMethodTestDescriptor.java:190)
        at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeEachCallbacks(TestMethodTestDescriptor.java:153)
        at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:131)
        at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:71)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
        at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
        at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
        at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
        at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
        at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
        at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
        at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
        at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
        at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:220)
        at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:188)
        at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:202)
        at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:181)
        at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128)
        at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:142)
        at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:117)
        at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
        at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Failed to start quarkus
        at io.quarkus.test.junit.QuarkusTestExtension.doJavaStart(QuarkusTestExtension.java:125)
        at io.quarkus.test.junit.QuarkusTestExtension.ensureStarted(QuarkusTestExtension.java:180)
        at io.quarkus.test.junit.QuarkusTestExtension.beforeAll(QuarkusTestExtension.java:208)
        at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeBeforeAllCallbacks$7(ClassBasedTestDescriptor.java:359)
        at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
        at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeBeforeAllCallbacks(ClassBasedTestDescriptor.java:359)
        at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:189)
        at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:78)
        at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:132)
        ... 31 more
Caused by: java.lang.RuntimeException: Failed to start quarkus
        at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:301)
        at io.quarkus.runtime.Application.start(Application.java:90)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at io.quarkus.runner.bootstrap.StartupActionImpl.run(StartupActionImpl.java:96)
        at io.quarkus.test.junit.QuarkusTestExtension.doJavaStart(QuarkusTestExtension.java:89)
        ... 39 more
Caused by: java.lang.IllegalAccessError: class cat.tmb.citaprevia.integration.bo.mock.QMaticAuthorizationService_Observer_onStart_fd71b5e0b207b7d1ef838b94eaeff75e52b8f463 tried to access method cat.tmb.citaprevia.api.services.qmatic.QMaticAuthorizationService.onStart(Lio/quarkus/runtime/StartupEvent;)V (cat.tmb.citaprevia.integration.bo.mock.QMaticAuthorizationService_Observer_onStart_fd71b5e0b207b7d1ef838b94eaeff75e52b8f463 and cat.tmb.citaprevia.api.services.qmatic.QMaticAuthorizationService are in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @332796d3)
        at cat.tmb.citaprevia.integration.bo.mock.QMaticAuthorizationService_Observer_onStart_fd71b5e0b207b7d1ef838b94eaeff75e52b8f463.notify(QMaticAuthorizationService_Observer_onStart_fd71b5e0b207b7d1ef838b94eaeff75e52b8f463.zig:111)
        at io.quarkus.arc.impl.EventImpl$Notifier.notifyObservers(EventImpl.java:282)
        at io.quarkus.arc.impl.EventImpl$Notifier.notify(EventImpl.java:267)
        at io.quarkus.arc.impl.EventImpl.fire(EventImpl.java:69)
        at io.quarkus.arc.runtime.LifecycleEventRunner.fireStartupEvent(LifecycleEventRunner.java:23)
        at io.quarkus.arc.runtime.ArcRecorder.handleLifecycleEvents(ArcRecorder.java:109)
        at io.quarkus.deployment.steps.LifecycleEventsBuildStep$startupEvent55.deploy_0(LifecycleEventsBuildStep$startupEvent55.zig:77)
        at io.quarkus.deployment.steps.LifecycleEventsBuildStep$startupEvent55.deploy(LifecycleEventsBuildStep$startupEvent55.zig:36)
        at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:255)
        ... 46 more

Code:

@Mock
@ApplicationScoped 
public class QMaticOrchestaAPIServiceMock extends QMaticOrchestaAPIService
{

    private static final Logger logger = LogManager.getLogger(QMaticOrchestaAPIServiceMock.class);

    @Override   
    public BranchResponse getBranches() {
        logger.info("MOCK ORQUESTRA API CLIENT!!!!");
        BranchResponse response  = new BranchResponse();
        List<Branch> branchList = new ArrayList<Branch>();
        Branch newBranch = new Branch();
        newBranch.setName("TestBranch");
        newBranch.setPublicId("BranchPublicId");
        newBranch.setCreated(new Date());
        branchList.add(newBranch);
        response.setBranchList(branchList);
        return response;
    }


}

To Reproduce
Steps to reproduce the behavior:

  1. Mvn test


    1. 3.

Screenshots
(If applicable, add screenshots to help explain your problem.)

Environment (please complete the following information):

  • Output of uname -a or ver: Microsoft Windows [Versi贸n 6.1.7601]
  • Output of java -version: openjdk version "11" 2018-09-25
    OpenJDK Runtime Environment 18.9 (build 11+28)
    OpenJDK 64-Bit Server VM 18.9 (build 11+28, mixed mode
  • GraalVM version (if different from Java): N/A
  • Quarkus version or git rev: 1.3.0.Final
  • Build tool (ie. output of mvnw --version or gradlew --version):
    Maven home: C:\DeveloperTools\apache-maven-3.6.3\bin..
    Java version: 11, vendor: Oracle Corporation, runtime: C:\DeveloperTools\jdk-11
    Default locale: es_ES, platform encoding: Cp1252
    OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
    Additional context
    (Add any other context about the problem here.)
kinbug

All 12 comments

Could you prepare a simple reproducer (a simple Maven project showing the issue)? Thanks!

Yeah, there is a good chance this has already been fixed in master (I tried reproducing the issue without success), so having a reproducer would be super useful.

At the very least, we will need to see what kind observer code you are using.

Also, is QMaticOrchestaAPIService in a different module than where the test is?

Hi,
Reproducer:
https://github.com/esteveavi/quarkus-1.3-test
QMaticOrchestaAPIService is in the same module.

Thank you for the reproducer!

The problem surfaces because cat.tmb.citaprevia.integration.bo.mock.QMaticAuthorizationServiceMock is not the same package as cat.tmb.citaprevia.api.services.qmatic.QMaticAuthorizationService and the onStart method of the latter is package-private.
So what happens is that the observer for QMaticAuthorizationServiceMock is created in cat.tmb.citaprevia.integration.bo.mock and therefore doesn't have access to cat.tmb.citaprevia.api.services.qmatic.QMaticAuthorizationService#onStart.

You have a few options to overcome the problem:

  • Use the same package for both beans
  • Make onStart public.

To be honest, the new Quarkus behavior seems correct to me, but I'll let @mkouba and @manovotn comment more since they are the CDI experts.

Hi,

That was the problem. By the way it surfaced when upgraded to 1.3.0. It worked on previous versions.

Thank you very much.

Looks like you guys solved this over the weekend. @geoand analysis is correct.
However, I think we should be able to add a reflection fallback here so the method can be invoked.

This will affect not only observers but also initializer and @PostConstruct methods (some of which may already work, requires testing). I'll reopen this issue and see what we can do with it.

@esteveavi Just out of curiosity what version of Quarkus did you use before? This behavior should manifest itself since v1.0 unless the observer was previously private because in such case a reflection fallback is always used.

@manovotn IIRC, I tested the reproducer with 1.2.1.Final and the problem didn't manifest in that version.

@geoand thanks! @manovotn I believe that it would be good to know why before we come with the fix...

Alright so this indeed works for 1.2. Looks like we accidentally broke this with https://github.com/quarkusio/quarkus/pull/6888 where the target package for created OM changed to work for synthetic observers. However, at the same time this results in two (or more) different OM classes being created for hierarchical cases. This is becuase the target package will no longer be deduced from declaring class (which can be missing for synthetic observers) but instead uses bean class which can be a subclass.

Since this issue deals with just observer methods, I will send a PR fixing this and look separately into aforementioned initializers and post constructs to verify if those work and if needed, file separate issue.

Was this page helpful?
0 / 5 - 0 ratings