quarkus: Injecting from another module causes ClassCastException

Describe the bug The class to be injected is located in Maven dependency. During the runtime, injection fails with java.lang.ClassCastException. Both main project and dependency have beans.xml. If the injected class is moved to the main project, injection works.

Verified in dev mode.

Expected behavior Class should be injected without error.

Actual behavior

When the @Inject variable is used for the first time, Quarkus throws exception:

2019-10-30 08:26:52,612 INFO  [io.quarkus] (main) Installed features: [agroal, cdi, hibernate-orm, jdbc-h2, narayana-jta, resteasy, resteasy-jsonb, smallrye-openapi, swagger-ui]
2019-10-30 08:27:18,622 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (vert.x-worker-thread-1) HTTP Request to /person failed, error id: 96789028-ac59-4737-82a2-032c65c14f36-1: org.jboss.resteasy.spi.UnhandledException: java.lang.RuntimeException: Error injecting link.zeljko.quarkus.model.PersonRepository link.zeljko.quarkus.service.PersonService.personRepository
...
Caused by: java.lang.ClassCastException: link.zeljko.quarkus.model.PersonRepository_ClientProxy cannot be cast to link.zeljko.quarkus.model.PersonRepository
	at link.zeljko.quarkus.service.PersonService_Bean.create(PersonService_Bean.zig:151)
	... 31 more

To Reproduce Steps to reproduce the behavior:

  1. Create two projects, the main project, and dependency with injectable class. Add beans.xml to both.
  2. mvn install dependency
  3. Add dependency to the main project
  4. Inject class from the dependency
  5. Run main project in the dev mode.
  6. Make operation that accesses the injected variable.

Configuration

quarkus.datasource.url=jdbc:h2:file:./persons
quarkus.datasource.driver=org.h2.Driver
quarkus.hibernate-orm.database.generation=update
quarkus.http.port=8000

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

Environment (please complete the following information):

  • Output of uname -a or ver: Microsoft Windows [Version 10.0.18362.418]
  • Output of java -version: java version “1.8.0_221” Java™ SE Runtime Environment (build 1.8.0_221-b11) Java HotSpot™ 64-Bit Server VM (build 25.221-b11, mixed mode)
  • GraalVM version (if different from Java):
  • Quarkus version or git rev: 0.26.1

Additional context quarkus.zip

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 29 (17 by maintainers)

Commits related to this issue

Most upvoted comments

It should be, but I don’t have a reproducer handy for this particular issue.