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

        Chris Holmes made changes -
        Field Original Value New Value
        Assignee Andrea Aime [ aaime ] Arne Kepp [ arneke ]
        Fix Version/s 1.6.1 [ 14070 ]
        Hide
        Andrea Aime added a comment -

        Arne, are you fixing this for 1.6.1?

        Show
        Andrea Aime added a comment - Arne, are you fixing this for 1.6.1?
        Arne Kepp made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Hide
        Arne Kepp added a comment -

        Yes, started working on it last night.

        Show
        Arne Kepp added a comment - Yes, started working on it last night.
        Chris Holmes made changes -
        Fix Version/s 1.6.2 [ 14102 ]
        Fix Version/s 1.6.1 [ 14070 ]
        Hide
        Arne Kepp added a comment -

        I believe this is a duplicate of GEOS-1577, and that this was fixed for 1.6.0 RC2

        Can you please test 1.6.0 final and verify that the issue is gone? It should now correctly encode the characters, so that GeoServer starts without any problems after you save such characters.

        If you have a broken catalog.xml now the easiest solution is to edit it by hand. Sorry about the trouble.

        Show
        Arne Kepp added a comment - I believe this is a duplicate of GEOS-1577 , and that this was fixed for 1.6.0 RC2 Can you please test 1.6.0 final and verify that the issue is gone? It should now correctly encode the characters, so that GeoServer starts without any problems after you save such characters. If you have a broken catalog.xml now the easiest solution is to edit it by hand. Sorry about the trouble.
        Hide
        Amos Hayes added a comment -

        Note that this bug was filed against 1.6.0 RC3 which, I presume, was newer than RC2. Is there some reason to believe it was fixed in RC2 and final but not RC3?

        Sadly, I don't have an environment to try 1.6.0 in at the moment.

        Show
        Amos Hayes added a comment - Note that this bug was filed against 1.6.0 RC3 which, I presume, was newer than RC2. Is there some reason to believe it was fixed in RC2 and final but not RC3? Sadly, I don't have an environment to try 1.6.0 in at the moment.
        Hide
        Arne Kepp added a comment -

        Yeah, I saw it was RC3, I was just curious whether maybe it was a nightly build before the actual RC3 release. Since the version labels are set manually I don't trust them 100%.

        Either way, I am confident that these characters are now escaped correctly.

        Thanks for reporting and getting back to me so quickly

        Show
        Arne Kepp added a comment - Yeah, I saw it was RC3, I was just curious whether maybe it was a nightly build before the actual RC3 release. Since the version labels are set manually I don't trust them 100%. Either way, I am confident that these characters are now escaped correctly. Thanks for reporting and getting back to me so quickly
        Arne Kepp made changes -
        Fix Version/s 1.6.1 [ 14070 ]
        Fix Version/s 1.6.2 [ 14102 ]
        Resolution Duplicate [ 3 ]
        Status In Progress [ 3 ] Resolved [ 5 ]
        Hide
        Amos Hayes added a comment -

        Well... OK, I give up. Surely the build wouldn't say RC3 unless it was after RC2.

        Does anyone have a 1.6.0 install running? Could they throw an ampersand in the description of a coverageStore and then see if it is still possible to stop and successfully start geoserver?

        Show
        Amos Hayes added a comment - Well... OK, I give up. Surely the build wouldn't say RC3 unless it was after RC2. Does anyone have a 1.6.0 install running? Could they throw an ampersand in the description of a coverageStore and then see if it is still possible to stop and successfully start geoserver?
        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.
        Arne Kepp made changes -
        Status Resolved [ 5 ] Reopened [ 4 ]
        Resolution Duplicate [ 3 ]
        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).
        Arne Kepp made changes -
        Status Reopened [ 4 ] Closed [ 6 ]
        Resolution Fixed [ 1 ]
        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: