1 Reply Latest reply on Aug 7, 2013 11:43 PM by james viet

    Class loader between 2 projects in jboss 7

    james viet Newbie

      Hi,

       

      I met problem when I deploy my app

      Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [META-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [META-INF/applicationContext.xml] cannot be opened because it does not exist

          at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341)

          at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)

          at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)

          at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)

          at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)

          at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:243)

          at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)

          at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)

          at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131)

          at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:522)

          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:436)

          at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)

          at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)

          at com.alcatel.axs.jboss7.demo.app.mbean.AppStartup.startService(AppStartup.java:42)

          at com.alcatel.axs.jboss7.demo.app.mbean.AbsractAppStartup.start(AbsractAppStartup.java:38)

          ... 11 more

      Caused by: java.io.FileNotFoundException: class path resource [META-INF/applicationContext.xml] cannot be opened because it does not exist

          at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:158)

          at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328)

          ... 25 more

       

      Structure of my app: have 2 project: demo-api. demo-app

       

      demo-api: contain class AppStartup, in this app I will start service in application context file.

      ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext("META-INF/applicationContext.xml");

       

      I defined app-api to a module

      <module xmlns="urn:jboss:module:1.1" name="com.lib">

          <resources>

              <resource-root path="demo-api.jar"/>

          </resources>

          <dependencies>

              <module name="org.jboss.as.clustering.infinispan"/>

              <module name="org.infinispan"/>

          </dependencies>

      </module>

       

       

      demo-app: have structure

       

      demo-app

      +src/main/java

      +src/main/resource

        - META-INF (in src/main/resource)

        * applicationContext.xml (in META-INF)

       

      In jboss.service of demo-app, I used AppStartup class of demo-api

       

      I defined jboss-deployment-structure.xml in demo-app

      <?xml version="1.0" encoding="UTF-8"?>

      <jboss-deployment-structure>

          <deployment>

              <dependencies>

                       <module name="com.lib">

                      <imports>

                          <include path="META-INF**" />

                          <exclude path="/**" />

                      </imports>

                  </module>

              </dependencies>

          </deployment>

      </jboss-deployment-structure>

       

      But when I deploy demo-app, server log thrown error

      Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [META-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [META-INF/applicationContext.xml] cannot be opened because it does not exist

          at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341)

          at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)

          at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)

          at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)

          at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)

          at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:243)

          at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)

          at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)

          at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131)

          at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:522)

          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:436)

          at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)

          at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)

          at com.alcatel.axs.jboss7.demo.app.mbean.AppStartup.startService(AppStartup.java:42)

          at com.alcatel.axs.jboss7.demo.app.mbean.AbsractAppStartup.start(AbsractAppStartup.java:38)

          ... 11 more

      Caused by: java.io.FileNotFoundException: class path resource [META-INF/applicationContext.xml] cannot be opened because it does not exist

          at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:158)

          at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328)

          ... 25 more

       

      I guessed JBoss can not find applicationContext.xml in demo-api because this file lives in demo-app.

      But I also configured boss-deployment-structure.xml

       

      Could you please give me some advice to fix this error?

       

      Thanks,