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

MongoDB BSON types are not in the Jandex index #17893

Closed
afedotov opened this issue Jun 14, 2021 · 2 comments · Fixed by #17895
Closed

MongoDB BSON types are not in the Jandex index #17893

afedotov opened this issue Jun 14, 2021 · 2 comments · Fixed by #17895
Assignees
Labels
area/mongodb kind/bug Something isn't working
Milestone

Comments

@afedotov
Copy link
Contributor

Describe the bug

When building Quarkus application that using mongodb-client and mongodb-panache extentions, ReflectiveHierarchyStep grumbles:

[WARNING] [io.quarkus.deployment.steps.ReflectiveHierarchyStep] Unable to properly register the hierarchy of the following classes for reflection as they are not in the Jandex index:
	- org.bson.types.ObjectId (source: <unknown>)
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.

To Reproduce

Create a sample application:

mvn io.quarkus:quarkus-maven-plugin:1.13.7.Final:create \
    -DprojectGroupId=org.acme \
    -DprojectArtifactId=getting-started \
    -Dextensions=resteasy,mongodb-client,mongodb-panache

Add sample entity:

package org.acme;

import io.quarkus.mongodb.panache.MongoEntity;

@MongoEntity
public class SampleEntity {
}

Add sample repository:

package org.acme;

import javax.enterprise.context.ApplicationScoped;
import io.quarkus.mongodb.panache.PanacheMongoRepository;

@ApplicationScoped
public class SampleRepository implements PanacheMongoRepository<SampleEntity> {
}

Build project and observe mentioned message:

mvn clean package -DskipTests

Environment

$ uname -a
Darwin mbp 20.5.0 Darwin Kernel Version 20.5.0: Sat May  8 05:10:33 PDT 2021; root:xnu-7195.121.3~9/RELEASE_X86_64 x86_64

$ java -version
openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9)
OpenJDK 64-Bit Server VM AdoptOpenJDK-11.0.11+9 (build 11.0.11+9, mixed mode)

$ mvn --version
Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: /opt/local/share/java/maven3
Java version: 11.0.11, vendor: AdoptOpenJDK, runtime: /Library/Java/JavaVirtualMachines/openjdk11/Contents/Home
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "11.4", arch: "x86_64", family: "mac"

Quarkus version or git rev

1.13.7.Final, also tried build from main branch:

$ git describe --all --tags --always --long
heads/main-0-gfc31727672

Additional info

To resolve issue already tried to add org.mongodb:bson to quarkus.index-dependency.
The problem here is that all classes within bson library is added to Jandex index, including all CodecProvider's. This causes MongoClientProcessor to register all internal codec providers again, and fail on many of this that does not have default no-arg constructor.

The better solution is to add BuildStep in mongodb-client extention, that should explicitly add only org.bson.types.* classes to Jandex index. I'll try to provide PR with fix for this issue.

@afedotov afedotov added the kind/bug Something isn't working label Jun 14, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Jun 14, 2021

/cc @evanchooly, @loicmathieu

@loicmathieu
Copy link
Contributor

Thanks for reporting this one @afedotov , I'm aware of it since a long time, this is just an harmless warning, your application will works without any issue.

I agree this needs to be workedaround to avoid people asking themself if it's a rela issue or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/mongodb kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants