wildfly-extras / wildfly-graphql-feature-pack

5 stars 6 forks source link

EAR application using graphql query don't work (WildFly 20.0.1) or the application doesn't deploy (WildFly 24.0.1) #78

Closed DarrellWu closed 2 months ago

DarrellWu commented 3 years ago

Hi,

I'm trying to get graphql working with an ear deployment package. In Wildfly 20.0.1 the application deploys and runs but when running a graphql query i get the following response

{ "errors": [ { "message": "Server Error", "locations": [ { "line": 1, "column": 2 } ], "path": [ "allMembers" ], "extensions": { "exception": "org.jboss.weld.exceptions.UnsatisfiedResolutionException", "classification": "DataFetchingException", "code": "unsatisfied-resolution" } } ], "data": { "allMembers": null } }

I tried the same app on WildFly 24.0.1 and the application fails to deploy with


[ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 93) MSC000001: Failed to start service jboss.deployment.subunit."webapp-ear.ear"."webapp-web.war".undertow-deployment: org.jboss.msc.service.StartException in service jboss.deployment.subunit."webapp-ear.ear"."webapp-web.war".undertow-deployment: java.lang.RuntimeException: java.lang.RuntimeException: SRGQL000020: Can not inject an instance of class [com.oneplaceonline.ear.webapp.rest.MemberGraphQLResource]. Please make sure it is a CDI bean, also possibly the beans.xml file is needed
      at org.wildfly.extension.undertow@24.0.1.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:90)
      at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
      at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
      at org.jboss.threads@2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
      at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
      at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
      at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
      at java.base/java.lang.Thread.run(Thread.java:829)
      at org.jboss.threads@2.4.0.Final//org.jboss.threads.JBossThread.run(JBossThread.java:513)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: SRGQL000020: Can not inject an instance of class [com.oneplaceonline.ear.webapp.rest.MemberGraphQLResource]. Please make sure it is a CDI bean, also possibly the beans.xml file is needed
      at io.undertow.servlet@2.2.8.Final//io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:257)
      at org.wildfly.extension.undertow@24.0.1.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:105)
      at org.wildfly.extension.undertow@24.0.1.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:87)
      ... 8 more
Caused by: java.lang.RuntimeException: SRGQL000020: Can not inject an instance of class [com.oneplaceonline.ear.webapp.rest.MemberGraphQLResource]. Please make sure it is a CDI bean, also possibly the beans.xml file is needed
      at io.smallrye.graphql@4.8//io.smallrye.graphql.bootstrap.Bootstrap.lambda$verifyInjectionIsAvailable$1(Bootstrap.java:141)
      at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
      at java.base/java.util.stream.DistinctOps$1$2.accept(DistinctOps.java:175)
      at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
      at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
      at java.base/java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1603)
      at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
      at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
      at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
      at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
      at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
      at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:274)
      at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
      at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
      at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
      at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
      at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
      at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
      at io.smallrye.graphql@4.8//io.smallrye.graphql.bootstrap.Bootstrap.verifyInjectionIsAvailable(Bootstrap.java:136)
      at io.smallrye.graphql@4.8//io.smallrye.graphql.bootstrap.Bootstrap.<init>(Bootstrap.java:116)
      at io.smallrye.graphql@4.8//io.smallrye.graphql.bootstrap.Bootstrap.bootstrap(Bootstrap.java:103)
      at io.smallrye.graphql@4.8//io.smallrye.graphql.cdi.producer.GraphQLProducer.initialize(GraphQLProducer.java:30)
      at io.smallrye.graphql@4.8//io.smallrye.graphql.cdi.producer.GraphQLProducer.initialize(GraphQLProducer.java:25)
      at io.smallrye.graphql@4.8//io.smallrye.graphql.cdi.producer.GraphQLProducer$Proxy$_$$_WeldClientProxy.initialize(Unknown Source)
      at io.smallrye.graphql@4.8//io.smallrye.graphql.entry.http.StartupListener.contextInitialized(StartupListener.java:58)
      at io.undertow.servlet@2.2.8.Final//io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:187)
      at io.undertow.servlet@2.2.8.Final//io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:219)
      at io.undertow.servlet@2.2.8.Final//io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:187)
      at io.undertow.servlet@2.2.8.Final//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
      at io.undertow.servlet@2.2.8.Final//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
      at org.wildfly.extension.undertow@24.0.1.Final//org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
      at org.wildfly.extension.undertow@24.0.1.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1535)
      at org.wildfly.extension.undertow@24.0.1.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1535)
      at org.wildfly.extension.undertow@24.0.1.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1535)
      at org.wildfly.extension.undertow@24.0.1.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1535)
      at org.wildfly.extension.undertow@24.0.1.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1535)
      at io.undertow.servlet@2.2.8.Final//io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:255)
      ... 10 more
