Announcement Announcement Module
Collapse
No announcement yet.
Bizzare ClassLoader issue in Java WebStart? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bizzare ClassLoader issue in Java WebStart?

    Hello - I've been trying to advocate the use of Spring in our project. Another developer has written the following class to adapt us to the Spring world:

    public class MatrixValueSupplierProvider
    {
    private static final String REFERENCE_FACTORY = "com/allustra/application/common/refFactory.xml";
    private static final String MATRX_VALUE_SUPPLIER_FACTORY = "matrixValueSupplierBeans";

    private static BeanFactoryReference ms_factoryReference;


    static
    {
    ms_factoryReference = SingletonBeanFactoryLocator.getInstance(REFERENCE_ FACTORY).useBeanFactory(MATRX_VALUE_SUPPLIER_FACTO RY);
    }

    private MatrixValueSupplierProvider()
    {
    }

    public static final MatrixValueSupplier getInstance(String id)
    {
    MatrixValueSupplier result = (MatrixValueSupplier)ms_factoryReference.getFactor y().getBean(id);

    return result;
    }
    }

    Which references refFactory.xml:

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

    <beans>
    <bean id="matrixValueSupplierBeans" lazy-init="true" class="org.springframework.context.support.ClassPa thXmlApplicationContext">
    <constructor-arg>
    <value>classpath*:com/allustra/business/matrix/common/valuesupplier/MatrixValueSupplierBeans.xml</value>
    </constructor-arg>
    </bean>
    </beans>

    The motivation here is that MatrixValueSupplierBeans.xml appears a few times in the classpath as it is defined in multiple locations in the classpath and then combined by Spring at runtime.

    Now this all works fine and realiably when running from a client invoked using the java command line.

    However, when we use Java WebStart, every once in a while we get the following error:

    2005-07-28 14:09:41.359|Error |CCOMM.90 |STDERR: Caused by: org.springframework.beans.FatalBeanException: Unable to find resource for specified definition. Group resource name [classpath*:com/allustra/application/common/refFactory.xml], factory key [matrixValueSupplierBeans]
    2005-07-28 14:09:41.359|Error |CCOMM.90 |STDERR: at org.springframework.beans.factory.access.Singleton BeanFactoryLocator.createDefinition(SingletonBeanF actoryLocator.java:477)
    2005-07-28 14:09:41.359|Error |CCOMM.90 |STDERR: at org.springframework.beans.factory.access.Singleton BeanFactoryLocator.useBeanFactory(SingletonBeanFac toryLocator.java:372)
    2005-07-28 14:09:41.359|Error |CCOMM.90 |STDERR: at com.allustra.business.matrix.common.valuesupplier. MatrixValueSupplierProvider.<clinit>(MatrixValueSu pplierProvider.java:22)
    2005-07-28 14:09:41.359|Error |CCOMM.90 |STDERR: ... 45 more
    2005-07-28 14:09:47.468|Error |CCOMM.90 |STDERR: java.lang.NoClassDefFoundError
    2005-07-28 14:09:47.468|Error |CCOMM.90 |STDERR: at com.allustra.business.matrix.common.MatrixKeyAdapt erPE.getValueSupplier(MatrixKeyAdapterPE.java:117)

    Where MatrixKeyAdapterPE.getValueSupplier() line 117 is the line which calls MatrixValueSupplierProvider.getInstance().

    This has got me stumped. I've had problems with Java WebStart before, where the classloader it uses can load all the jars it needs and then fails with NoClassDefFoundError before. Usually addressed by setting the context classloader of the current thread to be the same as the classloader for the current class, but looking at the Spring code - it already does something like this.

    Any ideas?

  • #2
    Definitelly the problem lies in Java WebStart - I guess you can turn some logging on or do some profilling to see what happens. I had a LOT of problems with JBoss classloader when we were deploying more then one instance of an application on a server and the CL had huge concurrency problems. I had to restart the server serveral times until the application was deployed without any CCE.

    Comment

    Working...
    X