Uploaded image for project: 'Axis2'
  1. Axis2
  2. AXIS2-400

Classloader doesn't work with Spring inside an AAR

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.94
    • None
    • kernel
    • None
    • Tomcat 5.5, Axis 0.94, Windows XP, Java 5

    Description

      The classloader used for AAR doesn't work with Spring - when I put Spring inside the lib directory of the AAR, it's not able to access its applicationContext.xml. If I move the applicationContext to the WEB-INF/classes directory, then Spring is able to find it, but not to load the classes defined in it from the AAR.

      However, I am able to access files in the AAR from within my own code directly inside the .AAR.

      When I initially tried to reproduce this, I thought I wasn't able to access the contents of the .AAR at all - but I think this was because I was connecting to Tomcat via a debugger and running the "getResource" code in the context of the debug session, which seems to have given different results than when I call getResource from code.

      This sounds like the behaviour I'd expect if Spring was in the Axis lib directory - but it isn't.

      Error:
      org.springframework.beans.factory.BeanDefinitionStoreException: Error registering bean with name 'myBean' defined in class path resource [testApplicationContext.xml]: Bean class [classpathtest.MyBean] not found; nested exception is java.lang.ClassNotFoundException: classpathtest.MyBean

      Full error:

      ?
      <soapenv:Envelope>
      <soapenv:Header/>
      ?
      <soapenv:Body>
      ?
      <soapenv:Fault>
      <faultcode>Client</faultcode>
      ?
      <faultstring>
      IOException parsing XML document from class path resource [testApplicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [testApplicationContext.xml] cannot be opened because it does not exist; nested exception is:
      org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [testApplicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [testApplicationContext.xml] cannot be opened because it does not exist
      </faultstring>
      <faultactor>http://myAxisServer/role/default</faultactor>
      ?
      <detail>
      ?
      <soapenv:Exception>
      org.apache.axis2.AxisFault: IOException parsing XML document from class path resource [testApplicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [testApplicationContext.xml] cannot be opened because it does not exist; nested exception is:
      org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [testApplicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [testApplicationContext.xml] cannot be opened because it does not exist
      at org.apache.axis2.AxisFault.makeFault(AxisFault.java:254)
      at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:118)
      at org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.receive(AbstractInOutSyncMessageReceiver.java:37)
      at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:331)
      at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPGetRequest(HTTPTransportUtils.java:147)
      at org.apache.axis2.transport.http.AxisServlet.doGet(AxisServlet.java:103)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
      at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
      at java.lang.Thread.run(Thread.java:595)
      Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [testApplicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [testApplicationContext.xml] cannot be opened because it does not exist
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:180)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:148)
      at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:68)
      at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:56)
      at classpathtest.ClasspathTest.testSpring(ClasspathTest.java:20)
      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:585)
      at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:97)
      ... 20 more
      Caused by: java.io.FileNotFoundException: class path resource [testApplicationContext.xml] cannot be opened because it does not exist
      at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:137)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:167)
      ... 29 more
      </soapenv:Exception>
      </detail>
      </soapenv:Fault>
      </soapenv:Body>
      </soapenv:Envelope>

      Attachments

        1. ClasspathTest.java
          0.9 kB
          Inigo Surguy
        2. MyBean.java
          0.2 kB
          Inigo Surguy
        3. testClasspath.aar
          1.58 MB
          Inigo Surguy

        Activity

          People

            dims Davanum Srinivas
            inigo Inigo Surguy
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: