Headless RCP app that depends on a library the depends on Spring [message #483422] |
Tue, 01 September 2009 14:59 |
Ben Dixon Messages: 63 Registered: July 2009 |
Member |
|
|
Hi all,
I have a headless RCP app that is run as part of a client-server setup
such that the use can launch the server and ui that connects to it by
right-clicking on a certain type of file. My problem is that the server
cannot successfully load its resources because of a Spring classloader
issue. Spring is used by a third-party jar that I have created a plugin
for. That plugin contains the third-party jar which itself contains the
Spring class hierarchy (unjarred). The error I get is:
org.springframework.beans.factory.CannotLoadBeanClassExcepti on: Error
loading class [com.company.products.sim.DMD20$Bean] for bean with name
'dmd20' defined in class path resource
[com/company/products/sim/DMD20Init.xml]: problem with class file or
dependent class; nested exception is java.lang.NoClassDefFoundError:
com/company/product/ProductBean
at
org.springframework.beans.factory.support.AbstractBeanFactor y.resolveBeanClass(AbstractBeanFactory.java:1144)
at
org.springframework.beans.factory.support.AbstractAutowireCa pableBeanFactory.predictBeanType(AbstractAutowireCapableBean Factory.java:524)
at
org.springframework.beans.factory.support.AbstractBeanFactor y.isFactoryBean(AbstractBeanFactory.java:1177)
at
org.springframework.beans.factory.support.AbstractBeanFactor y.isFactoryBean(AbstractBeanFactory.java:758)
at
org.springframework.beans.factory.support.DefaultListableBea nFactory.preInstantiateSingletons(DefaultListableBeanFactory .java:422)
at
org.springframework.context.support.AbstractApplicationConte xt.finishBeanFactoryInitialization(AbstractApplicationContex t.java:728)
at
org.springframework.context.support.AbstractApplicationConte xt.refresh(AbstractApplicationContext.java:380)
At this point in the Spring code, this following method is (ultimately)
called:
public static ClassLoader getDefaultClassLoader() {
ClassLoader cl = null;
try {
cl = Thread.currentThread().getContextClassLoader();
}
catch (Throwable ex) {
// Cannot access thread context ClassLoader - falling back to system
class loader...
}
if (cl == null) {
// No thread context class loader -> use class loader of this class.
cl = ClassUtils.class.getClassLoader();
}
return cl;
}
Notice the use of Thread.currentThread().getContextClassLoader(). This
tipped me off to try using buddy loading to get this working. So in my RCP
plugin I added "Eclipse-RegisterBuddy: com.company.product.lib" and in the
plugin with that symbolic name I added "Eclipse-BuddyPolicy: registered".
But this has made no difference in helping Spring load the relevant
classes.
Does anyone have any insight into how I can get Spring to find the
appropriate classes? I know my plugin successfully accesses the
third-party lib but Spring is not using the same classpath for some
reason. Ideas?
Thanks,
Ben
|
|
|
Powered by
FUDForum. Page generated in 0.02383 seconds