Results 1 to 7 of 7

Thread: Unable to return specified BeanFactory instance

  1. #1
    Join Date
    Sep 2005
    Location
    St. Louis, MO USA
    Posts
    25

    Default Unable to return specified BeanFactory instance

    Hi,

    I am getting a BootstrapException when attempting to deploy my app to Tomcat. My current configuration works in both WebSphere and JBoss so I'm not sure if the problem is related to the lack of JTA or a JNDI context so I thought I'd ask.

    First off I have a beanRefContext.xml file that holds references to all of my other configuration files :

    <beans>
    <bean name="mainApplicationContext" class="org.springframework.context.support.ClassPa thXmlApplicationContext">
    <constructor-arg>
    <list>
    <value>/WEB-INF/applicationDS.xml</value>
    <value>/WEB-INF/dataAccessContext-local.xml</value>
    <value>/WEB-INF/applicationContext.xml</value>
    </list>
    </constructor-arg>
    </bean>
    </beans>

    When attempting to run under Tomcat I get the following stack trace when deploying my app :

    ERROR - ContextLoader.initWebApplicationContext(177) | Context initialization failed
    org.springframework.beans.factory.access.Bootstrap Exception: Unable to return specified BeanFactory instance: factory key [mainApplicationContext], from group with resource name [classpath*:WEB-INF/beanRefContext.xml]; nested exception is org.springframework.beans.factory.NoSuchBeanDefini tionException: No bean named 'mainApplicationContext' is defined: org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans []; root of BeanFactory hierarchy
    org.springframework.beans.factory.NoSuchBeanDefini tionException: No bean named 'mainApplicationContext' is defined: org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans []; root of BeanFactory hierarchy
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.getBeanDefinition(DefaultListab leBeanFactory.java:351)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getMergedBeanDefinition(AbstractBeanFa ctory.java:640)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:195)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:147)
    at org.springframework.context.support.AbstractApplic ationContext.getBean(AbstractApplicationContext.ja va:536)
    at org.springframework.beans.factory.access.Singleton BeanFactoryLocator.useBeanFactory(SingletonBeanFac toryLocator.java:399)
    at org.springframework.web.context.ContextLoader.load ParentContext(ContextLoader.java:271)
    at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:152)
    at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 48)
    at org.apache.catalina.core.StandardContext.listenerS tart(StandardContext.java:3827)
    at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4343)
    at org.apache.catalina.core.ContainerBase.addChildInt ernal(ContainerBase.java:823)
    at org.apache.catalina.core.ContainerBase.addChild(Co ntainerBase.java:807)
    at org.apache.catalina.core.StandardHost.addChild(Sta ndardHost.java:595)
    at org.apache.catalina.core.StandardHostDeployer.inst all(StandardHostDeployer.java:277)
    at org.apache.catalina.core.StandardHost.install(Stan dardHost.java:832)
    at org.apache.catalina.startup.HostConfig.deployWARs( HostConfig.java:625)
    at org.apache.catalina.startup.HostConfig.deployApps( HostConfig.java:431)
    at org.apache.catalina.startup.HostConfig.start(HostC onfig.java:983)
    at org.apache.catalina.startup.HostConfig.lifecycleEv ent(HostConfig.java:349)
    at org.apache.catalina.util.LifecycleSupport.fireLife cycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1091)
    at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:789)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1083)
    at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:478)
    at org.apache.catalina.core.StandardService.start(Sta ndardService.java:480)
    at org.apache.catalina.core.StandardServer.start(Stan dardServer.java:2313)
    at org.apache.catalina.startup.Catalina.start(Catalin a.java:556)
    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.apache.catalina.startup.Bootstrap.start(Bootst rap.java:287)
    at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:425)

    I don't think its a classpath issue since it runs in JBoss just fine and JBoss uses Tomcat under the covers. So it has to be an environment issue, any ideas?

    Thanks,
    Dave

  2. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    beanRefContext.xml is not found on classpath*:WEB-INF/beanRefContext.xml. What is your war configuration?
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  3. #3
    Join Date
    Sep 2005
    Location
    St. Louis, MO USA
    Posts
    25

    Default

    What do you mean by war configuration?

    Here's the web.xml that loads my app context on startup :

    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
    /WEB-INF/applicationDS.xml /WEB-INF/dataAccessContext-local.xml /WEB-INF/applicationContext.xml
    </param-value>
    </context-param>
    <context-param>
    <param-name>locatorFactorySelector</param-name>
    <param-value>classpath*:/WEB-INF/beanRefContext.xml</param-value>
    </context-param>
    <context-param>
    <param-name>parentContextKey</param-name>
    <param-value>mainApplicationContext</param-value>
    </context-param>

    <servlet>
    <servlet-name>context</servlet-name>
    <servlet-class>org.springframework.web.context.ContextLoade rServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>

  4. #4
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    WAR = Web ARchive; the file structure of your deployment.

    Btw, try "classpath*: beanRefContext.xml" (w/o the WEB-INF).
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  5. #5
    Join Date
    Sep 2005
    Location
    St. Louis, MO USA
    Posts
    25

    Default

    yes, I know what a WAR is

    Didn't know what you meant by the configuration. I have a context xml file that has all my configuration (datasource, etc.)

    I've tried almost every configuration for the path :

    classpath*:/WEB-INF/beanRefContext.xml
    classpath*:WEB-INF/beanRefContext.xml
    WEB-INF/beanRefContext.xml
    /WEB-INF/beanRefContext.xml
    classpath*:beanRefContext.xml
    beanRefContext.xml
    classpath*:/beanRefContext.xml
    /beanRefContext.xml

    None of them work. That's why I'm confused. It works in both JBoss and WebSphere, but not in Tomcat.

  6. #6
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    I remember I was bitten at some point by Tomcat also. The easiest solution to find out what's going was to use classpath: myFile.xml and then copy the file in various locations.
    It sounds very silly but it worked in the end - the issue seems to appear if tomcat is started from an IDE that changes its classpath.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  7. #7
    Join Date
    Sep 2005
    Location
    St. Louis, MO USA
    Posts
    25

    Default

    You were right! I'm using MyEclipse to start and stop tomcat and all I had to do was add the path of my actual application on the classpath of the startup from within Eclipse.

    Thanks for your help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •