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

resteasy-reactive-jaxb does not work nicely together with multipart/form-data FileUpload #28524

Closed
Postremus opened this issue Oct 12, 2022 · 3 comments · Fixed by #28570
Closed
Labels
area/jaxb area/rest kind/bug Something isn't working
Milestone

Comments

@Postremus
Copy link
Member

Postremus commented Oct 12, 2022

Describe the bug

I have 3 resteasy-reactive resources in my project:

  • one which returns application/xml
  • one which consumes multipart/form-data. This uses a org.jboss.resteasy.reactive.multipart.FileUpload.
  • one which returns text/plain

The text/plain one works correctly.
The multipart/form-data one also works correctly.

The application/xml one however complains about the FileUpload which is used in the other resource. See exception below.
FileUpload is an Interface, and can't be marshalled / unmarshaled by default.

The FileUpload class is bound because each parameter type of a multipart/form-data resource is getting bound to one jaxb context.

// If consumes "application/xml" or "multipart/form-data", we register all the classes of the parameters
if (consumesXml(resourceInfo) || consumesMultipart(resourceInfo)) {
for (Type parameter : methodInfo.parameterTypes()) {
ClassInfo effectiveParameter = getEffectiveClassInfo(parameter, indexView);
if (effectiveParameter != null) {
classesInfo.add(effectiveParameter);
}
}
}
}

One solution would be to create distinct JaxbContext instances for each resource.

Using java.io.File instead works, however in that case I can't access the mimetype easily.

Expected behavior

No exception when using multipart/form-data and application/xml in the same project.

Actual behavior

2022-10-12 08:28:22,045 ERROR [org.jbo.res.rea.com.cor.AbstractResteasyReactiveContext] (executor-thread-0) Request failed: java.lang.RuntimeException: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
org.jboss.resteasy.reactive.multipart.FileUpload ist eine Schnittstelle, und JAXB kann keine Schnittstellen verarbeiten.
        this problem is related to the following location:
                at org.jboss.resteasy.reactive.multipart.FileUpload
                at public org.jboss.resteasy.reactive.multipart.FileUpload org.acme.FileUploadData.fileUpload
                at org.acme.FileUploadData

        at io.quarkus.jaxb.runtime.JaxbContextProducer.jaxbContext(JaxbContextProducer.java:44)
        at io.quarkus.jaxb.runtime.JaxbContextProducer_Subclass.jaxbContext$$superforward1(Unknown Source)
        at io.quarkus.jaxb.runtime.JaxbContextProducer_Subclass$$function$$3.apply(Unknown Source)
        at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54)
        at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:62)
        at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:49)
        at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(Unknown Source)
        at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:42)
        at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41)
        at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:33)
        at io.quarkus.jaxb.runtime.JaxbContextProducer_Subclass.jaxbContext(Unknown Source)
        at io.quarkus.jaxb.runtime.JaxbContextProducer_ProducerMethod_jaxbContext_bd8f21cf3f403916a32bb5db1dc1007aab351487_Bean.create(Unknown Source)
        at io.quarkus.jaxb.runtime.JaxbContextProducer_ProducerMethod_jaxbContext_bd8f21cf3f403916a32bb5db1dc1007aab351487_Bean.create(Unknown Source)
        at io.quarkus.arc.impl.AbstractSharedContext.createInstanceHandle(AbstractSharedContext.java:113)
        at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:37)
        at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:34)
        at io.quarkus.arc.impl.LazyValue.get(LazyValue.java:26)
        at io.quarkus.arc.impl.ComputingCache.computeIfAbsent(ComputingCache.java:69)
        at io.quarkus.arc.impl.AbstractSharedContext.get(AbstractSharedContext.java:34)
        at io.quarkus.jaxb.runtime.JaxbContextProducer_ProducerMethod_jaxbContext_bd8f21cf3f403916a32bb5db1dc1007aab351487_Bean.get(Unknown Source)
        at io.quarkus.jaxb.runtime.JaxbContextProducer_ProducerMethod_jaxbContext_bd8f21cf3f403916a32bb5db1dc1007aab351487_Bean.get(Unknown Source)
        at io.quarkus.jaxb.runtime.JaxbContextProducer_ProducerMethod_marshaller_4f8d16bb162b44aa8bbc0b7b364931bb173b516e_Bean.create(Unknown Source)
        at io.quarkus.jaxb.runtime.JaxbContextProducer_ProducerMethod_marshaller_4f8d16bb162b44aa8bbc0b7b364931bb173b516e_Bean.create(Unknown Source)
        at io.quarkus.arc.impl.RequestContext.getIfActive(RequestContext.java:76)
        at io.quarkus.arc.impl.ClientProxies.getDelegate(ClientProxies.java:30)
        at javax.xml.bind.JaxbContextProducer_ProducerMethod_marshaller_4f8d16bb162b44aa8bbc0b7b364931bb173b516e_ClientProxy.arc$delegate(Unknown Source)
        at javax.xml.bind.JaxbContextProducer_ProducerMethod_marshaller_4f8d16bb162b44aa8bbc0b7b364931bb173b516e_ClientProxy.marshal(Unknown Source)
        at io.quarkus.resteasy.reactive.jaxb.runtime.serialisers.ServerJaxbMessageBodyWriter.marshal(ServerJaxbMessageBodyWriter.java:57)
        at io.quarkus.resteasy.reactive.jaxb.runtime.serialisers.ServerJaxbMessageBodyWriter.writeResponse(ServerJaxbMessageBodyWriter.java:43)
        at org.jboss.resteasy.reactive.server.core.ServerSerialisers.invokeWriter(ServerSerialisers.java:216)
        at org.jboss.resteasy.reactive.server.core.ServerSerialisers.invokeWriter(ServerSerialisers.java:187)
        at org.jboss.resteasy.reactive.server.core.serialization.FixedEntityWriter.write(FixedEntityWriter.java:28)
        at org.jboss.resteasy.reactive.server.handlers.ResponseWriterHandler.handle(ResponseWriterHandler.java:34)
        at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:121)
        at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:142)
        at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:564)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
