Announcement Announcement Module
Collapse
No announcement yet.
Error Caused by: java.io.FileNotFoundException: class path resource cannot be opened Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error Caused by: java.io.FileNotFoundException: class path resource cannot be opened

    Hi,

    In project1 i have my context.xml file in this xml i am using another xml which is in project2.The project2 contains project1 jar.

    When i try to deply the project2 i am getting the following exception.

    Caused by: org.springframework.beans.BeanInstantiationExcepti on: Could not insta
    ntiate bean class [org.springframework.context.support.ClassPathXmlAp plicationCo
    ntext]: Constructor threw exception; nested exception is org.springframework.bea
    ns.factory.BeanDefinitionStoreException: IOException parsing XML document from c
    lass path resource [MyApplication/src/main/webapp/WEB-INF/context/application-portlet.xml]; nested exception is java.io.FileNotFoundException: class path res
    ource [MyApplication/src/main/webapp/WEB-INF/context/application-portlet.xml]
    cannot be opened because it does not exist
    Caused by: org.springframework.beans.factory.BeanDefinitionSt oreException: IOExc
    eption parsing XML document from class path resource [MyStatementPortlet/src/mai
    n/webapp/WEB-INF/context/statement-portlet.xml]; nested exception is java.io.Fil
    eNotFoundException: class path resource [MyApplication/src/main/webapp/WEB-INF/context/application-portlet.xml] cannot be opened because it does not exist
    Caused by: java.io.FileNotFoundException: class path resource [MyApplication/src/main/webapp/WEB-INF/context/application-portlet.xml] cannot be opened becaus
    e it does not exist
    at org.springframework.core.io.ClassPathResource.getI nputStream(ClassPat
    hResource.java:135)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBea
    nDefinitions(XmlBeanDefinitionReader.java:297)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBea
    nDefinitions(XmlBeanDefinitionReader.java:280)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReade
    r.loadBeanDefinitions(AbstractBeanDefinitionReader .java:131)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReade
    r.loadBeanDefinitions(AbstractBeanDefinitionReader .java:147)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReade
    r.loadBeanDefinitions(AbstractBeanDefinitionReader .java:173)
    at org.springframework.context.support.AbstractXmlApp licationContext.loa
    dBeanDefinitions(AbstractXmlApplicationContext.jav a:112)
    at org.springframework.context.support.AbstractXmlApp licationContext.loa
    dBeanDefinitions(AbstractXmlApplicationContext.jav a:79)
    at org.springframework.context.support.AbstractRefres hableApplicationCon
    text.refreshBeanFactory(AbstractRefreshableApplica tionContext.java:101)
    at org.springframework.context.support.AbstractApplic ationContext.obtain
    FreshBeanFactory(AbstractApplicationContext.java:3 89)
    at org.springframework.context.support.AbstractApplic ationContext.refres
    h(AbstractApplicationContext.java:324)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<i
    nit>(ClassPathXmlApplicationContext.java:91)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<i
    nit>(ClassPathXmlApplicationContext.java:75)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)

    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(NativeConstruct
    orAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(DelegatingC
    onstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Construc tor.java:513)
    at org.springframework.beans.BeanUtils.instantiateCla ss(BeanUtils.java:8
    5)
    at org.springframework.beans.factory.support.SimpleIn stantiationStrategy
    .instantiate(SimpleInstantiationStrategy.java:87)
    at org.springframework.beans.factory.support.Construc torResolver.autowir
    eConstructor(ConstructorResolver.java:186)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBean
    Factory.autowireConstructor(AbstractAutowireCapabl eBeanFactory.java:799)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBean
    Factory.createBeanInstance(AbstractAutowireCapable BeanFactory.java:717)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBean
    Factory.createBean(AbstractAutowireCapableBeanFact ory.java:384)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getOb
    ject(AbstractBeanFactory.java:251)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistr
    y.getSingleton(DefaultSingletonBeanRegistry.java:1 56)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean
    (AbstractBeanFactory.java:248)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean
    (AbstractBeanFactory.java:160)
    at org.springframework.context.support.AbstractApplic ationContext.getBea
    n(AbstractApplicationContext.java:733)
    at org.springframework.beans.factory.access.Singleton BeanFactoryLocator.
    useBeanFactory(SingletonBeanFactoryLocator.java:39 5)
    at org.springframework.web.context.ContextLoader.load ParentContext(Conte
    xtLoader.java:315)
    at org.springframework.web.context.ContextLoader.init WebApplicationConte
    xt(ContextLoader.java:183)
    at org.springframework.web.context.ContextLoaderListe ner.contextInitiali
    zed(ContextLoaderListener.java:49)
    at org.apache.catalina.core.StandardContext.listenerS tart(StandardContex
    t.java:3827)
    at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4
    334)
    at org.apache.catalina.core.ContainerBase.addChildInt ernal(ContainerBase
    .java:791)
    at org.apache.catalina.core.ContainerBase.addChild(Co ntainerBase.java:77
    1)
    at org.apache.catalina.core.StandardHost.addChild(Sta ndardHost.java:525)

    at org.apache.catalina.startup.HostConfig.deployWAR(H ostConfig.java:825)

    at org.apache.catalina.startup.HostConfig.deployWARs( HostConfig.java:714
    )
    at org.apache.catalina.startup.HostConfig.deployApps( HostConfig.java:490
    )
    at org.apache.catalina.startup.HostConfig.check(HostC onfig.java:1206)
    at org.apache.catalina.startup.HostConfig.lifecycleEv ent(HostConfig.java
    :293)
    at org.apache.catalina.util.LifecycleSupport.fireLife cycleEvent(Lifecycl
    eSupport.java:117)
    at org.apache.catalina.core.ContainerBase.backgroundP rocess(ContainerBas
    e.java:1337)
    at org.apache.catalina.core.ContainerBase$ContainerBa ckgroundProcessor.p
    rocessChildren(ContainerBase.java:1601)
    at org.apache.catalina.core.ContainerBase$ContainerBa ckgroundProcessor.p
    rocessChildren(ContainerBase.java:1610)
    at org.apache.catalina.core.ContainerBase$ContainerBa ckgroundProcessor.r
    un(ContainerBase.java:1590)
    at java.lang.Thread.run(Thread.java:619)

    Please help me on this.

    Thanks in advance,
    Naresh
    Last edited by Naresh.T; May 5th, 2008, 07:51 AM.

  • #2
    Same same

    Hi there,

    I am encountering the same problem. Did you find a way to resolve this?

    To sum up:
    - module 1 depends on module 2
    - module1/src/main/resources/META-INF/module1/config.xml contains:
    Code:
    <import resource="classpath:META-INF/module2/subConfig.xml" />
    - module2/src/main/resources/META-INF/module2/subConfig.xml exists
    - when deploying the module1 application, I get the following stacktrace:

    Code:
    Caused by: java.io.FileNotFoundException: class path resource [META-INF/module2/subConfig.xml] cannot be opened because it does not exist
    	at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:158) ~[spring-core-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328) ~[spring-beans-3.0.4.RELEASE.jar:3.0.4.RELEASE]
    	... 37 common frames omitted
    I've had a look at the deployed application and I found ...\workspace\.metadata\.plugins\org.eclipse.wst.s erver.core\tmp5\wtpwebapps\module1\WEB-INF\lib\module2.jar
    and the file module2.jar contains subConfig.xml!

    So it's like module1 cannot load resources within jar files. How is that possible?
    Does anyone have a clue?

    Simon
    Last edited by sisays; Jun 1st, 2011, 09:03 AM.

    Comment


    • #3
      Found it

      Ok, module2 was initially configured to be packaged as a WAR and then changed to JAR
      Eclipse mixed the thing up and I had to delete module2 project and reimport it as a maven project into Eclipse to make everything right.

      This and some other minor problems that prevented Eclipse from deploying completely the module1 war..

      Comment

      Working...
      X