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

Quarkus 3.3.3 - injecting UserTransaction generates Jandex warnings on startup #36050

Closed
jonjanisch opened this issue Sep 20, 2023 · 0 comments · Fixed by #36062
Closed

Quarkus 3.3.3 - injecting UserTransaction generates Jandex warnings on startup #36050

jonjanisch opened this issue Sep 20, 2023 · 0 comments · Fixed by #36062
Labels
kind/bug Something isn't working
Milestone

Comments

@jonjanisch
Copy link

jonjanisch commented Sep 20, 2023

Describe the bug

I'm upgrading our app from Quarkus 2.7 to Quarkus 3.3.3.

The app starts up fine, but we get tons of warnings regarding classes in jakarta.jms similar to this:

Failed to index jakarta.jms.XAConnection: Class does not exist in ClassLoader
...
Unable to properly register the hierarchy of the following classes for reflection as they are not in the Jandex index:
    - io.mashona.logwriting.ArrayStore (source: ResteasyReactiveProcessor > blah.MyResource[AnotherResource getAnotherResource(java.lang.String aStr)])
    - jakarta.jms.BytesMessage (source: ResteasyReactiveProcessor > blah.MyResource[AnotherResource getAnotherResource(java.lang.String aStr)])

I've narrowed the problem down to injecting UserTransaction for manual transaction management in a few places.

@Inject
UserTransaction userTransaction;

It only seems to manifest itself when we have a sub-resource that injects UserTransaction somewhere. If we inject into a root level resource, e.g. GreetingResource I'm not seeing the warnings.

Expected behavior

No warnings on startup

Actual behavior

Failed to index jakarta.jms.XAConnection: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader: DEV@1eb5174b
Failed to index jakarta.jms.XASession: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader: DEV@1eb5174b
Failed to index jakarta.jms.XAConnectionFactory: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader: DEV@1eb5174b
Failed to index jakarta.jms.Connection: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader: DEV@1eb5174b
Failed to index org.apache.activemq.artemis.core.journal.Journal: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader: DEV@1eb5174b
Failed to index jakarta.jms.Session: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader: DEV@1eb5174b
Failed to index jakarta.jms.ExceptionListener: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader: DEV@1eb5174b
Failed to index jakarta.jms.ConnectionMetaData: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader: DEV@1eb5174b
Failed to index io.mashona.logwriting.ArrayStore: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader: DEV@1eb5174b
Failed to index jakarta.jms.BytesMessage: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader: DEV@1eb5174b
Failed to index jakarta.jms.MapMessage: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader: DEV@1eb5174b
Failed to index jakarta.jms.Message: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader: DEV@1eb5174b
Failed to index jakarta.jms.ObjectMessage: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader: DEV@1eb5174b
Failed to index jakarta.jms.StreamMessage: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader: DEV@1eb5174b
Failed to index jakarta.jms.TemporaryQueue: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader: DEV@1eb5174b
Failed to index jakarta.jms.TemporaryTopic: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader: DEV@1eb5174b
Failed to index jakarta.jms.TextMessage: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader: DEV@1eb5174b
Failed to index jakarta.jms.MessageListener: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader: DEV@1eb5174b
Failed to index org.apache.activemq.artemis.core.journal.RecordInfo: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader: DEV@1eb5174b
(build-40) Unable to properly register the hierarchy of the following classes for reflection as they are not in the Jandex index:
    - io.mashona.logwriting.ArrayStore (source: ResteasyReactiveProcessor > blah.MyResource[AnotherResource getAnotherResource(java.lang.String aStr)])
    - jakarta.jms.BytesMessage (source: ResteasyReactiveProcessor > blah.MyResource[AnotherResource getAnotherResource(java.lang.String aStr)])
    - jakarta.jms.Connection (source: ResteasyReactiveProcessor > blah.MyResource[AnotherResource getAnotherResource(java.lang.String aStr)])
    - jakarta.jms.ConnectionMetaData (source: ResteasyReactiveProcessor > blah.MyResource[AnotherResource getAnotherResource(java.lang.String aStr)])
    - jakarta.jms.ExceptionListener (source: ResteasyReactiveProcessor > blah.MyResource[AnotherResource getAnotherResource(java.lang.String aStr)])
    - jakarta.jms.MapMessage (source: ResteasyReactiveProcessor > blah.MyResource[AnotherResource getAnotherResource(java.lang.String aStr)])
    - jakarta.jms.Message (source: ResteasyReactiveProcessor > blah.MyResource[AnotherResource getAnotherResource(java.lang.String aStr)])
    - jakarta.jms.MessageListener (source: ResteasyReactiveProcessor > blah.MyResource[AnotherResource getAnotherResource(java.lang.String aStr)])
    - jakarta.jms.ObjectMessage (source: ResteasyReactiveProcessor > blah.MyResource[AnotherResource getAnotherResource(java.lang.String aStr)])
    - jakarta.jms.Session (source: ResteasyReactiveProcessor > blah.MyResource[AnotherResource getAnotherResource(java.lang.String aStr)])
    - jakarta.jms.StreamMessage (source: ResteasyReactiveProcessor > blah.MyResource[AnotherResource getAnotherResource(java.lang.String aStr)])
    - jakarta.jms.TemporaryQueue (source: ResteasyReactiveProcessor > blah.MyResource[AnotherResource getAnotherResource(java.lang.String aStr)])
    - jakarta.jms.TemporaryTopic (source: ResteasyReactiveProcessor > blah.MyResource[AnotherResource getAnotherResource(java.lang.String aStr)])
    - jakarta.jms.TextMessage (source: ResteasyReactiveProcessor > blah.MyResource[AnotherResource getAnotherResource(java.lang.String aStr)])
    - jakarta.jms.XAConnection (source: ResteasyReactiveProcessor > blah.MyResource[AnotherResource getAnotherResource(java.lang.String aStr)])
    - jakarta.jms.XAConnectionFactory (source: ResteasyReactiveProcessor > blah.MyResource[AnotherResource getAnotherResource(java.lang.String aStr)])
    - jakarta.jms.XASession (source: ResteasyReactiveProcessor > blah.MyResource[AnotherResource getAnotherResource(java.lang.String aStr)])
    - org.apache.activemq.artemis.core.journal.Journal (source: ResteasyReactiveProcessor > blah.MyResource[AnotherResource getAnotherResource(java.lang.String aStr)])
    - org.apache.activemq.artemis.core.journal.RecordInfo (source: ResteasyReactiveProcessor > blah.MyResource[AnotherResource getAnotherResource(java.lang.String aStr)])
