打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
problems using Spring with Eclipse RCP
  • problems using Spring with Eclipse RCP

    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:

    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)
    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.

    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.
    Last edited by rcurry; Feb 28th, 2013, 01:27 PM.Reason: formatting
  • There is one other thing that we tried, and that was using this same big jar needed for the OSGI environment as a maven dependency in our application jars. We thought that might allow us to skip the part of manually editing out the version information on packages. However, while the spring jars in the big jar are available on the OSGI bundle classpath, they are not available on the regular classpath if we try to use that jar to supply our Spring dependencies in a maven build.
  • One thing that we just got to work was to create the "big jar" as an exploded bundle. The jar then contains class files and not a set of jars. This works fine in the OSGI environment, and we can build our application projects against it using maven. We still had a couple of transitive dependencies showing up in the Import-Packages section of the MANIFEST. We were able to exclude these using
    Code:
    <configuration>  <instructions>    <Import-Package>!org.springframework.context.annotation;version="[3.1,4)",*"</Import-Package>  </instructions></configuration>
    in the "maven-bundle-plugin" section of our pom.xml file.
    Last edited by rcurry; Mar 1st, 2013, 12:44 PM.Reason: formatting
  • Hey!

    Maybe the Eclipse Gemini Blueprint project can help here (it is the successor of Spring Dynamic Modules, the addition to Spring to use it in an OSGi environment): http://www.eclipse.org/gemini/blueprint/

    The work that I did with Spring in an Eclipse RCP environment is too long ago to be still valid, but I remember that I used Spring Dynamic Modules. And for doing dependency injection into Eclipse extensions, I implemented this a long time ago:
    https://github.com/martinlippert/spr...ension-factory

    HTH,
    -Martin
  • Thank you, Martin.

    We have had a couple of discussions about whether or not Gemini Blueprint might be what we need. I will take a look at the code you shared. If there is something there that helps with our situation, I will be sure and update this thread.

    Regards,

    rcurry


  • HTH,
    -Martin
    Thank you so much! You did the nice work for us!
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Rich Ajax Platform,第 1 部分: 简介
spring+osgi 动态模型一: Bundles和Application Contexts
Spring and OSGi
Spring boot Mybatis(讀寫分離配置)
springcloud(第三篇)springcloud eureka 服务注册与发现
微服务:Eureka+Zuul+Ribbon+Feign+Hystrix构建微服务架构
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服