I'm using Geoserver 2.13.2 with leaflet0.7.2, I have deployed Geoserver Tomcat 9.0 and followed all steps mentioned in this and I have installed mapfish v3.
I'm trying to print a map and wms layers and I'm using the this plugin.
But when I start printing I got following problem:
Error while generating PDF:
com.itextpdf.text.DocumentException: org.mapfish.print.InvalidJsonValueException: spec.layers[0].baseURL has an invalid value: http://a.tile.openstreetmap.org/ (spec.layers[0].baseURL has an invalid value: http://a.tile.openstreetmap.org/)
at com.itextpdf.text.pdf.PdfDocument.add(PdfDocument.java:821)
at com.itextpdf.text.Document.add(Document.java:277)
at org.mapfish.print.config.layout.Page$1.add(Page.java:76)
at org.mapfish.print.config.layout.MapBlock.render(MapBlock.java:81)
at org.mapfish.print.config.layout.Page.render(Page.java:73)
at org.mapfish.print.config.layout.MainPage.render(MainPage.java:63)
at org.mapfish.print.config.layout.Layout.render(Layout.java:59)
at org.mapfish.print.output.AbstractOutputFormat.doPrint(AbstractOutputFormat.java:31)
at org.mapfish.print.output.PdfOutputFactory.print(PdfOutputFactory.java:58)
at org.mapfish.print.MapPrinter.print(MapPrinter.java:176)
at org.mapfish.print.servlet.MapPrinterServlet.doCreatePDFFile(MapPrinterServlet.java:370)
at org.mapfish.print.servlet.MapPrinterServlet.createAndGetPDF(MapPrinterServlet.java:166)
at org.mapfish.print.servlet.MapPrinterServlet.doGet(MapPrinterServlet.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.springframework.web.servlet.mvc.ServletWrappingController.handleRequestInternal(ServletWrappingController.java:165)
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:177)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:52)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1038)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:998)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:890)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:875)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.geoserver.filters.ThreadLocalsCleanupFilter.doFilter(ThreadLocalsCleanupFilter.java:26)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.geoserver.filters.SpringDelegatingFilter$Chain.doFilter(SpringDelegatingFilter.java:69)
at org.geoserver.wms.animate.AnimatorFilter.doFilter(AnimatorFilter.java:73)
at org.geoserver.filters.SpringDelegatingFilter$Chain.doFilter(SpringDelegatingFilter.java:66)
at org.geoserver.filters.SpringDelegatingFilter.doFilter(SpringDelegatingFilter.java:41)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.geoserver.platform.AdvancedDispatchFilter.doFilter(AdvancedDispatchFilter.java:37)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320)
at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:70)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:74)
at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:91)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:70)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119)
at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:74)
at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:91)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.geoserver.security.filter.GeoServerAnonymousAuthenticationFilter.doFilter(GeoServerAnonymousAuthenticationFilter.java:51)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:70)
at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilterInternal(BasicAuthenticationFilter.java:158)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:74)
at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:91)
at org.geoserver.security.filter.GeoServerBasicAuthenticationFilter.doFilter(GeoServerBasicAuthenticationFilter.java:81)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:70)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
at org.geoserver.security.filter.GeoServerSecurityContextPersistenceFilter$1.doFilter(GeoServerSecurityContextPersistenceFilter.java:52)
at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:74)
at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:91)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178)
at org.geoserver.security.GeoServerSecurityFilterChainProxy.doFilter(GeoServerSecurityFilterChainProxy.java:142)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.geoserver.filters.LoggingFilter.doFilter(LoggingFilter.java:101)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.geoserver.filters.XFrameOptionsFilter.doFilter(XFrameOptionsFilter.java:79)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.geoserver.filters.GZIPFilter.doFilter(GZIPFilter.java:47)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.geoserver.filters.SessionDebugFilter.doFilter(SessionDebugFilter.java:46)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.geoserver.filters.FlushSafeFilter.doFilter(FlushSafeFilter.java:42)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:688)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1594)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
Caused by: org.mapfish.print.InvalidJsonValueException: spec.layers[0].baseURL has an invalid value: http://a.tile.openstreetmap.org/ (spec.layers[0].baseURL has an invalid value: http://a.tile.openstreetmap.org/)
at org.mapfish.print.map.readers.HTTPMapReader.checkSecurity(HTTPMapReader.java:136)
at org.mapfish.print.map.readers.HTTPMapReader.<init>(HTTPMapReader.java:76)
at org.mapfish.print.map.readers.TileableMapReader.<init>(TileableMapReader.java:42)
at org.mapfish.print.map.readers.OsmMapReader.<init>(OsmMapReader.java:50)
at org.mapfish.print.map.readers.OsmMapReader$Factory.create(OsmMapReader.java:43)
at org.mapfish.print.map.readers.MapReaderFactoryFinder.create(MapReaderFactoryFinder.java:36)
at org.mapfish.print.map.MapChunkDrawer.renderImpl(MapChunkDrawer.java:120)
at org.mapfish.print.ChunkDrawer.render(ChunkDrawer.java:55)
at org.mapfish.print.ChunkDrawer.tableLayout(ChunkDrawer.java:49)
at com.itextpdf.text.pdf.PdfPTable.writeSelectedRows(PdfPTable.java:855)
at com.itextpdf.text.pdf.ColumnText.goComposite(ColumnText.java:1978)
at com.itextpdf.text.pdf.ColumnText.go(ColumnText.java:999)
at com.itextpdf.text.pdf.ColumnText.go(ColumnText.java:993)
at com.itextpdf.text.pdf.ColumnText.go(ColumnText.java:981)
at com.itextpdf.text.pdf.PdfPRow.writeCells(PdfPRow.java:583)
at com.itextpdf.text.pdf.PdfPTable.writeSelectedRows(PdfPTable.java:831)
at com.itextpdf.text.pdf.PdfPTable.writeSelectedRows(PdfPTable.java:964)
at com.itextpdf.text.pdf.ColumnText.goComposite(ColumnText.java:1986)
at com.itextpdf.text.pdf.ColumnText.go(ColumnText.java:999)
at com.itextpdf.text.pdf.ColumnText.go(ColumnText.java:993)
at com.itextpdf.text.pdf.ColumnText.go(ColumnText.java:981)
at com.itextpdf.text.pdf.PdfDocument.addPTable(PdfDocument.java:2717)
at com.itextpdf.text.pdf.PdfDocument.add(PdfDocument.java:759)
... 111 more
Caused by: org.mapfish.print.InvalidJsonValueException: spec.layers[0].baseURL has an invalid value: http://a.tile.openstreetmap.org/
at org.mapfish.print.map.readers.HTTPMapReader.checkSecurity(HTTPMapReader.java:133)
... 133 more
Here is the config.yml file:
#===========================================================================
# allowed DPIs
#===========================================================================
dpis: [75, 150, 300,254,72]
#===========================================================================
# the allowed scales
#===========================================================================
scales:
- 25000
- 50000
- 100000
- 200000
- 500000
- 1000000
- 2000000
- 4000000
#===========================================================================
# the list of allowed hosts
#===========================================================================
hosts:
- !localMatch
dummy: true
- !ipMatch
ip: www.camptocamp.org
- !dnsMatch
host: demo.opengeo.org
port: 80
- !dnsMatch
host: terraservice.net
port: 80
- !dnsMatch
host: sigma.openplans.org
- !dnsMatch
host: demo.mapfish.org
layouts:
Legal:
mainPage:
pageSize: LEGAL
items:
- !map
spacingAfter: 30
width: 440
height: 483
#===========================================================================
A4 portrait:
#===========================================================================
metaData:
# title: '${mapTitle}'
author: 'MapFish print module'
subject: 'Simple layout'
keywords: 'map,print'
creator: 'MapFish'
titlePage:
pageSize: A4
items:
- !text
spacingAfter: 150
- !text
font: Helvetica
fontSize: 40
spacingAfter: 100
align: center
text: '${layout}'
- !image
maxWidth: 160
maxHeight: 160
spacingAfter: 100
align: center
url: http://trac.mapfish.org/trac/mapfish/attachment/ticket/3/logo_v8_sphere.svg?format=raw
footer: &commonFooter
height: 30
items:
- !columns
config:
cells:
- paddingBottom: 5
items:
- !text
backgroundColor: #FF0000
align: left
text: a red box
- !text
align: right
text: 'Page ${pageNum}'
- !image
align: center
maxWidth: 100
maxHeight: 30
spacingAfter: 200
url: 'http://geoserver.org/img/geoserver-logo.png'
#-------------------------------------------------------------------------
mainPage:
pageSize: A4
rotation: true
# header:
# height: 50
# items:
# - !text
# font: Helvetica
# fontSize: 30
# align: right
# text: '${layout}'
items:
- !text
text: '${mapTitle}'
fontSize: 30
spacingAfter: 30
- !map
spacingAfter: 30
width: 440
height: 483
- !columns
# columns can have an absolute position. In that case, they need the 3 following fields:
absoluteX: 410
absoluteY: 310
width: 100
items:
- !scalebar
type: bar
maxSize: 100
barBgColor: white
fontSize: 8
align: right
- !text
text: '${comment}'
spacingAfter: 30
- !attributes
source: data
spacingAfter: 30
columnDefs:
id:
columnWeight: 2
header: !text
text: ID
backgroundColor: #A0A0A0
cell: !text
text: '${id}'
name:
columnWeight: 5
header: !text
text: Name
backgroundColor: #A0A0A0
cell: !columns
config:
cells:
- backgroundColor: '${nameBackgroundColor}'
borderWidth: 1
borderColor: '${nameBorderColor}'
items:
- !text
text: '${name}'
icon:
columnWeight: 2
header: !text
text: Symbol
backgroundColor: #A0A0A0
cell: !image
align: center
maxWidth: 15
maxHeight: 15
url: 'http://www.mapfish.org/svn/mapfish/trunk/MapFish/client/mfbase/mapfish/img/${icon}.png'
- !text
font: Helvetica
fontSize: 9
align: right
text: '1:${scale} ${now MM.dd.yyyy}'
footer: *commonFooter
What do I need to do for printing to work??
Your list of allowed hosts does not allow for you mapfish to print from http://a.tile.openstreetmap.org/ (the hint is in your error log where it says
spec.layers[0].baseURL has an invalid value: http://a.tile.openstreetmap.org/
).There is an additional config.yaml file that you can use as a template: https://github.com/GeoNode/geoserver-geonode-ext/blob/main/data/printing/config.yaml`
From that sample, it seems you should add the following under your
hosts:
section:I know you probably don't need this answer anymore, but since I am having a lot of trouble with the geoserver mapfish printing module myself, I thought someone else might use this as reference.