[jboss-jira] [JBoss JIRA] (WFLY-7371) JAXRS endpoint - CDI injection to constructor doesn't work

Ron Sigal (Jira) issues at jboss.org
Fri Feb 22 10:45:02 EST 2019


     [ https://issues.jboss.org/browse/WFLY-7371?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ron Sigal resolved WFLY-7371.
-----------------------------
    Resolution: Rejected


As per the analysis in upstream RESTEASY-1538, this issue is properly considered an enhancement rather than a bug. If it a desirable enhancement, it can be re-opened as such.

> JAXRS endpoint - CDI injection to constructor doesn't work
> ----------------------------------------------------------
>
>                 Key: WFLY-7371
>                 URL: https://issues.jboss.org/browse/WFLY-7371
>             Project: WildFly
>          Issue Type: Bug
>          Components: CDI / Weld, REST
>    Affects Versions: 10.1.0.Final
>            Reporter: Tomas Remes
>            Assignee: Ron Sigal
>            Priority: Major
>
> Deploying app with following JAXRS endpoint 
> {code}
> @Path("/test")
> public class MyTimeResource {
>     private final LocalDateTime dateTime;
>     @Inject
>     public MyTimeResource(LocalDateTime dateTime){
>         this.dateTime = dateTime;
>     };
> }
> {code}
> is failing with following stack trace:
> {noformat}
> Caused by: java.lang.RuntimeException: RESTEASY003190: Could not find constructor for class: org.example.microprofile.MyTimeResource
> 	at org.jboss.resteasy.spi.metadata.ResourceBuilder.constructor(ResourceBuilder.java:692)
> 	at org.jboss.resteasy.plugins.server.resourcefactory.POJOResourceFactory.registered(POJOResourceFactory.java:42)
> 	at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:208)
> 	at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:194)
> 	at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:180)
> 	at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:157)
> 	at org.jboss.resteasy.core.ResourceMethodRegistry.addPerRequestResource(ResourceMethodRegistry.java:76)
> 	at org.jboss.resteasy.spi.ResteasyDeployment.registration(ResteasyDeployment.java:409)
> 	at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:250)
> 	at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:113)
> 	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:36)
> 	at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117)
> 	at org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:78)
> 	at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103)
> 	at io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:250)
> 	at io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:133)
> 	at io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:546)
> 	at io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:517)
> 	at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
> 	at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
> 	at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
> 	at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
> 	at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
> 	at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
> 	at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
> 	at io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:559)
> 	at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:101)
> 	at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:82)
> 	... 6 more
> {noformat}
> Note that app contains beans.xml so the JAXRS resource should be really managed by CDI.



--
This message was sent by Atlassian Jira
(v7.12.1#712002)


More information about the jboss-jira mailing list