Announcement Announcement Module
No announcement yet.
Spring can't work on Eclipse Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring can't work on Eclipse

    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 :

    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 Instance(
    at org.apache.commons.logging.impl.LogFactoryImpl.get Instance(
    at org.apache.commons.logging.impl.LogFactoryImpl.get Instance(
    at org.apache.commons.logging.LogFactory.getLog(LogFa
    at ationContext.<init>(AbstractApplicationContext.jav a:115)
    at licationContext.<init>(AbstractXmlApplicationConte
    at plicationContext.<init>(ClassPathXmlApplicationCon
    at plicationContext.<init>(ClassPathXmlApplicationCon
    at plicationContext.<init>(ClassPathXmlApplicationCon

    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?

  • #2
    I too am facing this problem. I would really like to be able to use Spring from Eclipse RCP as it provides a rich and extensible Rich Client.