Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Having two instances of GeoServer and postGIS running on two servers, I have run into a peculiar problem. When I transfer the same dataset to both servers, one is able to show the data without problems while the other gives a "String index out of range" ERROR when I view the data.

The easiest way to notice the error is through the "Layer preview", through the OpenLayers preview I can see the structure, but when I click on a feature, I get

java.lang.StringIndexOutOfBoundsException: String index out of range: -1 String index out of range: -1

instead of the data for this particular feature. Both instances are to my knowledge identical (e.g., software versions, layer settings, geometry settings) so I'm quite baffled.

The error log tells me very little:

    2012-06-14 11:14:40,598 ERROR [geoserver.ows] - 
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
    at java.lang.String.substring(String.java:1937)
    at java.lang.String.substring(String.java:1904)
    at freemarker.core.StringBuiltins$substringBI$1.exec(StringBuiltins.java:211)
    at freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:93)
    at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
    at freemarker.core.Expression.getStringValue(Expression.java:93)
    at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
    at freemarker.core.Environment.visit(Environment.java:208)
    at freemarker.core.MixedContent.accept(MixedContent.java:92)
    at freemarker.core.Environment.visit(Environment.java:208)
    at freemarker.core.Environment.process(Environment.java:188)
    at freemarker.template.Template.process(Template.java:237)
    at org.geoserver.wms.featureinfo.HTMLFeatureInfoOutputFormat.write(HTMLFeatureInfoOutputFormat.java:118)
    at org.geoserver.wms.featureinfo.GetFeatureInfoResponse.write(GetFeatureInfoResponse.java:108)
    at org.geoserver.ows.Dispatcher.response(Dispatcher.java:751)
    at org.geoserver.ows.Dispatcher.handleRequestInternal(Dispatcher.java:233)
    at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
    at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.geoserver.filters.ThreadLocalsCleanupFilter.doFilter(ThreadLocalsCleanupFilter.java:23)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.geoserver.filters.SpringDelegatingFilter$Chain.doFilter(SpringDelegatingFilter.java:68)
    at org.springframework.security.ui.ExceptionTranslationFilter.doFilterHttp(ExceptionTranslationFilter.java:101)
    at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
    at org.geoserver.filters.SpringDelegatingFilter$Chain.doFilter(SpringDelegatingFilter.java:64)
    at org.springframework.security.ui.ExceptionTranslationFilter.doFilterHttp(ExceptionTranslationFilter.java:101)
    at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
    at org.geoserver.filters.SpringDelegatingFilter$Chain.doFilter(SpringDelegatingFilter.java:64)
    at org.springframework.security.ui.basicauth.BasicProcessingFilter.doFilterHttp(BasicProcessingFilter.java:174)

Any ideas?

share|improve this question
2  
looks like a template error - did you copy the FreeMarker template across. –  iant Jun 14 '12 at 12:27
    
Thank you for giving me this hint. I had completely forgot about the templates and this turned out to be the issue. Please set it as an answer so I can accept it. –  Mimo Jun 18 '12 at 7:51
add comment

1 Answer 1

up vote 2 down vote accepted

The key clue in the stack trace is that the error seems to be thrown in freemarker.core. FreeMarker is the templating language that GeoServer uses to create custom getFeatureInfo responses.

Thus I expect that there is a missing template or that a template file got damaged in the copy process. Look in the DATA_DIR/workspaces/.... directory that matches your feature.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.