ProxyHelper requires cglib even if interface is used as client service class
----------------------------------------------------------------------------

                 Key: CXF-2180
                 URL: https://issues.apache.org/jira/browse/CXF-2180
             Project: CXF
          Issue Type: Bug
          Components: Core, REST
    Affects Versions: 2.2
            Reporter: Holger Delfs


When using a JAX-RS proxy client with the spring bean

  <jaxrs:client id="subscriberService" serviceClass="sample.SubscriberService"
    address="http://localhost:8080/services/";>
  </jaxrs:client>

where sample.SubscriberService is an interface, I would expect, that I don't 
need cglib in my classpath. Instead I get 
org.springframework.beans.factory.BeanCreationException with the following root 
cause:

Caused by: java.lang.NoClassDefFoundError: net/sf/cglib/proxy/Callback
        at org.apache.cxf.common.util.ProxyHelper.<clinit>(ProxyHelper.java:33)
        at 
org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean.createWithValues(JAXRSClientFactoryBean.java:134)
        at 
org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean.create(JAXRSClientFactoryBean.java:119)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at 
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:115)
        ... 18 more
Caused by: java.lang.ClassNotFoundException: net.sf.cglib.proxy.Callback
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
        ... 26 more

which I can only fix by including cglib in my Maven dependencies.

The catch block in the static initializer of ProxyHelper lets me assume, that 
the usage of cglib features was intended to be optional. But if cglib.jar is 
not available, the class loading of CglibProxyHelper causes the error above.

I suggest to either catch Throwable when calling CglibProxyHelper, or to avoid 
the class loading dependency on cglib classes within CglibProxyHelper.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to