You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Vladimir Kulev (JIRA)" <ji...@apache.org> on 2015/12/03 22:15:11 UTC
[jira] [Updated] (CXF-6694) SpringResourceFactory does not work
with constructor-autowired beans
[ https://issues.apache.org/jira/browse/CXF-6694?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Vladimir Kulev updated CXF-6694:
--------------------------------
Attachment: CXF-6694.patch
Here is a patch which fixes my problem. Also I wrote an example Spring Boot application to demonstrate use case:
{code:java}
@SpringBootApplication
@Import(SpringComponentScanServer.class)
public class CxfExampleApplication {
public static void main(String[] args) {
SpringApplication.run(CxfExampleApplication.class, args);
}
@Bean
public ServletRegistrationBean servletRegistrationBean() {
return new ServletRegistrationBean(new CXFServlet(), "/api/*");
}
@Bean
public Backend backend() {
return new Backend();
}
@Bean
public Frontend frontend() {
return new Frontend(backend());
}
@Path("/")
public static class Frontend {
private final Backend backend;
public Frontend(Backend backend) {
this.backend = backend;
}
@Path("/status")
@GET
public String getStatus() {
return backend.getStatus();
}
}
public static class Backend {
public String getStatus() {
return "Hello, world!";
}
}
}
{code}
Also please consider adding this to documentation page:
http://cxf.apache.org/docs/jaxrs-services-configuration.html#JAXRSServicesConfiguration-SpringBoot
> SpringResourceFactory does not work with constructor-autowired beans
> --------------------------------------------------------------------
>
> Key: CXF-6694
> URL: https://issues.apache.org/jira/browse/CXF-6694
> Project: CXF
> Issue Type: Bug
> Components: JAX-RS
> Affects Versions: 3.1.4
> Reporter: Vladimir Kulev
> Labels: spring
> Attachments: CXF-6694.patch
>
>
> When used with constructor-autowired bean, it fails with "Resource class ... has no valid constructor" exception. We don't need constructor at all when we already have a singleton instance from Spring.
> Also it looks like {{isSingleton()}} is called for the first time before correct value is calculated a few lines below: {{isSingleton = ac.isSingleton(beanId)}}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)