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

DefaultConfigurationFactory not found in Quarkus 2.7.1.Final native application with quarkus-spring-security #23621

Closed
bkzoller opened this issue Feb 11, 2022 · 2 comments · Fixed by #23650
Assignees
Labels
area/security area/spring Issues relating to the Spring integration kind/bug Something isn't working
Milestone

Comments

@bkzoller
Copy link

bkzoller commented Feb 11, 2022

Describe the bug

I have a project which is on Quarkus 1.11.5.Final and uses quarkus-spring-web and quarkus-spring-security. When I tried upgrading the application to Quarkus 2.7.1.Final, it works in JVM mode but fails in native mode.

To reproduce, download the bug reproducer project.

  1. mvn clean quarkus:dev
  2. http://localhost:8080/greeting/world -> works normally and returns {"message": "HELLO WORLD!"}
  3. pass a JWT header or JWT cookie to the request and it returns the user in the message {"message": "HELLO [email protected]!"}

Now build using the native image:

  1. mvn clean verify -Pnative
  2. ./target/spring-web-quickstart-1.0.0-SNAPSHOT-runner
  3. http://localhost:8080/greeting/world -> results in exception below
[io.quarkus] INFO  spring-web-quickstart 1.0.0-SNAPSHOT native (powered by Quarkus 2.7.1.Final) started in 0.041s. Listening on: http://0.0.0.0:8080
[io.quarkus] INFO  Profile prod activated. 
[io.quarkus] INFO  Installed features: [cdi, resteasy, resteasy-jackson, security, smallrye-context-propagation, spring-di, spring-security, spring-web, vertx]
[io.qua.ver.htt.run.QuarkusErrorHandler] ERROR HTTP Request to /greeting/world failed, error id: 9e7f1917-38a8-41ad-b7e1-752e7725be89-1: java.util.ServiceConfigurationError: org.jboss.resteasy.spi.config.ConfigurationFactory: Provider org.jboss.resteasy.core.config.DefaultConfigurationFactory not found
	at java.util.ServiceLoader.fail(ServiceLoader.java:589)
	at java.util.ServiceLoader$LazyClassPathLookupIterator.nextProviderClass(ServiceLoader.java:1212)
	at java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:106)
	at java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1265)
	at java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1300)
	at java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1385)
	at org.jboss.resteasy.spi.config.ConfigurationFactory.getInstance(ConfigurationFactory.java:46)
	at org.jboss.resteasy.plugins.providers.jackson.WhiteListPolymorphicTypeValidatorBuilder.<init>(WhiteListPolymorphicTypeValidatorBuilder.java:17)
	at org.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider.writeTo(ResteasyJackson2Provider.java:237)
	at org.jboss.resteasy.core.messagebody.AsyncBufferedMessageBodyWriter.asyncWriteTo(AsyncBufferedMessageBodyWriter.java:24)
	at org.jboss.resteasy.core.interception.jaxrs.ServerWriterInterceptorContext.writeTo(ServerWriterInterceptorContext.java:87)
	at org.jboss.resteasy.core.interception.jaxrs.AbstractWriterInterceptorContext.asyncProceed(AbstractWriterInterceptorContext.java:203)
	at org.jboss.resteasy.core.interception.jaxrs.AbstractWriterInterceptorContext.getStarted(AbstractWriterInterceptorContext.java:166)
	at org.jboss.resteasy.core.interception.jaxrs.ServerWriterInterceptorContext.lambda$getStarted$0(ServerWriterInterceptorContext.java:73)
	at org.jboss.resteasy.core.interception.jaxrs.ServerWriterInterceptorContext.aroundWriteTo(ServerWriterInterceptorContext.java:93)
	at org.jboss.resteasy.core.interception.jaxrs.ServerWriterInterceptorContext.getStarted(ServerWriterInterceptorContext.java:73)
	at org.jboss.resteasy.core.ServerResponseWriter.lambda$writeNomapResponse$3(ServerResponseWriter.java:163)
	at org.jboss.resteasy.core.interception.jaxrs.ContainerResponseContextImpl.filter(ContainerResponseContextImpl.java:404)
	at org.jboss.resteasy.core.ServerResponseWriter.executeFilters(ServerResponseWriter.java:252)
	at org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse(ServerResponseWriter.java:101)
	at org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse(ServerResponseWriter.java:74)
	at org.jboss.resteasy.core.SynchronousDispatcher.writeResponse(SynchronousDispatcher.java:594)
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:524)
	at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:261)
	at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:161)
	at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
	at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:164)
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:247)
	at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73)
	at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:151)
	at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler$1.run(VertxRequestHandler.java:91)
	at io.quarkus.vertx.core.runtime.VertxCoreRecorder$13.runWith(VertxCoreRecorder.java:543)
	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.lang.Thread.run(Thread.java:829)
	at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:597)
	at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:194)

Expected behavior

The application should work in native mode the same as JVM mode.

Actual behavior

The exception in ServiceLoader.java points to the ConfigurationFactory class not being registered for reflection in native mode, which is why DefaultConfigurationFactory could not be found.

            try {
                return Class.forName(cn, false, loader);
            } catch (ClassNotFoundException x) {
                fail(service, "Provider " + cn + " not found");
                return null;
            }

How to Reproduce?

Reproducer: https://github.com/bkzoller/quarkus-quickstarts/tree/bug/quarkus-spring-web/spring-web-quickstart

See description above for the steps to reproduce the bug.

Output of uname -a or ver

Darwin Brians-MBP.fios-router.home 21.2.0 Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:54 PST 2021; root:xnu-8019.61.5~1/RELEASE_X86_64 x86_64

Output of java -version

OpenJDK 64-Bit Server VM Temurin-11.0.14+9 (build 11.0.14+9, mixed mode)

GraalVM version (if different from Java)

22.0.0.2 or 21.3.1

Quarkus version or git rev

2.7.1.Final, 2.6.3.Final and main branch

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

Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537) Maven home: /usr/local/Cellar/maven/3.8.4/libexec Java version: 11.0.14, vendor: Eclipse Adoptium, runtime: /Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home Default locale: en_US, platform encoding: UTF-8 OS name: "mac os x", version: "12.1", arch: "x86_64", family: "mac"

Additional information

No response

@bkzoller bkzoller added the kind/bug Something isn't working label Feb 11, 2022
@quarkus-bot quarkus-bot bot added area/security area/spring Issues relating to the Spring integration labels Feb 11, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Feb 11, 2022

/cc @geoand, @sberyozkin

@bkzoller
Copy link
Author

Adding this class to the reproducer project fixes the exception.

package org.acme.spring.web;

import io.quarkus.runtime.annotations.RegisterForReflection;
import org.jboss.resteasy.core.config.DefaultConfigurationFactory;

@RegisterForReflection(targets = {DefaultConfigurationFactory.class})
public class ReflectionConfiguration {
}

@geoand geoand self-assigned this Feb 13, 2022
geoand added a commit to geoand/quarkus that referenced this issue Feb 13, 2022
geoand added a commit that referenced this issue Feb 13, 2022
Register RESTEasy's ConfigurationFactory impls in GraalVM
@quarkus-bot quarkus-bot bot added this to the 2.8 - main milestone Feb 13, 2022
@gsmet gsmet modified the milestones: 2.8 - main, 2.7.2.Final Feb 21, 2022
gsmet pushed a commit to gsmet/quarkus that referenced this issue Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/security area/spring Issues relating to the Spring integration kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants