14 Replies Latest reply on Dec 31, 2015 8:07 AM by deklog01

    Spring module can't access resource file from custom module

    deklog01

      I created a custom spring module with spring jars and module.xml:

      <module xmlns="urn:jboss:module:1.1" name="org.springframework.spring">

      <resources>

      <resource-root path="spring-context-2.5.5.jar"/>

      <resource-root path="xbean-spring-3.4.3.jar"/>

      <resource-root path="spring-beans-2.5.5.jar"/>

      <resource-root path="spring-aop-2.5.5.jar"/>

      <resource-root path="spring-core-2.5.5.jar"/>

      </resources>

      <dependencies>

      <module name="org.custom">

      <module name="javax.api"/>

      <module name="javax.jms.api"/>

      <module name="javax.annotation.api"/>

      <module name="org.apache.commons.logging"/>

      </dependencies>

      </module>

      and another custom module: org.custom, with a custom jar, and a folder config containing config/config.xml

      <module xmlns="urn:jboss:module:1.1" name="org.custom">

      <resources>

      <resource-root path="config"/>

      <resource-root path="custom.jar"/>

      </resources>

      <dependencies>

      <module name="org.springframework.spring"/>

      </dependencies>

      </module>

      I declared both modules as global modules in standalone.xml and also as dependancies for my ear application in jboss-deployment-structure.xml:

      <jboss-deployment-structure>

      <deployment>

      <dependencies>

      <module name="org.springframework.spring"/>

      <module name="org.custom" slot="main"/>

      </dependencies>

      </deployment>

      </jboss-deployment-structure>

      At startup my application use custom module, that use spring to load config.xml. But spring can't access custom.xml file:

      Caused by: java.io.FileNotFoundException: class path resource [config.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) ... 31 more 

      I tried to access config.xml directly from my application using classloader, and it's ok.
      I can't modify custom.jar it's a tier dependancy, it calls spring load with param 'config.xml', I can't force a path.

      Why Spring can't access it?

      Using Jboss EAP 6.3.0, and spring 2.5.5

      An help?

      Thanks.

        • 1. Re: Spring module can't access resource file from custom module
          jaysensharma

          Hello,

           

             try adding the [export="true]" for the "org.custom" module as following inside your spring module.xml file.:

           

          <module xmlns="urn:jboss:module:1.1" name="org.springframework.spring">
            <resources>
              <resource-root path="spring-context-2.5.5.jar"/>
              <resource-root path="xbean-spring-3.4.3.jar"/> 
              <resource-root path="spring-beans-2.5.5.jar"/>
              <resource-root path="spring-aop-2.5.5.jar"/>
              <resource-root path="spring-core-2.5.5.jar"/> 
           </resources> 
           <dependencies>
             <module name="org.custom"  export="true" />     <!-- NOTICE -->
             <module name="javax.api"/> 
             <module name="javax.jms.api"/> 
             <module name="javax.annotation.api"/>
             <module name="org.apache.commons.logging"/> 
           </dependencies>
          </module>
          

           

           

          Reagards

          Jay SenSharma

          • 2. Re: Spring module can't access resource file from custom module
            deklog01

            Thanks for your answer Jay.

            I tried adding export also, but it doesn't work. Spring still don't find the file.

             

            The only way so that Spring see the file, is to put it somewhere in system/layers/base/.overlay/layer-base-jboss-eap-6.3.1.CP

             

            This config was working fine in EAP 6.1

             

            Thanks

            • 3. Re: Spring module can't access resource file from custom module
              jaikiran

              I tried to access config.xml directly from my application using classloader, and it's ok.

              I can't modify custom.jar it's a tier dependancy, it calls spring load with param 'config.xml', I can't force a path.

              Can you paste that entire exception stacktrace? That will give us a hint on what context that call gets made and might help us understand what classloader gets used.

              • 4. Re: Spring module can't access resource file from custom module
                deklog01

                Thanks for your answer.

                Here is the full exception:

                 

                11:55:05,881 INFO  [org.custom.agent.Lookup] (MSC service thread 1-2) Init resourceName <custom.xml>
                11:55:05,942 DEBUG [org.jboss.security] (MSC service thread 1-4) PBOX000307: Constructing JBossPolicyConfiguration with contextID partner-jboss7-app-1.8.10-SNAPSHOT.ear
                11:55:05,943 DEBUG [org.jboss.as.security] (MSC service thread 1-4) Cannot create permissions with 'null' metaData for id=partner-jboss7-app-1.8.10-SNAPSHOT.ear
                11:55:05,951 INFO  [org.apache.xbean.spring.context.ClassPathXmlApplicationContext] (MSC service thread 1-2) Refreshing org.apache.xbean.spring.context.ClassPathXmlApplicationContext@24e998bb: display name [org.apache.xbean.spring.context.ClassPathXmlApplicationContext@24e998bb]; startup date [Tue Dec 29 11:55:05 CET 2015]; root of context hierarchy
                11:55:05,965 DEBUG [org.jboss.security] (MSC service thread 1-3) PBOX000307: Constructing JBossPolicyConfiguration with contextID partner-jboss7-app-1.8.10-SNAPSHOT.ear!partner-jboss7-ejb-1.8.10-SNAPSHOT.jar
                11:55:05,968 DEBUG [org.jboss.as.ejb3] (MSC service thread 1-4) Using pool config StrictMaxPoolConfig{name=slsb-strict-max-pool, maxPoolSize=20, timeoutUnit=MINUTES, timeout=5} to create pool for Stateless EJB PartnerComponentEJB
                11:55:06,010 INFO  [org.apache.xbean.spring.context.v2.XBeanXmlBeanDefinitionReader] (MSC service thread 1-2) Loading XML bean definitions from class path resource [custom.xml]
                11:55:06,011 ERROR [org.custom.jb7.agent.JASPIAuthenticator] (MSC service thread 1-2) Error starting SSO Agent : IOException parsing XML document from class path resource [custom.xml]; nested exception is java.io.FileNotFoundException: class path resource [custom.xml] cannot be opened because it does not exist: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [custom.xml]; nested exception is java.io.FileNotFoundException: class path resource [custom.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.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
                        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212)
                        at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:113)
                        at org.apache.xbean.spring.context.ClassPathXmlApplicationContext.loadBeanDefinitions(ClassPathXmlApplicationContext.java:180)
                        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.apache.xbean.spring.context.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:161)
                        at org.apache.xbean.spring.context.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:51)
                        at org.custom.agent.config.SpringComponentKeeperImpl.<init>(SpringComponentKeeperImpl.java:51)
                        at org.custom.agent.config.SpringComponentKeeperFactoryImpl.newComponentKeeper(SpringComponentKeeperFactoryImpl.java:33)
                        at org.custom.agent.Lookup.getComponentKeeper(Lookup.java:125)
                        at org.custom.agent.Lookup.lookupSSOAgent(Lookup.java:102)
                        at org.custom.jb7.agent.JASPIAuthenticator.<init>(JASPIAuthenticator.java:65)
                        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.7.0_79]
                        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) [rt.jar:1.7.0_79]
                        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [rt.jar:1.7.0_79]
                        at java.lang.reflect.Constructor.newInstance(Constructor.java:526) [rt.jar:1.7.0_79]
                        at java.lang.Class.newInstance(Class.java:379) [rt.jar:1.7.0_79]
                        at org.jboss.as.web.deployment.WarDeploymentProcessor.getInstance(WarDeploymentProcessor.java:415)
                        at org.jboss.as.web.deployment.WarDeploymentProcessor.processDeployment(WarDeploymentProcessor.java:231)
                        at org.jboss.as.web.deployment.WarDeploymentProcessor.deploy(WarDeploymentProcessor.java:126)
                        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:159) [jboss-as-server-7.4.2.Final-redhat-2.jar:7.4.2.Final-redhat-2]
                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1980) [jboss-msc-1.1.5.Final-redhat-1.jar:1.1.5.Final-redhat-1]
                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1913) [jboss-msc-1.1.5.Final-redhat-1.jar:1.1.5.Final-redhat-1]
                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_79]
                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_79]
                        at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_79]
                Caused by: java.io.FileNotFoundException: class path resource [custom.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)
                        ... 31 more
                
                
                11:55:06,025 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.deployment.subunit."partner-jboss7-app-1.8.10-SNAPSHOT.ear"."partner-jboss7-web-1.8.10-SNAPSHOT.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.subunit."partner-jboss7-app-1.8.10-SNAPSHOT.ear"."partner-jboss7-web-1.8.10-SNAPSHOT.war".INSTALL: JBAS018733: Failed to process phase INSTALL of subdeployment "partner-jboss7-web-1.8.10-SNAPSHOT.war" of deployment "partner-jboss7-app-1.8.10-SNAPSHOT.ear"
                        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:166) [jboss-as-server-7.4.2.Final-redhat-2.jar:7.4.2.Final-redhat-2]
                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1980) [jboss-msc-1.1.5.Final-redhat-1.jar:1.1.5.Final-redhat-1]
                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1913) [jboss-msc-1.1.5.Final-redhat-1.jar:1.1.5.Final-redhat-1]
                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_79]
                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_79]
                        at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_79]
                Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS018096: Error instantiating container component: org.custom.jb7.agent.JASPIAuthenticator
                        at org.jboss.as.web.deployment.WarDeploymentProcessor.getInstance(WarDeploymentProcessor.java:423)
                        at org.jboss.as.web.deployment.WarDeploymentProcessor.processDeployment(WarDeploymentProcessor.java:231)
                        at org.jboss.as.web.deployment.WarDeploymentProcessor.deploy(WarDeploymentProcessor.java:126)
                        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:159) [jboss-as-server-7.4.2.Final-redhat-2.jar:7.4.2.Final-redhat-2]
                        ... 5 more
                Caused by: java.lang.RuntimeException: Error starting SSO Agent : IOException parsing XML document from class path resource [custom.xml]; nested exception is java.io.FileNotFoundException: class path resource [custom.xml] cannot be opened because it does not exist
                        at org.custom.jb7.agent.JASPIAuthenticator.<init>(JASPIAuthenticator.java:73)
                        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.7.0_79]
                        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) [rt.jar:1.7.0_79]
                        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [rt.jar:1.7.0_79]
                        at java.lang.reflect.Constructor.newInstance(Constructor.java:526) [rt.jar:1.7.0_79]
                        at java.lang.Class.newInstance(Class.java:379) [rt.jar:1.7.0_79]
                        at org.jboss.as.web.deployment.WarDeploymentProcessor.getInstance(WarDeploymentProcessor.java:415)
                        ... 8 more
                Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [custom.xml]; nested exception is java.io.FileNotFoundException: class path resource [custom.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.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
                        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212)
                        at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:113)
                        at org.apache.xbean.spring.context.ClassPathXmlApplicationContext.loadBeanDefinitions(ClassPathXmlApplicationContext.java:180)
                        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.apache.xbean.spring.context.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:161)
                        at org.apache.xbean.spring.context.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:51)
                        at org.custom.agent.config.SpringComponentKeeperImpl.<init>(SpringComponentKeeperImpl.java:51)
                        at org.custom.agent.config.SpringComponentKeeperFactoryImpl.newComponentKeeper(SpringComponentKeeperFactoryImpl.java:33)
                        at org.custom.agent.Lookup.getComponentKeeper(Lookup.java:125)
                        at org.custom.agent.Lookup.lookupSSOAgent(Lookup.java:102)
                        at org.custom.jb7.agent.JASPIAuthenticator.<init>(JASPIAuthenticator.java:65)
                        ... 14 more
                Caused by: java.io.FileNotFoundException: class path resource [custom.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)
                        ... 31 more
                
                

                 

                 

                 

                The custom jar is used as SSO agent and configured as a valve in the web module of my application:

                 

                <jboss-web>
                    <context-root>/partnerapp</context-root>
                    <security-domain>custom</security-domain>
                    <valve>
                        <class-name>org.custom.jb7.agent.JASPIAuthenticator</class-name>
                    </valve>
                </jboss-web>
                

                 

                in standalone.xml, I configured the security domain:

                 <security-domain name="custom">
                                    <authentication-jaspi>
                                        <login-module-stack name="custom-stack">
                                            <login-module code="org.custom.jb7.agent.JBossSSOGatewayLoginModule" flag="required">
                                                <module-option name="debug" value="true"/>
                                            </login-module>
                                        </login-module-stack>
                                        <auth-module code="org.custom.jaspi.agent.JASPISSOAuthModule" login-module-stack-ref="custom-stack"/>
                                    </authentication-jaspi>
                                </security-domain>
                            </security-domains>
                

                 

                 

                The code that calls Spring from the custom jar to make initialisation with the XML file: (resource here = custom.xml)

                    /**
                     * Creates a new Spring Component Keeper.
                     *
                     * @param resource The xml file holding SSO Spring/xbean configuration.
                     */
                    public SpringComponentKeeperImpl(String resource) {
                        // Use XBean XML file system application context.
                        context = new ClassPathXmlApplicationContext(resource);
                    }
                

                 

                 

                Thanks for your help.

                • 5. Re: Spring module can't access resource file from custom module
                  jaikiran

                  org.custom.jb7.agent.JASPIAuthenticator.<init>(JASPIAuthenticator.java:65)

                  What kind of class is this one from whose constructor the Spring classes get invoked? A servlet or something else?

                  • 6. Re: Spring module can't access resource file from custom module
                    deklog01

                    The custom jar is used as SSO agent and configured as a valve in the web module of my application:

                     

                     

                     

                    1. <jboss-web> 
                    2.     <context-root>/partnerapp</context-root> 
                    3.     <security-domain>custom</security-domain> 
                    4.     <valve> 
                    5.         <class-name>org.custom.jb7.agent.JASPIAuthenticator</class-name> 
                    6.     </valve> 
                    7. </jboss-web> 

                    in standalone.xml, I configured the security domain:

                     

                     

                    1. <security-domain name="custom"> 
                    2.                     <authentication-jaspi> 
                    3.                         <login-module-stack name="custom-stack"> 
                    4.                             <login-module code="org.custom.jb7.agent.JBossSSOGatewayLoginModule" flag="required"> 
                    5.                                 <module-option name="debug" value="true"/> 
                    6.                             </login-module> 
                    7.                         </login-module-stack> 
                    8.                         <auth-module code="org.custom.jaspi.agent.JASPISSOAuthModule" login-module-stack-ref="custom-stack"/> 
                    9.                     </authentication-jaspi> 
                    10.                 </security-domain> 
                    11.             </security-domains> 
                    • 7. Re: Spring module can't access resource file from custom module
                      jaikiran

                      Does adding a module element in the valve declaration of jboss-web.xml help:

                       

                      <jboss-web>
                          <context-root>/partnerapp</context-root>
                          <security-domain>custom</security-domain>
                          <valve>
                              <module>org.custom</module>
                              <class-name>org.custom.jb7.agent.JASPIAuthenticator</class-name>
                          </valve>
                      </jboss-web> 
                      
                      • 8. Re: Spring module can't access resource file from custom module
                        deklog01

                        Same error.

                        • 9. Re: Spring module can't access resource file from custom module
                          jaysensharma

                          I tried replicating your issue ... exactly as you used the modules spring module and the com.custom module.    I could reproduce the same error which you got.

                           

                          Altering the "org.springframework.spring"  module.xml and adding the export as following line fixed my issue:

                           

                            <module name="org.custom"  export="true" />     <!-- NOTICE --> 

                           

                          I tried on a fresh JBoss EAP 6.3 (Not on any CP, means no patch applied so i do not have the "system/layers/base/.overlay/layer-base-jboss-eap-6.3.1.CP"   So can you try with a fresh installation or temporarily uninstall the patch and test with the above mentioned suggestion)

                          • 10. Re: Spring module can't access resource file from custom module
                            deklog01

                            I tried with a fresh install without any patch, but still got this error.

                            I tried also to call directly the class loaded from the application code (make the init manually) and it works all modules are visible.

                             

                            The problem occurs only when using the valve.

                            Did you use a valve in your test?

                             

                            Thanks for your help

                            Regards

                            • 11. Re: Spring module can't access resource file from custom module
                              jaysensharma

                              No, I did not use Valve in my case.

                              Can you please share some piece of code from [org.custom.jb7.agent.JASPIAuthenticator.<init>]  or some code snippet where we can see what code is written inside the constructor iof this class, Specially the line 74.

                               

                              Regards

                              Jay SenSharma

                              • 12. Re: Spring module can't access resource file from custom module
                                jaikiran

                                I don't know how Spring tries to load those resources. Maybe it uses the thread context classloader. Can you try this - in the constructor of that JASPIAuthenticator do this before invoking whatever is being invoked:

                                 

                                JASPIAuthenticator() {
                                        final ClassLoader previousClassLoader = Thread.currentThread().getContextClassLoader();
                                        try {
                                            Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
                                            ... // the rest of your code here
                                        } finally {
                                            Thread.currentThread().setContextClassLoader(previousClassLoader);
                                        }
                                }
                                
                                • 13. Re: Spring module can't access resource file from custom module
                                  deklog01

                                  I added the set of classloader as suggested, It doesn't resolve the issue.

                                  It seems that spring module who's using another class loader.

                                  • 14. Re: Spring module can't access resource file from custom module
                                    deklog01

                                    Here is the code calling spring module:

                                    public JASPIAuthenticator() {

                                     

                                        try {
                                                if (_agent == null) {
                                                    Lookup lookup = Lookup.getInstance();
                                                    lookup.init("custom.xml");
                                                    _agent = (HttpSSOAgent) lookup.lookupSSOAgent(); // Here the call to Spring is done
                                                    if (log.isDebugEnabled()) {
                                                        _agent.setDebug(1);
                                                    }
                                                    _agent.start();
                                                }
                                            } catch (Exception e) {
                                                log.error("Error starting Agent : " + e.getMessage(), e);
                                                throw new RuntimeException("Error starting Agent : " + e.getMessage(), e);
                                            }
                                        }
                                    
                                    
                                    

                                     

                                    In Lookup class:

                                     

                                        public static Lookup getInstance() {
                                            return Lookup.INSTANCE;
                                        }
                                    
                                        public void init(String configResourceName) {
                                            logger.info("Load ressource<" + configResourceName + ">");
                                            this.configResourceName = configResourceName;
                                        }
                                    
                                        public synchronized SSOAgent lookupSSOAgent() throws Exception {
                                            if (_ssoAgent == null)
                                                _ssoAgent = getComponentKeeper().fetchSSOAgent(); //getComponentKeeper  method causes the error
                                            return _ssoAgent;
                                        }
                                    
                                    
                                    
                                    public ComponentKeeper getComponentKeeper() throws Exception {
                                            if (this._componentKeeper == null) {
                                                ComponentKeeperFactory factory = ComponentKeeperFactory.getInstance();
                                                factory.setResourceFileName(this.configResourceName);
                                                _componentKeeper = factory.newComponentKeeper();//Here spring is called to initiate the beans
                                                logger.info("Using ComponentKeeper : " + this._componentKeeper.getClass().getName());
                                            }
                                            return this._componentKeeper;
                                        }
                                    
                                    
                                    

                                     

                                    In componentKeeperFactory:

                                    private static String factoryClass = "org.custom.agent.config.SpringComponentKeeperFactoryImpl";
                                        private String _resourceFileName;
                                        public static ComponentKeeperFactory getInstance() {
                                            if (System.getProperty(COMPONENT_KEEKPER_FACTORY) != null)
                                                factoryClass = System.getProperty(COMPONENT_KEEKPER_FACTORY);
                                            try {
                                                return (ComponentKeeperFactory) Class.forName(factoryClass).newInstance();
                                            } catch (InstantiationException e) {
                                                logger.error(e.getMessage(), e);
                                                throw new FactoryConfigurationError(e);
                                            } catch (IllegalAccessException e) {
                                                logger.error(e.getMessage(), e);
                                                throw new FactoryConfigurationError(e);
                                            } catch (ClassNotFoundException e) {
                                                logger.warn("Class not found : " + factoryClass);
                                                throw new FactoryConfigurationError(e);
                                            }
                                    
                                    
                                    

                                        }

                                     

                                    In SpringComponentKeeperFactoryImpl:

                                    public class SpringComponentKeeperFactoryImpl extends ComponentKeeperFactory {
                                        public ComponentKeeper newComponentKeeper() {
                                            return new SpringComponentKeeperImpl(super.getResourceFileName());
                                        }
                                    }
                                    
                                    
                                    

                                     

                                    In: SpringComponentKeeperImpl:

                                    public SpringComponentKeeperImpl(String resource) {
                                            // Use XBean XML file system application context.
                                            context = new ClassPathXmlApplicationContext(resource); // here org.apache.xbean.spring.context.ClassPathXmlApplicationContext from Spring module
                                      }
                                    
                                    
                                    

                                     

                                    the resource (= customer.xml) is not in Spring classpath.

                                     

                                    But what is strange is when I call Spring ClassPathXmlApplicationContext from my application code it's working (using Spring module), It happens only when declaring a valve class from a custom module.

                                     

                                    Actually I use the old good fashion and added both modules as libs for my application (only cutmo.xml kept as configuration module) to get it working.