Caused by: org.jboss.weld.exceptions.UnsatisfiedResolutionException: WELD-001334: Unsatisfied dependencies for type MemberGraphQLResource with qualifiers  
      at org.jboss.weld.core@3.1.7.SP1//org.jboss.weld.bean.builtin.InstanceImpl.checkBeanResolved(InstanceImpl.java:241)
      at org.jboss.weld.core@3.1.7.SP1//org.jboss.weld.bean.builtin.InstanceImpl.get(InstanceImpl.java:113)
      at io.smallrye.graphql@4.8//io.smallrye.graphql.cdi.CdiLookupService.getInstance(CdiLookupService.java:27)
      at io.smallrye.graphql@4.8//io.smallrye.graphql.cdi.CdiLookupService.getClass(CdiLookupService.java:21)
      at io.smallrye.graphql@4.8//io.smallrye.graphql.bootstrap.Bootstrap.lambda$verifyInjectionIsAvailable$1(Bootstrap.java:139)
      ... 48 more

11:19:46,158 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "webapp-ear.ear")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.deployment.subunit.\"webapp-ear.ear\".\"webapp-web.war\".undertow-deployment" => "java.lang.RuntimeException: java.lang.RuntimeException: SRGQL000020: Can not inject an instance of class [com.oneplaceonline.ear.webapp.rest.MemberGraphQLResource]. Please make sure it is a CDI bean, also possibly the beans.xml file is needed
    Caused by: java.lang.RuntimeException: java.lang.RuntimeException: SRGQL000020: Can not inject an instance of class [com.oneplaceonline.ear.webapp.rest.MemberGraphQLResource]. Please make sure it is a CDI bean, also possibly the beans.xml file is needed
    Caused by: java.lang.RuntimeException: SRGQL000020: Can not inject an instance of class [com.oneplaceonline.ear.webapp.rest.MemberGraphQLResource]. Please make sure it is a CDI bean, also possibly the beans.xml file is needed
    Caused by: org.jboss.weld.exceptions.UnsatisfiedResolutionException: WELD-001334: Unsatisfied dependencies for type MemberGraphQLResource with qualifiers  "}}](url)

Any chance EAR package will be supported

jmartisk commented 3 years ago

Hi, I'd really like to support that, but I'll need to find out how to do it.

WildFly has got its, in my opinion, somewhat weird CDI behavior for EAR archives, where it creates a separate BeanManager for every JAR (it seems that not only for every JAR/WAR in the EAR, but including static modules - basically every CDI-enabled archive that is involved in the app). And when SmallRye GraphQL code wants to perform programmatic injection and calls CDI.current(), it receives a CDI instance for the BeanManager owned by the JAR that contains this call. Unfortunately, that JAR in our case is smallrye-graphql-cdi.jar, and its BeanManager does not 'see' the beans contained in the application, hence an attempt to inject will fail. Weirdly, when you deploy a WAR only, then that BeanManager can see those beans, but not with EAR.

I really don't know how to fix the EAR case, it might be a design issue of WildFly, or something that is configurable... somehow.

cghislai commented 1 year ago

I rememeber a similar issue with Soteria. See https://issues.redhat.com/browse/WELD-2510 for reference: getting the bean manager instance using JNDI lookup should work as expected.

jmartisk commented 2 months ago

I've marked EAR deployments explicitly as unsupported in the main README. This is in line with the support policies of the MicroProfile expansion pack for JBoss EAP (see https://access.redhat.com/articles/2026253)