Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.4.0.CR1 Generated Bean Injection not working as before #20755

Closed
lorenzjosten opened this issue Oct 13, 2021 · 10 comments · Fixed by #20770
Closed

2.4.0.CR1 Generated Bean Injection not working as before #20755

lorenzjosten opened this issue Oct 13, 2021 · 10 comments · Fixed by #20770
Assignees
Labels
area/arc Issue related to ARC (dependency injection) area/gradle Gradle kind/bug Something isn't working
Milestone

Comments

@lorenzjosten
Copy link

lorenzjosten commented Oct 13, 2021

Describe the bug

I am working on a multi-module gradle project which uses MapStruct for @entity to DTO conversion. Mapper beans are injected into microservice modules from shared data library modules. After upgrading from quarkus 2.3.0.Final to 2.4.0.CR1 injecting mapper beans does not work anymore. Using Jandex does not solve the problem either.

Expected behavior

Injecting MapStruct mapper beans from one module into another should work for 2.4.0.RC1.

Actual behavior

Injecting MapStruct mapper beans from one module into another does not work for 2.4.0.RC1. The application crashes before starting the server in devMode:

2021-10-14 01:28:17,706 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: javax.enterprise.inject.spi.DeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type de.lj.v240.mapper.PersonMapper and qualifiers [@Default]
	- java member: de.lj.MapperTest#<init>()
	- declared on CLASS bean [types=[de.lj.MapperTest, java.lang.Object], qualifiers=[@Default, @Any], target=de.lj.MapperTest]
	at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:1190)
	at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:268)
	at io.quarkus.arc.processor.BeanProcessor.initialize(BeanProcessor.java:129)
	at io.quarkus.arc.deployment.ArcProcessor.validate(ArcProcessor.java:418)
	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.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:821)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
	at java.base/java.lang.Thread.run(Thread.java:834)
	at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type de.lj.v240.mapper.PersonMapper and qualifiers [@Default]
	- java member: de.lj.MapperTest#<init>()
	- declared on CLASS bean [types=[de.lj.MapperTest, java.lang.Object], qualifiers=[@Default, @Any], target=de.lj.MapperTest]
	at io.quarkus.arc.processor.Beans.resolveInjectionPoint(Beans.java:567)
	at io.quarkus.arc.processor.BeanInfo.init(BeanInfo.java:470)
	at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:256)
	... 13 more

	at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:418)
	at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:276)
Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type de.lj.v240.mapper.PersonMapper and qualifiers [@Default]

	at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:67)
	at io.quarkus.deployment.dev.IsolatedDevModeMain.firstStart(IsolatedDevModeMain.java:92)
	at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:441)
	at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:65)
	at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:149)
	at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:105)
	at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:145)
	at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:63)
Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: javax.enterprise.inject.spi.DeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type de.lj.v240.mapper.PersonMapper and qualifiers [@Default]
	- java member: de.lj.MapperTest#<init>()
	- declared on CLASS bean [types=[de.lj.MapperTest, java.lang.Object], qualifiers=[@Default, @Any], target=de.lj.MapperTest]
	at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:1190)
	at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:268)
	at io.quarkus.arc.processor.BeanProcessor.initialize(BeanProcessor.java:129)
	at io.quarkus.arc.deployment.ArcProcessor.validate(ArcProcessor.java:418)
	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.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:821)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
	at java.base/java.lang.Thread.run(Thread.java:834)
	at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type de.lj.v240.mapper.PersonMapper and qualifiers [@Default]
	- java member: de.lj.MapperTest#<init>()
	- declared on CLASS bean [types=[de.lj.MapperTest, java.lang.Object], qualifiers=[@Default, @Any], target=de.lj.MapperTest]
	at io.quarkus.arc.processor.Beans.resolveInjectionPoint(Beans.java:567)
	at io.quarkus.arc.processor.BeanInfo.init(BeanInfo.java:470)
	at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:256)
	... 13 more

	at io.quarkus.builder.Execution.run(Execution.java:116)
	at io.quarkus.builder.BuildExecutionBuilder.execute(BuildExecutionBuilder.java:79)
	at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:161)
	at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:416)
	... 9 more
Caused by: javax.enterprise.inject.spi.DeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type de.lj.v240.mapper.PersonMapper and qualifiers [@Default]
	- java member: de.lj.MapperTest#<init>()
	- declared on CLASS bean [types=[de.lj.MapperTest, java.lang.Object], qualifiers=[@Default, @Any], target=de.lj.MapperTest]
	at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:1190)
	at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:268)
	at io.quarkus.arc.processor.BeanProcessor.initialize(BeanProcessor.java:129)
	at io.quarkus.arc.deployment.ArcProcessor.validate(ArcProcessor.java:418)
	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.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:821)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
	at java.base/java.lang.Thread.run(Thread.java:834)
	at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type de.lj.v240.mapper.PersonMapper and qualifiers [@Default]
	- java member: de.lj.MapperTest#<init>()
	- declared on CLASS bean [types=[de.lj.MapperTest, java.lang.Object], qualifiers=[@Default, @Any], target=de.lj.MapperTest]
	at io.quarkus.arc.processor.Beans.resolveInjectionPoint(Beans.java:567)
	at io.quarkus.arc.processor.BeanInfo.init(BeanInfo.java:470)
	at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:256)
Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors

	... 13 more

