Announcement Announcement Module
Collapse
No announcement yet.
FileNotFoundException <import resource="classpath:..."/> Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • FileNotFoundException <import resource="classpath:..."/>

    I'm new to Spring, so I suspect I'm missing something very basic, but I've searched a bunch and have yet to find a solution to my problem... Any suggestions are greatly appreciated!

    I'm getting a file not found exception on a resource import in my applicationContext.xml. The resource I'm trying to import is another applicationContext file in another project.

    I'm using Eclipse 3.3.2, Tomcat 6, and Spring 2.5.4.

    Here's my file structure:
    Code:
    project1
       --> webapp
          --> WEB-INF
             --> applicationContext.xml
    project2
       --> bin
          --> com/app/billing/config
             --> applicationContext-logic.xml
    and my applicationContext.xml:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:context="http://www.springframework.org/schema/context"
           xmlns:tx="http://www.springframework.org/schema/tx"
           xmlns:p="http://www.springframework.org/schema/p"
           xsi:schemaLocation="http://www.springframework.org/schema/beans 
               http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
               http://www.springframework.org/schema/context
               http://www.springframework.org/schema/context/spring-context-2.5.xsd
               http://www.springframework.org/schema/tx 
               http://www.springframework.org/schema/tx/spring-tx.xsd">
    
     	<import	resource="classpath:/com/app/billing/config/applicationContext-logic.xml" />
     	...
    </beans>
    and the error:
    Code:
    INFO: Initializing Spring root WebApplicationContext
    11:31:04,954 INFO  [ContextLoader] Root WebApplicationContext: initialization started
    11:31:05,095 INFO  [XmlWebApplicationContext] Refreshing [email protected]1510e56: display name [Root WebApplicationContext]; startup date [Tue May 20 11:31:05 EDT 2008]; root of context hierarchy
    11:31:05,298 INFO  [XmlBeanDefinitionReader] Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
    11:31:05,485 INFO  [XmlBeanDefinitionReader] Loading XML bean definitions from class path resource [com/app/billing/config/applicationContext-logic.xml]
    11:31:05,485 ERROR [ContextLoader] Context initialization failed
    org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:/com/app/billing/config/applicationContext-logic.xml]
    Offending resource: ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [com/app/billing/config/applicationContext-logic.xml]; nested exception is java.io.FileNotFoundException: class path resource [com/app/billing/config/applicationContext-logic.xml] cannot be opened because it does not exist
    	at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
    	at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
    	at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)
    	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:182)
    	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:147)
    	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:132)
    	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:92)
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:507)
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:398)
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
    	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
    	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
    	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
    	at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
    	at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92)
    	at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
    	at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:423)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:353)
    	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
    	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
    	at org.springframework.web.context.ContextLoaderServlet.init(ContextLoaderServlet.java:81)
    	at javax.servlet.GenericServlet.init(GenericServlet.java:212)
    	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)
    	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)
    	at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4058)
    	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4364)
    	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
    	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
    	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
    	at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626)
    	at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
    	at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
    	at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1147)
    	at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
    	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    	at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
    	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    	at org.apache.catalina.core.StandardService.start(StandardService.java:516)
    	at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    	at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
    	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:597)
    	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
    	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
    Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [com/app/billing/config/applicationContext-logic.xml]; nested exception is java.io.FileNotFoundException: class path resource [com/app/billing/config/applicationContext-logic.xml] cannot be opened because it does not exist
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:349)
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
    	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
    	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
    	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:174)
    	... 45 more
    Caused by: java.io.FileNotFoundException: class path resource [com/app/billing/config/applicationContext-logic.xml] cannot be opened because it does not exist
    	at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:142)
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
    	... 49 more
    Thanks,
    KC

  • #2
    After some more banging of my head against the wall, I found that while the project build path included the other project, I had not included the other project in the classpath of Tomcat, which is required with the configuration I'm using (deploying to Tomcat using Sysdeo Tomcat plug-in).

    Hope this helps someone else!

    Comment


    • #3
      Thanks, you saved me much banging-of-head-on-wall pain.

      For those who are using Eclipse 3.4's Tomcat plug-in:

      1. After attaching the project to the Tomcat server, double click the "Tomcat v6.0 Server at localhost" to popup the Tomcat server configuration window.
      2. Click "General Information"->"Open launch configuration"
      3. Select Classpath tab
      4. Highlight "User Entries" (buttons will become enabled)
      5. Click "Add projects..." button
      6. check the boxes of the projects you want to include.
      7. click ok....ok....etc

      Comment


      • #4
        Hello, I'm also new at Spring and I was having the same problem(I wanted to import an applicationContext of one project into the applicationContext of another, using <import resource="classpath..."), although I solved it by a diferent way(it looks like the cause of my problem was different). I did the following:

        1-Right click on the project(the one that requires resources from the other projects).
        2-Click on properties > Deployment Assembly > Add.. > Project
        3-Select the projects where you willl search for resources.

        After doing that I could make the "<import resource="classpath:myOtherApplicationContext"/> worked.

        I hope this helps someone else also.
        Last edited by TomasAndres; Sep 20th, 2010, 03:06 PM.

        Comment


        • #5
          I am using RAD 7.5
          Any idea how i can get this working in RAD?

          thanks

          Comment

          Working...
          X