GeoServer
  1. GeoServer
  2. GEOS-1738

Ampersand in format description in catalog.xml causes failure to start geoserver

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.6.0-RC3
    • Fix Version/s: 1.6.1
    • Component/s: Configuration
    • Labels:
      None
    • Environment:
      GeoServer 1.6.0 RC3 on Java 1.5 on OS X 10.4
    • Number of attachments :
      0

      Description

      Including a description to a coverage store which contains an ampersand (&) works while geoserver is up. But GeoServer will not restart.

      The following in catalog.xml:

      <format namespace = "glsl" enabled = "true" id = "general1811robhuron_4326.tif" >
      <description>CANADA / BY A. K. JOHNSTON F. R. G. S. // NATIONAL ATLAS // 38 //
      Engraved by W. & A. K. Johnston. // [above the title overprinted
      "LITHOGRAPHED EDITION" has been added in sepia] // [imprint at bottom
      of sheet is partially cut off]

      Alexander Keith Johnston (1804-1871), published [1849?].
      Printed map. 50 cm x 61 cm, on sheet 52 cm x 64 cm. Boundaries and
      outlines coloured. Gilt edges.
      Scale: Two visual scales [67 mm = 90 Geographical Miles & 63 mm = 100
      English Miles].
      Taken from same original source as Accession # 107382.
      Acquired as part of the Hodsoll Collection. </description>
      <type>GeoTIFF</type>
      <url>file:coverages/glsl/general1811robhuron_4326.tif</url>
      </format>

      will generate this error:

      [Fatal Error] :79:17: The entity name must immediately follow the '&' in the entity reference.
      11 Feb 16:42:25 ERROR [context.ContextLoader] - Context initialization failed
      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'config' defined in URL [jar:file:/usr/local/apache-tomcat-6.0.14/webapps/geo
      server/WEB-INF/lib/main-1.6.0-RC3.jar!/applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.RuntimeException: Error reading : java.
      io.InputStreamReader@74c52a
      java.lang.RuntimeException: Error reading : java.io.InputStreamReader@74c52a
      at org.geoserver.util.ReaderUtils.parse(ReaderUtils.java:90)
      at org.vfny.geoserver.global.xml.XMLConfigReader.loadCatalog(XMLConfigReader.java:364)
      at org.vfny.geoserver.global.xml.XMLConfigReader.load(XMLConfigReader.java:222)
      at org.vfny.geoserver.global.xml.XMLConfigReader.<init>(XMLConfigReader.java:176)
      at org.vfny.geoserver.global.Config.setApplicationContext(Config.java:90)
      at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:84)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFacto
      ry.java:248)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:362)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:312)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:275)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:318)
      at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:134)
      at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:230)
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:156)
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:48)
      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.deployWAR(HostConfig.java:825)
      at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:714)
      at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490)
      at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
      at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
      at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
      at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
      at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
      at org.apache.catalina.core.StandardService.start(StandardService.java:516)
      at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
      at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
      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.catalina.startup.Bootstrap.start(Bootstrap.java:288)
      at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
      Caused by: org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.
      at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
      at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
      at org.geoserver.util.ReaderUtils.parse(ReaderUtils.java:87)
      ... 42 more
      Feb 11, 2008 4:42:25 PM org.apache.catalina.core.StandardContext start
      SEVERE: Error listenerStart
      Feb 11, 2008 4:42:25 PM org.apache.catalina.core.StandardContext start
      SEVERE: Context [/geoserver] startup failed due to previous errors

        Activity

        Hide
        Arne Kepp added a comment -

        Thank you for your persistence

        So I didn't know the WCS configuration well enough. There are actually two closely related bugs here.

        One is the writing of catalog.xml, which is covered in your report, and this has been fixed. But that is really from the datastore definition.

        The same problem can occur in services.xml, which is where coverage keywords and abstracts are stored.

        Show
        Arne Kepp added a comment - Thank you for your persistence So I didn't know the WCS configuration well enough. There are actually two closely related bugs here. One is the writing of catalog.xml, which is covered in your report, and this has been fixed. But that is really from the datastore definition. The same problem can occur in services.xml, which is where coverage keywords and abstracts are stored.
        Hide
        Arne Kepp added a comment -

        Our code did not handle the case where a text would include line termination characters and the code was executed on a UNIX-like system.

        "geoserver&\r".matches( "(.)[\"&'<>](.*)" )

        will return false because the carriage return is special and not covered by the (.*) when Java is running in UNIX mode.

        See http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html#lt

        I've updated the regexp above and added checks that replace "\r\n" with "\n" in text fields, and remove cr characters in keyword lists (since they are added again by the reader, leading to duplicates).

        Show
        Arne Kepp added a comment - Our code did not handle the case where a text would include line termination characters and the code was executed on a UNIX-like system. "geoserver&\r".matches( "(. ) [\"&'<>] (.*)" ) will return false because the carriage return is special and not covered by the (.*) when Java is running in UNIX mode. See http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html#lt I've updated the regexp above and added checks that replace "\r\n" with "\n" in text fields, and remove cr characters in keyword lists (since they are added again by the reader, leading to duplicates).
        Hide
        Justin Deoliveira added a comment -
        Show
        Justin Deoliveira added a comment - Integrated in geoserver-trunk #357 (See http://gridlock.openplans.org:8080/hudson/job/geoserver-trunk/357/ )
        Hide
        Justin Deoliveira added a comment -
        Show
        Justin Deoliveira added a comment - Integrated in geoserver-1.6.x #81 (See http://gridlock.openplans.org:8080/hudson/job/geoserver-1.6.x/81/ )
        Hide
        Amos Hayes added a comment -

        Thanks Arne! I knew something wacky had to be going on there. Glad you were able to hunt it down! I look forward to trying it out.

        Show
        Amos Hayes added a comment - Thanks Arne! I knew something wacky had to be going on there. Glad you were able to hunt it down! I look forward to trying it out.

          People

          • Assignee:
            Arne Kepp
            Reporter:
            Amos Hayes
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: