N
N
nuclear_kote2016-09-29 13:53:30
Apache HTTP Server
nuclear_kote, 2016-09-29 13:53:30

Why are @Context fields not populated in cxf?

@Service
@Transactional
@Path("test")
public class ServiceImpl implements Service {
    @Get
    public void test(@Context MessageContext ctx) {
    }
}

issues 404
@Service
@Transactional
@Path("test")
public class ServiceImpl implements Service {
    @Context MessageContext ctx;
    @Get
    public void test() {
    }
}

flies like this:
Caused by: java.lang.IllegalArgumentException: Can not set org.apache.cxf.jaxrs.ext.MessageContext field com.example.services.test.ServiceImpl.ctx to com.sun.proxy.$Proxy197
        at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)
        at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)
        at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:58)
        at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:75)
        at java.lang.reflect.Field.set(Field.java:764)
        at org.apache.cxf.jaxrs.utils.InjectionUtils$1.run(InjectionUtils.java:228)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.apache.cxf.jaxrs.utils.InjectionUtils.injectFieldValue(InjectionUtils.java:224)
        at org.apache.cxf.jaxrs.utils.InjectionUtils.injectContextProxiesAndApplication(InjectionUtils.java:1103)
        at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.injectContexts(JAXRSServerFactoryBean.java:405)
        at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.updateClassResourceProviders(JAXRSServerFactoryBean.java:429)
        at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:162)
        ... 29 more

what am I doing wrong?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question