Announcement Announcement Module
Collapse
No announcement yet.
How to reference a bean from another eclipse project Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to reference a bean from another eclipse project

    I have 2 projects (one struts project and a java project to contain my DAOs and business logic in eclipse). In my Struts project, I've setup my spring context to refer to beans within the same Struts project and it works fine. But when I need to to set some bean references to my java library project, it fails. Here are the error messages:

    Code:
    [2005-08-29 16:41:26,218][INFO][ContextLoader][initWebApplicationContext][146]- Root WebApplicationContext: initialization started
    [2005-08-29 16:41:26,375][INFO][XmlBeanDefinitionReader][loadBeanDefinitions][150]- Loading XML bean definitions from ServletContext resource [/WEB-INF/config/spring-context.xml]
    [2005-08-29 16:41:26,609][ERROR][ContextLoader][initWebApplicationContext][177]- Context initialization failed
    org.springframework.beans.factory.BeanDefinitionStoreException: Error registering bean with name 'partnerService' defined in ServletContext resource [/WEB-INF/config/spring-context.xml]: Bean class [tuinsurance.lib.business.service.impl.PartnerServiceImpl] not found; nested exception is java.lang.ClassNotFoundException: tuinsurance.lib.business.service.impl.PartnerServiceImpl
    java.lang.ClassNotFoundException: tuinsurance.lib.business.service.impl.PartnerServiceImpl
    	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1340)
    	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1189)
    	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    	at java.lang.Class.forName0(Native Method)
    	at java.lang.Class.forName(Class.java:242)
    	at org.springframework.util.ClassUtils.forName(ClassUtils.java:87)
    	at org.springframework.beans.factory.support.BeanDefinitionReaderUtils.createBeanDefinition(BeanDefinitionReaderUtils.java:64)
    	at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.parseBeanDefinitionElement(DefaultXmlBeanDefinitionParser.java:369)
    	at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.parseBeanDefinitionElement(DefaultXmlBeanDefinitionParser.java:335)
    	at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.parseBeanDefinitions(DefaultXmlBeanDefinitionParser.java:266)
    	at org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.registerBeanDefinitions(DefaultXmlBeanDefinitionParser.java:186)
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:238)
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:155)
    	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:124)
    	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:140)
    	at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:116)
    	at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:84)
    	at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:87)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:267)
    	at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:134)
    	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:230)
    	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:156)
    	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:48)
    	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3831)
    	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4323)
    	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)
    	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
    	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
    	at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:277)
    	at org.apache.catalina.core.StandardHost.install(StandardHost.java:832)
    	at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:701)
    	at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:432)
    	at org.apache.catalina.startup.HostConfig.start(HostConfig.java:983)
    	at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:349)
    	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1091)
    	at org.apache.catalina.core.StandardHost.start(StandardHost.java:789)
    	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)
    	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478)
    	at org.apache.catalina.core.StandardService.start(StandardService.java:480)
    	at org.apache.catalina.core.StandardServer.start(StandardServer.java:2313)
    	at org.apache.catalina.startup.Catalina.start(Catalina.java:556)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:287)
    	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:425)
    Aug 29, 2005 4:41:26 PM org.apache.catalina.core.StandardContext start
    In eclipse, I have set the struts project to be dependent on the java library project. Im not sure if there's anything else I need to do to create bean references in my struts project that reference the java library project. Im new to Spring and any help/suggestions is appreciated.

    FYI. Im using Spring 1.2.3, Eclipse 3.1, MyEclipse 4.0M3, Tomcat 5.0.


    Thanks.

    Jade

  • #2
    It seems that Tomcat you're starting from MyEclipse doesn't see your Java project (where needed classes are). You should check MyEclipse on how to set referenced projects, or something similar. Nothing to do with Spring itself, really.

    Comment


    • #3
      Thanks dcengija, thats what I thought so I just packaged the java project in a jar and placed it in my WEB-INF\lib folder and it works. I know I have MyEclipse setup properly because I can reference the Java project (ex. I can access the business service objects in my struts action classes.)

      Is there a better way of developing a web app with struts & spring in one project and a java project with business logic and DAOs? I mean, I dont want to be exporting my java project as a jar every single time just so I can test my web app. Or maybe Im just taking the wrong approach. Any help is appreciated.

      Jade

      Comment


      • #4
        We are also planning to create an Application with such approach. Is there a way?

        Sorry to reply to an old post.

        Originally posted by jakim8915 View Post

        Is there a better way of developing a web app with struts & spring in one project and a java project with business logic and DAOs? I mean, I dont want to be exporting my java project as a jar every single time just so I can test my web app. Or maybe Im just taking the wrong approach. Any help is appreciated.

        Jade

        Comment

        Working...
        X