Consider adding them to the index either by creating a Jandex index for your dependency via the Maven plugin, an empty META-INF/beans.xml or quarkus.index-dependency properties.

How to Reproduce?

I've attached a simple project here that demonstrates the issue:

jandex-transaction-issue.zip

Basic steps to reproduce the whole project.

  1. Generate code-with-quarkus project using Quarkus CLI
  2. Modify GreetingResource to return a sub-resource:
@Context
ResourceContext resourceContext;

  @Path("/another")
    public AnotherResource getAnotherResource() {
        return resourceContext.getResource(AnotherResource.class);
    }
  1. In the sub-resource, inject UserTransaction. Note: Our @Transactional method does not use the UserTransaction. It only needs to be injected to cause issues.
@ApplicationScoped
@Unremovable
public class AnotherResource {

    @Inject
    UserTransaction userTransaction;

    @POST
    @Transactional
    @Path("/world")
    public String hello() {
        return "Hello from RESTEasy Reactive";
    }
}
  1. Not sure if it's necessary, but in the sample project I added Panache and quarkus-jdbc-mysql. And then finally, I set up some basic hibernate-orm properties in application.properties to connect to the DB. I also needed one entity - otherwise Quarkus does not load Hibernate.
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-hibernate-orm-panache</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-jdbc-mysql</artifactId>
    </dependency>

Note:
In our real world app, we are injecting UserTransaction in a pure-Java business layer (separate Jar) that we try to keep Quarkus/framework-agnostic. So we'd rather not replace with QuarkusTransaction if possible. But the same problem exists just injecting it into the resource class.

Output of uname -a or ver

Darwin Kernel Version 22.3.0

Output of java -version

openjdk version "17.0.2" 2022-01-18 LTS

GraalVM version (if different from Java)

No response

Quarkus version or git rev

3.3.3

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

No response

Additional information

No response

@jonjanisch jonjanisch added the kind/bug Something isn't working label Sep 20, 2023
geoand added a commit to geoand/quarkus that referenced this issue Sep 21, 2023
geoand added a commit that referenced this issue Sep 21, 2023
Don't register subresource for reflection based on their use as a return type
@quarkus-bot quarkus-bot bot added this to the 3.5 - main milestone Sep 21, 2023
michelle-purcell pushed a commit to michelle-purcell/quarkus that referenced this issue Sep 21, 2023
@gsmet gsmet modified the milestones: 3.5 - main, 3.4.2 Oct 3, 2023
gsmet pushed a commit to gsmet/quarkus that referenced this issue Oct 3, 2023
@aloubyansky aloubyansky modified the milestones: 3.4.2, 3.2.8.Final Oct 31, 2023
aloubyansky pushed a commit to aloubyansky/quarkus that referenced this issue Oct 31, 2023
holly-cummins pushed a commit to holly-cummins/quarkus that referenced this issue Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants