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

Multipart Class Defined Outside Resource Implementation Fails with CNFE "Populator" #19037

Closed
kjq opened this issue Jul 27, 2021 · 9 comments · Fixed by #19070
Closed

Multipart Class Defined Outside Resource Implementation Fails with CNFE "Populator" #19037

kjq opened this issue Jul 27, 2021 · 9 comments · Fixed by #19070
Labels
area/rest kind/bug Something isn't working
Milestone

Comments

@kjq
Copy link

kjq commented Jul 27, 2021

Describe the bug

When I define a class meant to be used as a payload in both my REST client and resource I get a CNFE stating that the "populator" could not be located. If I put the class with the resource it works fine.

Referencing a conversation with Michal on Google Groups.

Issue 1 demonstrates the error / Working 2 demonstrates what worked:

reproduce-issue1.zip
reproduce-working2.zip

NOTE: Hopefully I did not mix up my reproducers.

Expected behavior

Class defined in a separate module can be used as the payload from the client and in the resource.

Actual behavior

Class not found exception - "Populator" when the payload is defined in another module.

ClassNotFoundException: io.platform.api.publish.FilePackage_generated_populator

How to Reproduce?

Run mvn clean install on the issue attached above

Output of uname -a or ver

Ubuntu / WSL

Output of java -version

JDK 11 in the POM / 15 as the default.

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.0.3.Final

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

3.8.1

Additional information

I forgot to include the Jandex plugin in my reproducer but my modules all are invoking it (and I see the IDX file). I have also tried adding a beans.xml but that did not help. Anything but the multipart payload seems to work though when separated between an API jar and the service jar.

@quarkus-bot
Copy link

quarkus-bot bot commented Jul 27, 2021

/cc @FroMage, @geoand, @stuartwdouglas

@geoand
Copy link
Contributor

geoand commented Jul 28, 2021

@michalszynkiewicz let me know if you need anything from me on this one

@michalszynkiewicz
Copy link
Member

The weird thing is, the class is there, generated.

@stuartwdouglas
Copy link
Member

It is likely ending up in the wrong ClassLoader, which is determined by io.quarkus.deployment.builditem.GeneratedClassBuildItem#applicationClass

@michalszynkiewicz
Copy link
Member

So, it is set to be an application class.
But it is the same in the case of having the payload class in the same module, and it works...
When I change applicationClass to false for it, it fails to load the interface class (in this case api.FilePayload) - and it fails like that also in Quarkus tests

@michalszynkiewicz
Copy link
Member

@geoand if you could take a look at it, I'd be grateful :)

@geoand
Copy link
Contributor

geoand commented Jul 28, 2021

I'll have a look tomorrow

@geoand
Copy link
Contributor

geoand commented Jul 28, 2021

The reason this works in dev-mode and not in test-mode is that dev-mode includes the classes of the dependent api module in the Runtime Class Loader (which is also the ClassLoader that contains the generated io.platform.api.publish.FilePackage_generated_populator) while in test-mode that class is part of the Base Runtime ClassLoader which of course means that the populator class cannot be loaded (as this ClassLoader is the parent of Runtime Class Loader).

@aloubyansky @stuartwdouglas is there a good reason why we have this difference?

If the current behavior is something we do want to maintain, I can work around it

@geoand
Copy link
Contributor

geoand commented Jul 28, 2021

#19068 is the fix for the current state of afairs

stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue Jul 29, 2021
@quarkus-bot quarkus-bot bot added this to the 2.2 - main milestone Jul 29, 2021
@gsmet gsmet modified the milestones: 2.2 - main, 2.1.1.Final Aug 3, 2021
gsmet pushed a commit to gsmet/quarkus that referenced this issue Aug 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/rest kind/bug Something isn't working
Projects
None yet
5 participants