Hi All,

I'm doing a project on Eclipse RCP to call spring. I found that it is not possible to do so. Do anyone try it already ?

The following is my case:

I built a plugin on RCP . Inside the plugin , I use new ClassPathXmlApplicationContext("applicationContext .xml");
to load the applicationContext. It can't work because Eclipse will new a thread to run the plugin. So spring can't get the current thread classloader to load the configuration. I have solved this problem by passing the current classloader(plugin one) to spring, It can work fine. But problems come again. It can't load some classes in other jar. For example DataSource. I try to edited the classloader and work fine again. Definately , I can't use this approach as I never know what other sources I will use later. I can't edit source code one by one.
Ref : http://folk.uio.no/olepaa/spring/

So Another approach I tried as below.
I included all the nesscesary jars in the main thread. That's mean set classpath in the java args. and run the RCP product.

set classpath=%classpath%;/lib/commons-logging-1.0.3.jar
set classpath=%classpath%;/lib/log4j-1.2.8.jar
set classpath=%classpath%;/lib/spring.jar
set classpath=%classpath%;/lib/classes12.jar
set classpath=%classpath%;/lib/aopalliance.jar
set classpath=%classpath%;/lib/spring-aop.jar
set classpath=%classpath%;/lib/spring-dao.jar
set classpath=%classpath%;startup.jar

java org.eclipse.core.launcher.Main -product MyProduct.product -debug

It can't initialize the log . error as below: org.apache.commons.logging.LogConfigurationExcepti on: org.apache.commons.logging
LogConfigurationException: org.apache.commons.logging.LogConfigurationExcepti on
: Class org.apache.commons.logging.impl.Log4JLogger does not implement Log
at org.apache.commons.logging.impl.LogFactoryImpl.new Instance(LogFactoryImpl.java:532)
at org.apache.commons.logging.impl.LogFactoryImpl.get Instance(LogFactoryImpl.java:272)
at org.apache.commons.logging.impl.LogFactoryImpl.get Instance(LogFactoryImpl.java:246)
at org.apache.commons.logging.LogFactory.getLog(LogFa ctory.java:395)
at org.springframework.context.support.AbstractApplic ationContext.<init>(AbstractApplicationContext.jav a:115)
at org.springframework.context.support.AbstractXmlApp licationContext.<init>(AbstractXmlApplicationConte xt.java:47)
at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:77)
at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:65)
at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:56)

Althought, I can make sure common log and log4j in the classpath only, it still can't get the right one. I guess the problem is the classloader. Do anyone know how to solve this issue?