2021-10-14 01:28:17,706 INFO  [io.qua.dep.dev.IsolatedDevModeMain] (main) Attempting to start live reload endpoint to recover from previous Quarkus startup failure
Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type de.lj.v240.mapper.PersonMapper and qualifiers [@Default]

Caused by: javax.enterprise.inject.spi.DeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type de.lj.v240.mapper.PersonMapper and qualifiers [@Default]

Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type de.lj.v240.mapper.PersonMapper and qualifiers [@Default]

2021-10-14 01:28:17,838 INFO  [org.jbo.threads] (main) JBoss Threads version 3.4.2.Final

> Task :microservice-2.4.0:quarkusDev FAILED

Execution failed for task ':microservice-2.4.0:quarkusDev'.
> Build cancelled while executing task ':microservice-2.4.0:quarkusDev'

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

How to Reproduce?

I added code which allows for reproduction of the error to my github repo. Run quarkusDev for gradle module microservice-2.4.0 in order to reproduce the error. Run quarkusDev for gradle module microservice-2.3.0 in order to get the expected behaviour.

Output of uname -a or ver

Darwin 20.6.0 Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64 x86_64

Output of java -version

openjdk version "11.0.10" 2021-01-19 OpenJDK Runtime Environment GraalVM CE 21.0.0.2 (build 11.0.10+8-jvmci-21.0-b06) OpenJDK 64-Bit Server VM GraalVM CE 21.0.0.2 (build 11.0.10+8-jvmci-21.0-b06, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.4.0.CR1

Build tool (ie. output of mvnw --version or gradlew --version)

Gradle 7.2

Additional information

Canonical bean injection, i.e. creating an @ApplicationScoped bean in the data-libraries, still works.

@lorenzjosten lorenzjosten added the kind/bug Something isn't working label Oct 13, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Oct 13, 2021

/cc @manovotn, @mkouba

@quarkus-bot quarkus-bot bot added the area/arc Issue related to ARC (dependency injection) label Oct 13, 2021
@mkouba mkouba added the area/gradle Gradle label Oct 14, 2021
@mkouba
Copy link
Contributor

mkouba commented Oct 14, 2021

@aloubyansky could it be also related to the bootstrap refactoring PR?

@aloubyansky
Copy link
Member

I'll check, thanks for letting me know.

@aloubyansky
Copy link
Member

Yes, it's a regression caused by my change.
We used to merge all the classes dirs into one temporary dir for the dev mode in Gradle. I wanted to get rid of that hack. But I missed a thing.

@aloubyansky aloubyansky self-assigned this Oct 14, 2021
@lorenzjosten
Copy link
Author

lorenzjosten commented Oct 14, 2021

Thank you guys for looking into this so quickly! Is there some kind of work around for this or do you plan to fix it for the 2.4.0.Final release?

@lorenzjosten lorenzjosten changed the title 2.4.1.RC Generated Bean Injection not working as before 2.4.0.CR1 Generated Bean Injection not working as before Oct 14, 2021
@aloubyansky
Copy link
Member

It should be fixed in 2.4.0.Final.
As to a workaround, afaics, this path mapper-injection/data-library-2.4.0/build/generated/source/kapt/main isn't present among Java source sets, although that's where the de/lj/v240/mapper/PersonMapperImpl.java is. Perhaps, it can be added in the project config as a workaround. I haven't tried it myself though. I am looking for a fix that won't require that.

@lorenzjosten
Copy link
Author

Indeed that works. I added a branch with an ugly workaround for anyone interested. Using my implementation is highly discouraged though, as it uses a Gradle anti-pattern (direct project reference in build script).
Quarkus doesn't like it either:

2021-10-14 12:53:47,000 WARN  [io.qua.arc.dep.SplitPackageProcessor] (build-34) Detected a split package usage which is considered a bad practice and should be avoided. Following packages were detected in multiple archives: 
- "de.lj.v240.mapper" found in [application classes, de.lj:data-library-2.4.0::jar]

Still, it works for the time being.

@aloubyansky
Copy link
Member

@lorenzjosten if you like you can test #20770 by building it locally.

One thing that still won't work though (2.3.0.Final isn't different in this regard) is changing the mapper interface in dev mode. That's another story though.

@lorenzjosten
Copy link
Author

Thank you! I’ll give it a try later and will let you know if it works. 👍🏻

@aloubyansky
Copy link
Member

Thanks @lorenzjosten

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/arc Issue related to ARC (dependency injection) area/gradle Gradle kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants