cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Beryozkin (JIRA)" <>
Subject [jira] [Commented] (CXF-6005) ResourceInfo cannot be injected in OSGi environment
Date Tue, 16 Sep 2014 09:42:34 GMT


Sergey Beryozkin commented on CXF-6005:

No problems at all, thanks

> ResourceInfo cannot be injected in OSGi environment
> ---------------------------------------------------
>                 Key: CXF-6005
>                 URL:
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.7.12
>            Reporter: Andrei Shakirin
>            Assignee: Andrei Shakirin
>            Priority: Critical
> Problem: by injection of ResourceInfo in resource class or in provider in OSGi environment
CXF throws following exception:
> {code}
> Caused by: java.lang.IllegalArgumentException: interface
is not visible from class loader
> 	at java.lang.reflect.Proxy.getProxyClass0([:1.7.0_40]
> 	at java.lang.reflect.Proxy.newProxyInstance([:1.7.0_40]
> 	at org.apache.cxf.jaxrs.utils.InjectionUtils.createThreadLocalProxy(
> {code}
> Reason of the problem: there is no dedicated thread local context for ResourceInfo and
CXF instantiates it using java reflection proxy in InjectionUtils:
> {code}
>             return (ThreadLocalProxy<T>)Proxy.newProxyInstance(type.getClassLoader(),
>                                    new Class[] {type, ThreadLocalProxy.class },
>                                    new ThreadLocalInvocationHandler<T>());
> {code}
> The problem is that classloader in first argument is taken from type class, but proxy
have to implement two interfaces: type and ThreadLocalProxy (second argument). It works fine
in standalone environment, but in OSGi classloader of ResourceInfo bundle doesn't know nothing
about ThreadLocalProxy interface in CXF JAX-RS bundle. Of course, the ThreadLocalProxy cannot
be found.
> Solution: possible solution is use the classloader of current class (InjectionUtils)
instead of type class. As far as InjectionUtils classloader knows type class as well it should
work in standalone as well as in OSGi environments.

This message was sent by Atlassian JIRA

View raw message