I am trying out the Spring Extensions of Restlet 1.1RC2 in OSGi, specifically
Equinox 3.4.0, Spring 2.5.5, and Spring-DM 1.1.1.  My Spring application context
is using the SpringFinder bean in much the same way the Restlet Spring example 
does:

    <bean id="v1Router" class="org.restlet.ext.spring.SpringRouter">
        <property name="attachments">
            <map>
                <entry key="/jobs">
                   <bean class="org.restlet.ext.spring.SpringFinder">
                     <lookup-method name="createResource" bean="jobsResource"/>
                   </bean>
                </entry>
            </map>
        </property>
    </bean>


When Spring tries to use CGLib for the "lookup-method" it cannot find the CGLib
classes and gets this exception:

Caused by: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'org.restlet.ext.spring.SpringFinder#19e215b' defined in
URL [bundleentry://38/META-INF/spring/restlet.pde-context.xml]: Instantiation of
bean failed; nested exception is net.sf.cglib.core.CodeGenerationException:
java.lang.reflect.InvocationTargetException-->null
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.
    instantiateBean(AbstractAutowireCapableBeanFactory.java:883)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.
    createBeanInstance(AbstractAutowireCapableBeanFactory.java:839)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.
    doCreateBean(AbstractAutowireCapableBeanFactory.java:440)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.
    run(AbstractAutowireCapableBeanFactory.java:409)
        at java.security.AccessController.doPrivileged(Native Method)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.
    createBean(AbstractAutowireCapableBeanFactory.java:380)
        at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.
    resolveInnerBean(BeanDefinitionValueResolver.java:219)
        ... 32 more
Caused by: net.sf.cglib.core.CodeGenerationException:
java.lang.reflect.InvocationTargetException-->null
        at net.sf.cglib.core.AbstractClassGenerator.create(
    AbstractClassGenerator.java:237)
        at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
        at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:285)
        at
org.springframework.beans.factory.support.CglibSubclassingInstantiationStrategy
    $CglibSubclassCreator.
        instantiate(CglibSubclassingInstantiationStrategy.java:116)
        at
org.springframework.beans.factory.support.CglibSubclassingInstantiationStrategy
    .instantiateWithMethodInjection(
        CglibSubclassingInstantiationStrategy.java:70)
        at
org.springframework.beans.factory.support.SimpleInstantiationStrategy.
    instantiate(SimpleInstantiationStrategy.java:65)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.
    instantiateBean(AbstractAutowireCapableBeanFactory.java:877)
        ... 38 more
Caused by: java.lang.reflect.InvocationTargetException
        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 net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:384)
        at net.sf.cglib.core.AbstractClassGenerator.create(
    AbstractClassGenerator.java:219)
        ... 44 more
Caused by: java.lang.NoClassDefFoundError: net/sf/cglib/proxy/Factory
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
        ... 50 more
Caused by: java.lang.ClassNotFoundException: net.sf.cglib.proxy.Factory
        at
org.eclipse.osgi.framework.internal.core.BundleLoader.findClassInternal(
    BundleLoader.java:481)
        at
org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(
    BundleLoader.java:397)
        at
org.eclipse.osgi.framework.internal.core.BundleLoader.findClass(
    BundleLoader.java:385)
        at
org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(
    DefaultClassLoader.java:87)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
        ... 52 more


The only solution I've found is to modify the MANIFEST.MF in
org.restlet.ext.spring_2.5.jar and import all the of "net.sf.cglib.*" related
packages.  Is this a bug in the Restlet's Spring Extension manifest or might I
have something wrong in my environment?

Thanks for your help,
Adam




Reply via email to