org.jboss.resteasy.reactive.multipart.FileUpload ist eine Schnittstelle, und JAXB kann keine Schnittstellen verarbeiten.
        this problem is related to the following location:
                at org.jboss.resteasy.reactive.multipart.FileUpload
                at public org.jboss.resteasy.reactive.multipart.FileUpload org.acme.FileUploadData.fileUpload
                at org.acme.FileUploadData

        at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:76)
        at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:441)
        at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:273)
        at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:109)
        at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1126)
        at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:135)
        at com.sun.xml.bind.v2.JAXBContextFactory.createContext(JAXBContextFactory.java:35)
        at javax.xml.bind.ContextFinder.find(ContextFinder.java:393)
        at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:691)
        at io.quarkus.jaxb.runtime.JaxbContextProducer.jaxbContext(JaxbContextProducer.java:42)
        ... 41 more

How to Reproduce?

  1. Download the reproducer:
    multipart-jaxb-fileinput.zip
  2. Either execute the Test GreetingResourceTest
  3. Or mvn quarkus:dev and visit http://localhost:8080/hello/xml

Output of uname -a or ver

Microsoft Windows [Version 10.0.19044.2006]

Output of java -version

17.0.4

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.13.1.Final

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

Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537) Maven home: C:\eclipse\tools\java\maven Java version: 17.0.4, vendor: Eclipse Adoptium, runtime: C:\eclipse\tools\java\17 Default locale: de_DE, platform encoding: Cp1252 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Additional information

No response

@Postremus Postremus added the kind/bug Something isn't working label Oct 12, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Oct 12, 2022

@quarkus-bot quarkus-bot bot added area/jaxb area/rest env/windows Impacts Windows machines labels Oct 12, 2022
@Postremus Postremus removed the env/windows Impacts Windows machines label Oct 12, 2022
@Postremus
Copy link
Member Author

I attached an reproducer to the starting post.

@Sgitario
Copy link
Contributor

@Postremus, I've just linked a pull request with a fix

@quarkus-bot quarkus-bot bot added this to the 2.14 - main milestone Oct 13, 2022
@gsmet gsmet modified the milestones: 2.14 - main, 2.13.3.Final Oct 17, 2022
gsmet pushed a commit to gsmet/quarkus that referenced this issue Oct 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/jaxb area/rest kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants