Announcement Announcement Module
Collapse
No announcement yet.
Help!spring+hibernate+rcp,can't find h Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help!spring+hibernate+rcp,can't find h

    now,we have integrated spring and hibernate into our RCP application. use
    spring as control,integrate hibernate into spring as persistence layer.

    at first ,in rcp application,it can't load applicationContext.xml,but i use
    http://folk.uio.no/olepaa/spring/
    and
    << Thread cur = Thread.currentThread();
    << ClassLoader save = cur.getContextClassLoader();
    << cur.setContextClassLoader(getClass().getClassLoade r());
    << try {
    << InputStream is = getClass()
    << .getClassLoader()
    << .getResourceAsStream("/myDef.xml");
    << XmlBeanFactory beanFactory = new XmlBeanFactory(is);
    << myService = (MyService) beanFactory.getBean("myService");
    << } finally {
    << cur.setContextClassLoader(save);
    << }
    it works ,can find applicationContext.xml.

    but the new problem is :when i want to use hibernate like
    ctx.getBean("mhouseManager"),hibernate's mapping that configed as spring's
    bean property can't be find.

    <bean id="sessionFactory"
    class="org.springframework.orm.hibernate.LocalSess ionFactoryBean">
    <property name="dataSource"><ref local="dataSource"/></property>
    <property name="mappingResources">
    <list>
    <value>com/jctx/trms/hibernate/persistence/Mhouse.hbm.xml</value>
    <!-- Add list of .hbm.xml files here -->
    </list>
    </property>
    ..................

    and the error is "Could not open class path resource", does this caused by
    classloader again? are there some solution?
    or some helpful doc about eclipse 's classloader?? thanks a lot

    -----------------------
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean
    with name 'sessionFactory' defined in (no description): Initialization of
    bean failed; nested exception is java.io.FileNotFoundException: Could not
    open class path resource
    [com/jctx/trms/hibernate/persistence/Mhouse.hbm.xml]
    java.io.FileNotFoundException: Could not open class path resource
    [com/jctx/trms/hibernate/persistence/Mhouse.hbm.xml]
    at
    org.springframework.core.io.ClassPathResource.getI nputStream(ClassPathResource.java:86)
    at
    org.springframework.orm.hibernate.LocalSessionFact oryBean.afterPropertiesSet(LocalSessionFactoryBean .java:353)
    at
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:991)
    at
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:288)
    at
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:208)
    at
    org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:204)
    at
    org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:136)
    at com.jctx.trms.views.FormView.createPartControl(For mView.java:77)
    at org.eclipse.ui.internal.PartPane$2.run(PartPane.ja va:137)
    at
    org.eclipse.core.internal.runtime.InternalPlatform .run(InternalPlatform.java:616)
    at org.eclipse.core.runtime.Platform.run(Platform.jav a:747)
    at org.eclipse.ui.internal.PartPane.createChildContro l(PartPane.java:133)
    at org.eclipse.ui.internal.ViewPane.createChildContro l(ViewPane.java:135)
    at org.eclipse.ui.internal.PartPane.createControl(Par tPane.java:205)
    at org.eclipse.ui.internal.ViewPane.createControl(Vie wPane.java:119)
    at org.eclipse.ui.internal.ViewFactory$1.run(ViewFact ory.java:349)
    at
    org.eclipse.core.internal.runtime.InternalPlatform .run(InternalPlatform.java:616)
    at org.eclipse.core.runtime.Platform.run(Platform.jav a:747)
    at
    org.eclipse.ui.internal.ViewFactory.busyRestoreVie w(ViewFactory.java:273)
    at org.eclipse.ui.internal.ViewFactory$2.run(ViewFact ory.java:530)
    at org.eclipse.swt.custom.BusyIndicator.showWhile(Bus yIndicator.java:69)
    at org.eclipse.ui.internal.ViewFactory.restoreView(Vi ewFactory.java:528)
    at org.eclipse.ui.internal.Perspective.showView(Persp ective.java:1593)
    at
    org.eclipse.ui.internal.WorkbenchPage.busyShowView (WorkbenchPage.java:773)
    at org.eclipse.ui.internal.WorkbenchPage.access$9(Wor kbenchPage.java:753)
    at org.eclipse.ui.internal.WorkbenchPage$13.run(Workb enchPage.java:3051)
    at org.eclipse.swt.custom.BusyIndicator.showWhile(Bus yIndicator.java:69)
    at org.eclipse.ui.internal.WorkbenchPage.showView(Wor kbenchPage.java:3048)
    at org.eclipse.ui.internal.WorkbenchPage.showView(Wor kbenchPage.java:3028)
    at org.eclipse.ui.internal.ShowViewMenu.showOther(Sho wViewMenu.java:204)
    at org.eclipse.ui.internal.ShowViewMenu$2.run(ShowVie wMenu.java:68)
    at org.eclipse.jface.action.Action.runWithEvent(Actio n.java:881)
    at
    org.eclipse.jface.action.ActionContributionItem.ha ndleWidgetSelection(ActionContributionItem.java:91 5)
    at
    org.eclipse.jface.action.ActionContributionItem.ac cess$2(ActionContributionItem.java:866)
    at
    org.eclipse.jface.action.ActionContributionItem$7. handleEvent(ActionContributionItem.java:785)
    at org.eclipse.swt.widgets.EventTable.sendEvent(Event Table.java:82)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.ja va:796)
    at org.eclipse.swt.widgets.Display.runDeferredEvents( Display.java:2772)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Di splay.java:2431)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Wor kbench.java:1377)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench. java:1348)
    at
    org.eclipse.ui.internal.Workbench.createAndRunWork bench(Workbench.java:254)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(Pl atformUI.java:141)
    at com.jctx.trms.TrmsApplication.run(TrmsApplication. java:14)
    at
    org.eclipse.core.internal.runtime.PlatformActivato r$1.run(PlatformActivator.java:335)
    at
    org.eclipse.core.runtime.adaptor.EclipseStarter.ru n(EclipseStarter.java:273)
    at
    org.eclipse.core.runtime.adaptor.EclipseStarter.ru n(EclipseStarter.java:129)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at
    sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at
    sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at org.eclipse.core.launcher.Main.basicRun(Main.java: 185)
    at org.eclipse.core.launcher.Main.run(Main.java:704)
    at org.eclipse.core.launcher.Main.main(Main.java:688)

  • #2
    does anybody have solved this problem?

    Comment

    Working...
    X