[
https://issues.apache.org/jira/browse/CXF-5228?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13880289#comment-13880289
]
Scott Oster edited comment on CXF-5228 at 1/23/14 7:57 PM:
-----------------------------------------------------------
Awesome, thanks much Sergey. I can confirm this workaround works for me with
2.6.6.
Might want to mark this issue as related to
https://issues.apache.org/jira/browse/CXF-4290
I based my solution around this:
http://stackoverflow.com/questions/10458378/how-can-i-make-a-java-lang-reflect-proxy-from-two-separate-classloaders
ProxyClassLoader classLoader = new ProxyClassLoader();
classLoader.addLoader(resourceApiClass.getClassLoader());
classLoader.addLoader(JAXRSClientFactoryBean.class.getClassLoader());
JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
bean.setAddress(baseUrl);
bean.setServiceClass(resourceApiClass);
bean.setClassLoader(classLoader);
return bean.create(resourceApiClass);
was (Author: scott.oster):
Awesome, thanks much Sergey. I can confirm this workaround works for me 1ith
2.6.6.
Might want to mark this issue as related to
https://issues.apache.org/jira/browse/CXF-4290
I based my solution around this:
http://stackoverflow.com/questions/10458378/how-can-i-make-a-java-lang-reflect-proxy-from-two-separate-classloaders
ProxyClassLoader classLoader = new ProxyClassLoader();
classLoader.addLoader(resourceApiClass.getClassLoader());
classLoader.addLoader(JAXRSClientFactoryBean.class.getClassLoader());
JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
bean.setAddress(baseUrl);
bean.setServiceClass(resourceApiClass);
bean.setClassLoader(classLoader);
return bean.create(resourceApiClass);
> Rest client reports interface not visible for service interface
> ---------------------------------------------------------------
>
> Key: CXF-5228
> URL: https://issues.apache.org/jira/browse/CXF-5228
> Project: CXF
> Issue Type: Bug
> Components: JAX-RS
> Affects Versions: 2.7.6
> Environment: OSGi
> Reporter: Christian Schneider
> Assignee: Christian Schneider
> Fix For: 2.7.7, 3.0.0-milestone1
>
>
> When using a rest client in blueprint in OSGi I get the following stacktrace:
> Caused by: java.lang.IllegalArgumentException: interface
> net.lr.tutorial.karaf.cxf.personservice.person.PersonService is not visible
> from class loader
> See this for the full trace:
> https://gist.github.com/cschneider/6156833
> I debugged into it and found that the true execption is hidden.
> It happens in
> org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean.createWithValues(Object...)
> There is first tries to create the proxy using the classloader of the service
> interface.
> This fails as in the user classloader there is only the service interface but
> the proxy is also create for the cxf Client interface. So it fails when
> resolving cxf Client.
> This exception is swallowed and the context classloader is used to create the
> proxy. This classloader is not set so it reports the user service interface
> is not visible. This is not the root of the problem though.
> I fixed this by using a ProxyClassloader that contains the user classloader
> and the classloader of the JAXRSClientFactoryBean. So it then finds user
> classes as well as cxf classes.
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)