Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-4639

Classpath scanning fails after hot-deploy of a web-application to a container due to JarURLConnection caching

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.5.1
    • Fix Version/s: 2.5.3
    • Component/s: None
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      Steps to reproduce:

      Deploy a web application that uses component scanning [<context:component-scan base-package="com.example"/>]
      Modify the application so that one of the JAR files considered by classpath scanning changed.
      Redeploy that web application
      Servlet will fail to startup with an IO exception (see below).

      Suggested Fix:
      --------------------

      PathMatchingResourcePatternResolver:

      JarURLConnection jarCon = (JarURLConnection) con;

      // BEGIN PATCHED CODE
      //
      // After the web application is hot-deployed, a new version of our jar files exists at
      // the same file path. Disable caching to ensure that the new JAR file is successfully read.
      //
      con.setUseCaches(false);
      // END PATCHED CODE

      IOException:

      org.springframework.beans.factory.BeanDefinitionStoreException: I/O failure during classpath scanning; nested exception is java.io.FileNotFoundException: JAR entry com/efgfp/ not found in D:\zgg\p4\default\raptor\target\exploded\raptor-web-interfaceWeb\WEB-INF\lib\spring-wrapper.jar
      at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:186)
      at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:192)
      at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:159)
      at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:69)
      at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1246)
      at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1236)
      at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:135)
      at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:92)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:488)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:383)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:327)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:295)
      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:112)
      at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:79)
      at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:97)
      at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:411)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:338)
      at com.efgfp.raptor.util.context.Context.<init>(Context.java:25)
      at com.efgfp.raptor.util.context.ContextFactory.createContext(ContextFactory.java:41)
      at com.efgfp.raptor.util.context.ContextFactory.createContext(ContextFactory.java:29)
      at com.efgfp.raptor.web.RaptorWebApplicationStarter.createInitialContext(RaptorWebApplicationStarter.java:22)
      at com.efgfp.raptor.web.RaptorWebApplicationStarter.contextInitialized(RaptorWebApplicationStarter.java:15)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3830)
      at org.apache.catalina.core.StandardContext.start(StandardContext.java:4337)
      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.check(HostConfig.java:1206)
      at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293)
      at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
      at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
      at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
      at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
      at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
      at java.lang.Thread.run(Thread.java:619)
      Caused by: java.io.FileNotFoundException: JAR entry com/efgfp/ not found in D:\zgg\p4\default\raptor\target\exploded\raptor-web-interfaceWeb\WEB-INF\lib\spring-wrapper.jar
      at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:122)
      at sun.net.www.protocol.jar.JarURLConnection.getJarFile(JarURLConnection.java:71)
      at org.springframework.core.io.support.PathMatchingResourcePatternResolver.doFindPathMatchingJarResources(PathMatchingResourcePatternResolver.java:391)
      at org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingResources(PathMatchingResourcePatternResolver.java:320)
      at org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources(PathMatchingResourcePatternResolver.java:244)
      at org.springframework.context.support.AbstractApplicationContext.getResources(AbstractApplicationContext.java:1026)
      at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:172)
      ... 41 more

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              juergen.hoeller Juergen Hoeller
              Reporter:
              jzaugg Jason Zaugg
              Last updater:
              Spring Issues
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                2 years, 36 weeks, 5 days ago