My team provides backend data support for an Eclipse RCP/Equinox GUI. Previously, we have managed our dependency injection using Guice. We are switching to Spring Framework 3.x for DI and have encountered problems coaxing the Spring jars to "co-operate" with our data layer jars when running the GUI application. We have searched the forums here and also the Java Forums at the Big Moose Saloon, but have not found any possible solutions.
Our initial approach was to copy OSGI ready spring jars into our Target Platform directory, and add each of the spring dependencies (org.springframework.beans-3.1.3.RELEASE.jar, org.springframework.context-3.1.3.RELEASE.jar) as Eclipse Registered buddies to our applicaton jars. When we did that, we got this error when Spring tries to load our DataControllerModule, which is annotated with @Configuration and instantiates our beans:
The next thing that we tried was to create one big jar with all the spring dependencies in it, create a MANIFEST.MF file in that jar that exports all the individual packages needed from the spring jars, and reference this single "bundle" as an eclipse buddy in our applicaton jars. That works, in that we no longer see the FileNotFoundExceptions. However, some of the Spring-related Import-Package references have to be manually edited in our application jars. For example, the big spring jar exports "org.springframework.beans.factory.annotation" without version information while our application jar is looking for an import matching org.springframework.beans.factory.annotation;versi on="(3.1,4]" with version information. Until we edit out the version information, this appears as Missing Constraint in Eclipse.Code:GUI studio error: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to load bean class: com.foo.datacontroller.internal.DataControllerModule; nested exception is java.io.FileNotFoundException: class path resource [com/foo/datacontroller/internal/DataControllerModule.class] cannot be opened because it does not exist at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:293) at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:227) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:623) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:454)
We think there must be an easier way to get our jars working with Spring OSGI jars in our GUI, but we are stumped at the moment. We would be grateful if a forum member could point us to some relevant documentation that might help us sort out the classloader relationships, or even tell us we are barking up the wrong tree if that is the case. Thank you in advance for your time.