dm Server
  1. dm Server
  2. DMS-1567

Unable to locate Spring NamespaceHandler for XML schema namespace

    Details

    • Type: Defect Defect
    • Status: Done Done
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.2.RELEASE, 2.0.0.M4
    • Fix Version/s: None
    • Component/s: None
    • Environment:

      Windows XP 64 Bit SP2, STS 2.0.1.SR01 with dm-server-1.0.2.SR02 as well as dm-server-2.0.0.M4

      Description

      We have a WAR (attached) that I was hoping I would be able to deploy as-is to start (maybe converting to a web module later). Unfortunately, it would not start up due to a dependency on javax.mail.* packages. I was able to get past that by adding the dm-server's osgi-ified javax.mail package into the WAR's WEB-INF/lib, but also by either of these two steps: remove the code depending on that package, or make the war look like an osgi bundle by adding the required attributes to manifest.mf along with an import-package for javax.mail and javax.mail.internet. For simplicity I just put the JAR into the WEB-INF/lib.

      Now I get stuck with a deployment that "completes" but with an error which shows in the logs:
      2009-09-22 15:28:07,898 [ERROR] fs-watcher # - DispatcherServlet - Context initialization failed
      org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace http://www.springframework.org/schema/osgi
      Offending resource: URL [jar:file:/R:/bin/springsource/springsource-dm-server-2.0.0.M4/work/osgi/configuration/org.eclipse.osgi/bundles/74/1/bundlefile!/META-INF/spring/osgi-context.xml]

      at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
      at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
      at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80)
      at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:281)
      at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1294)
      at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1287)
      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:507)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:398)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
      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.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
      at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92)
      at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
      at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
      at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:402)
      at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:316)
      at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:282)
      at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:126)
      at javax.servlet.GenericServlet.init(GenericServlet.java:212)
      at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1172)
      at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:992)
      at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4058)
      at org.apache.catalina.core.StandardContext.start(StandardContext.java:4371)
      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 com.springsource.osgi.webcontainer.tomcat.TomcatServletContainer.startWebApplication(TomcatServletContainer.java:117)
      at com.springsource.osgi.webcontainer.internal.StandardWebContainer$StandardWebApplication.start(StandardWebContainer.java:102)
      at com.springsource.server.web.core.internal.WebBundleLifecycleListener.onStarted(WebBundleLifecycleListener.java:75)
      at com.springsource.kernel.install.artifact.internal.ArtifactStateMonitor.onStarted(ArtifactStateMonitor.java:202)
      at com.springsource.kernel.install.artifact.internal.AbstractInstallArtifact.asyncStartSucceeded(AbstractInstallArtifact.java:302)
      at com.springsource.kernel.install.artifact.internal.AbstractInstallArtifact$StateMonitorSignal.signalSuccessfulCompletion(AbstractInstallArtifact.java:282)
      at com.springsource.kernel.dm.internal.StandardBundleStarter.signalCompletion(StandardBundleStarter.java:183)
      at com.springsource.kernel.dm.internal.StandardBundleStarter.awaitStart(StandardBundleStarter.java:175)
      at com.springsource.kernel.dm.internal.StandardBundleStarter.start(StandardBundleStarter.java:131)
      at com.springsource.kernel.dm.internal.StandardBundleStarter.start(StandardBundleStarter.java:305)
      at com.springsource.kernel.dm.internal.StandardBundleStarter.start(StandardBundleStarter.java:293)
      at com.springsource.kernel.module.internal.CompositeBundleStarter.start(CompositeBundleStarter.java:92)
      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:597)
      at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
      at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:58)
      at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:62)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
      at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at org.springframework.osgi.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:59)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
      at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
      at $Proxy96.start(Unknown Source)
      at com.springsource.kernel.install.artifact.internal.StandardBundleDriver.asyncStart(StandardBundleDriver.java:171)
      at com.springsource.kernel.install.artifact.internal.StandardBundleInstallArtifact.doAsyncStart(StandardBundleInstallArtifact.java:244)
      at com.springsource.kernel.install.artifact.internal.AbstractInstallArtifact.asyncStart(AbstractInstallArtifact.java:267)
      at com.springsource.kernel.install.artifact.internal.StandardBundleInstallArtifact.asyncStart(StandardBundleInstallArtifact.java:237)
      at com.springsource.kernel.install.artifact.internal.BundleDriverBundleListener.bundleChanged(BundleDriverBundleListener.java:78)
      at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:916)
      at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:220)
      at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:149)
      at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEventPrivileged(Framework.java:1350)
      at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEvent(Framework.java:1301)
      at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:363)
      at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:280)
      at com.springsource.kernel.dm.internal.StandardBundleStarter.start(StandardBundleStarter.java:130)
      at com.springsource.kernel.dm.internal.StandardBundleStarter.start(StandardBundleStarter.java:305)
      at com.springsource.kernel.module.internal.CompositeBundleStarter.start(CompositeBundleStarter.java:99)
      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:597)
      at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
      at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:58)
      at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:62)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
      at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at org.springframework.osgi.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:59)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
      at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
      at $Proxy96.start(Unknown Source)
      at com.springsource.kernel.install.artifact.internal.StandardBundleDriver.syncStart(StandardBundleDriver.java:157)
      at com.springsource.kernel.install.artifact.internal.StandardBundleInstallArtifact.doSyncStart(StandardBundleInstallArtifact.java:229)
      at com.springsource.kernel.install.artifact.internal.StandardBundleInstallArtifact.syncStart(StandardBundleInstallArtifact.java:213)
      at com.springsource.kernel.install.artifact.internal.AbstractInstallArtifact.syncStart(AbstractInstallArtifact.java:239)
      at com.springsource.kernel.deployer.core.internal.PipelinedApplicationDeployer.start(PipelinedApplicationDeployer.java:283)
      at com.springsource.kernel.deployer.core.internal.PipelinedApplicationDeployer.deploy(PipelinedApplicationDeployer.java:178)
      at com.springsource.kernel.deployer.core.internal.StandardApplicationDeployer.deploy(StandardApplicationDeployer.java:359)
      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:597)
      at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
      at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:58)
      at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:62)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
      at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at org.springframework.osgi.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:59)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
      at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
      at $Proxy33.deploy(Unknown Source)
      at com.springsource.kernel.deployer.hot.HotDeploymentFileSystemListener.deploy(HotDeploymentFileSystemListener.java:191)
      at com.springsource.kernel.deployer.hot.HotDeploymentFileSystemListener.onChange(HotDeploymentFileSystemListener.java:88)
      at com.springsource.util.io.FileSystemChecker.notifyListeners(FileSystemChecker.java:182)
      at com.springsource.util.io.FileSystemChecker.check(FileSystemChecker.java:145)
      at com.springsource.kernel.io.fs.WatchTask.run(WatchTask.java:69)
      at java.lang.Thread.run(Thread.java:619)

      What's baffling about this is that the offending resource listed is NOT the bundle corresponding to my WAR file. It is the bundle com.springsource.server.web.dm.

      I've googled on this and some threads would indicate that there might be multiple spring JARs in the classpath. As this WAR has old spring JARs in the WEB-INF/lib folder, I took them out and OSGI-ified the WAR to import the dm-server's spring stuff. Still this error persists.

        Activity

        Hide
        Scott Hamilton added a comment -

        With some refactoring of code, division of modules and, perhaps most significantly, extraction of Spring web component configuration out of web.xml into the web module's manifest.mf file, I was able to get an alternative, fully-spring-dm-server-ized (a web module in a PAR) war working.

        I mention this because one of the troubles I ran into is very similar to the report here and may be related - hopefully it is useful info.

        The final piece of work needed to get this working as a PAR was that last part - no longer specifying the ContextLoaderListener or the dispatcher servlet in the web.xml along with the manifest.mf. As long as I had those, I was getting the same error as the one above, but at least in this case it was in the web module bundle, not some dm server module.

        Specifically here are the permutations I tried with the PAR, and what each result was:
        1. Web module contains no Module-Type or Web-* properties, web.xml contains ContextLoaderListener and dispatcher servlet configuration: the PAR would be deployed successfully but my web module would not be recognized as a web personality and so I could not invoke it thru HTTP.
        2. Web module contains Module-Type and Web-ContextPath, but not Web-DispatcherServletUrlPatterns, web.xml contains ContextLoaderListener and dispatcher servlet config: the PAR would fail to deploy with the exception I listed in this JIRA, but the bundle in which it occurred was my web module.
        3. Web module contains Module-Type, Web-ContextPath and Web-DispatcherServletUrlPatterns, web.xml contains no ContextLoaderListener and no dispatcher servlet config. PAR deploys and works fine.

        Please note that in #s 1 and 2 above I tried both the ServerOsgiBundleXmlWebApplicationContext and OsgiBundleXmlWebApplicationContext contextClass context-Param in web.xml. I should have captured this info, but did not: the results were different with each; I don't recall which one gave me the "Unable to locate Spring NamespaceHandler for XML schema namespace" exception.

        Show
        Scott Hamilton added a comment - With some refactoring of code, division of modules and, perhaps most significantly, extraction of Spring web component configuration out of web.xml into the web module's manifest.mf file, I was able to get an alternative, fully-spring-dm-server-ized (a web module in a PAR) war working. I mention this because one of the troubles I ran into is very similar to the report here and may be related - hopefully it is useful info. The final piece of work needed to get this working as a PAR was that last part - no longer specifying the ContextLoaderListener or the dispatcher servlet in the web.xml along with the manifest.mf. As long as I had those, I was getting the same error as the one above, but at least in this case it was in the web module bundle, not some dm server module. Specifically here are the permutations I tried with the PAR, and what each result was: 1. Web module contains no Module-Type or Web-* properties, web.xml contains ContextLoaderListener and dispatcher servlet configuration: the PAR would be deployed successfully but my web module would not be recognized as a web personality and so I could not invoke it thru HTTP. 2. Web module contains Module-Type and Web-ContextPath, but not Web-DispatcherServletUrlPatterns, web.xml contains ContextLoaderListener and dispatcher servlet config: the PAR would fail to deploy with the exception I listed in this JIRA, but the bundle in which it occurred was my web module. 3. Web module contains Module-Type, Web-ContextPath and Web-DispatcherServletUrlPatterns, web.xml contains no ContextLoaderListener and no dispatcher servlet config. PAR deploys and works fine. Please note that in #s 1 and 2 above I tried both the ServerOsgiBundleXmlWebApplicationContext and OsgiBundleXmlWebApplicationContext contextClass context-Param in web.xml. I should have captured this info, but did not: the results were different with each; I don't recall which one gave me the "Unable to locate Spring NamespaceHandler for XML schema namespace" exception.
        Hide
        Andy Wilkinson added a comment - - edited

        Scott, many thanks for the very detailed problem report.

        I've reproduced the problem on both 1.0.2.RELEASE and a recent nightly build of 2.0 (2.0.0.CI-411) and am looking into it now. I'll comment again once I've made some progress.

        Show
        Andy Wilkinson added a comment - - edited Scott, many thanks for the very detailed problem report. I've reproduced the problem on both 1.0.2.RELEASE and a recent nightly build of 2.0 (2.0.0.CI-411) and am looking into it now. I'll comment again once I've made some progress.
        Hide
        Andy Wilkinson added a comment - - edited

        I've started by investigating the problem on 2.0.

        The root cause of the problem is that the DispatcherServlet finds more Spring configuration files that it should. It finds both the LicensingClient-servlet.xml file in the WAR (which it should find) and osgi-context.xml from one of dm Server's bundles (which it should not). The DispatcherServlet's contextConfigLocation is configured with as /WEB-INF/*-servlet.xml,classpath*:META-INF/spring/*.xml. The classpath*: portion of this configuration is what's causing the osgi-context.xml file to be found. That said, it should be perfectly possible to use classpath*: and not have osgi-context.xml be picked up. The fact that it is, is a bug in dm Server which we'll need to fix.

        Scott, I believe that you can workaround the problem by restructuring your war slightly such that you reference all of the spring configuration files explicitly, rather than using classpath scanning to find them. If you get a chance to give that a try, please let me know how you get on.

        Cheers,
        Andy

        Show
        Andy Wilkinson added a comment - - edited I've started by investigating the problem on 2.0. The root cause of the problem is that the DispatcherServlet finds more Spring configuration files that it should. It finds both the LicensingClient-servlet.xml file in the WAR (which it should find) and osgi-context.xml from one of dm Server's bundles (which it should not). The DispatcherServlet's contextConfigLocation is configured with as /WEB-INF/*-servlet.xml,classpath*:META-INF/spring/*.xml. The classpath*: portion of this configuration is what's causing the osgi-context.xml file to be found. That said, it should be perfectly possible to use classpath*: and not have osgi-context.xml be picked up. The fact that it is, is a bug in dm Server which we'll need to fix. Scott, I believe that you can workaround the problem by restructuring your war slightly such that you reference all of the spring configuration files explicitly, rather than using classpath scanning to find them. If you get a chance to give that a try, please let me know how you get on. Cheers, Andy
        Hide
        Andy Wilkinson added a comment -

        The resource lookup logic has now been fixed in 2.0 such that it should no longer find the spring context files in other bundles which was the root cause of the problem.

        Given that 2.0 is planned for release by the end of the year and a workaround is available we don't currently plan to fix the problem in the 1.0.x line. Please feel free to reopen the issue if that's going to be a problem.

        Show
        Andy Wilkinson added a comment - The resource lookup logic has now been fixed in 2.0 such that it should no longer find the spring context files in other bundles which was the root cause of the problem. Given that 2.0 is planned for release by the end of the year and a workaround is available we don't currently plan to fix the problem in the 1.0.x line. Please feel free to reopen the issue if that's going to be a problem.

          People

          • Assignee:
            Andy Wilkinson
            Reporter:
            Scott Hamilton
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              First Response Date: