Hi Rice,
yep, I noticed that too, jetty6:run builds the classpath reading from the pom.xml, but actually this should not be "important", because this classpath is then reloaded by the cocoon classloader which is a child-first, so falls back on the jetty6:run created classpath only if it cannot find a class.

I'm currently loading some beans with spring from different jars and not having this problem, as long as all classes are there. Problems arise when you try to use JRE classes or other shared libraries not loaded by the cocoon classloader.

You should check the classloader of xs.school.Platform, this is because when you declare a method, say doSomethingWith(MyObject o) in class MyClass, argument and return classes are resolved on the current class classloader, so the method will be doSomethingWith(MyObject-LoadedByMyClassClassloader o), and it will complain if you try to invoke MyClass.doSomethingWith(MyObject-LoadedFromAnotherClassloader). Is xs.school.Platform in WEB-INF/cocoon/lib as well? Loaded by the cocoon classloader?

How do you discovered which classloader was loading a certain class? I'm asking because i noticed that Eclipse is a bit buggy in these field. The best way I've found so far is to put a static block printing out "Class X loaded by XXX".

Hope this helps,
Simone


Rice Yeh wrote:
Seems jetty6:run will automatically add all dependences in pom.xml to WEB-INF/lib. I get the following information by passing -X to mvn command.

[INFO] Context path = /
[DEBUG] Adding artifact hibernate-3.2.0.cr2.jar for WEB-INF/lib
[DEBUG] Adding artifact jakarta-bcel-20040329.jar for WEB-INF/lib
[DEBUG] Adding artifact excalibur-logger-2.1.jar for WEB-INF/lib
[DEBUG] Adding artifact commons-logging-1.0.4.jar for WEB-INF/lib
[DEBUG] Adding artifact xs-persistence-hibernate-1.0-SNAPSHOT.jar for WEB-INF/lib
....

On 9/20/06, *Rice Yeh* < [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:

    Hi,
      I have a bean created thru. springframeowrk in cocoon. The bean
    needs 3 arguments in its contructor to create it as below:

        <bean id="platform" class="xs.school.Platform" scope="singleton">
            <constructor-arg type="java.lang.String" value="development"/>
            <constructor-arg type="xs.persistence.Adapter"
    ref="persistenceAdapter"/>
            <constructor-arg type=" java.util.Locale"><util:constant
    static-field="java.util.Locale.TAIWAN"/></constructor-arg>
        </bean>

        <bean id="persistenceAdapter"
    class="xs.selection.HibernateAdapter ">
            <property name="settings" value="hibernate.cfg.xml"/>
        </bean>

    I find xs.persistence.Adapter 's (which is an interface)
    classloader is WebAppClassLoader. The real adapter implemenation
    is called HibernateAdapter whose classloader is
    DefaultClassLoader. So a ClassCastException is thrown when
    assigning the instance of HibernateAdapter (which implements
    Adapter, surely) to the second argument shown beflow. Adapter and
    HibernateAdapter are in two different jars but both are in
    WEB-INF/cocoon/lib. Should not all classes in jars under
    WEB-INF/cocoon/lib loaded by the same classloader
    (DefaultClassLoader)?

    Caused by:
    org.springframework.beans.factory.UnsatisfiedDependencyException: Err
    or creating bean with name 'platform' defined in URL
    [file:C:/tmp/cocoon/xs-scho
    ol-cocoon/src/main/resources/META-INF/spring/application.xml]:
    Unsatisfied depen
    dency expressed through constructor argument with index 1 of type
    [xs.persistenc
    e.Adapter]: Could not convert constructor argument value
    [xs.selection.Hibernate
    [EMAIL PROTECTED] to required type [xs.persistence.Adapter ]: Failed
    to convert val
    ue of type [xs.selection.HibernateAdapter] to required type
    [xs.persistence.Adap
    ter]; nested exception is java.lang.IllegalArgumentException: No
    matching editor
    s or conversion strategy found
            at
    org.springframework.beans.factory.support.ConstructorResolver.createA
    rgumentArray(ConstructorResolver.java:375)
            at
    org.springframework.beans.factory.support.ConstructorResolver.autowir
    eConstructor( ConstructorResolver.java:126)
            at
    org.springframework.beans.factory.support.AbstractAutowireCapableBean
    Factory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:548)
            at
    org.springframework.beans.factory.support.AbstractAutowireCapableBean
    Factory.createBean(AbstractAutowireCapableBeanFactory.java:352)
            at
    org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
    ject(AbstractBeanFactory.java:240)
            at
    org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
    y.getSingleton(DefaultSingletonBeanRegistry.java:132)
            at
    org.springframework.beans.factory.support.AbstractBeanFactory.getBean
    (AbstractBeanFactory.java:237)
            at
    org.springframework.beans.factory.support.AbstractBeanFactory.getBean
    (AbstractBeanFactory.java:153)
            at
    org.springframework.beans.factory.support.DefaultListableBeanFactory.
    preInstantiateSingletons(DefaultListableBeanFactory.java:254)
            at
    org.springframework.context.support.AbstractApplicationContext.refres
    h(AbstractApplicationContext.java:337)
            at
    org.springframework.web.context.support.AbstractRefreshableWebApplica
    tionContext.refresh(AbstractRefreshableWebApplicationContext.java:156)
            at
    org.springframework.web.context.ContextLoader.createWebApplicationCon
    text(ContextLoader.java:246)
            at
    org.springframework.web.context.ContextLoader.initWebApplicationConte
    xt(ContextLoader.java:184)
            at
    org.springframework.web.context.ContextLoaderListener.contextInitiali
    zed(ContextLoaderListener.java:49)
            at
    org.apache.cocoon.bootstrap.servlet.ShieldingListener.invoke(Shieldin
    gListener.java:151)
            ... 32 more


    Rice


Reply via email to