1

I have followed this well-known sequence to use the Geoserver printing module:

cd /var/lib/tomcat7/webapps
sudo wget http://ares.boundlessgeo.com/geoserver/2.6.x/geoserver-2.6.x-latest-war.zip
sudo unzip geoserver-2.6.x-latest-war.zip geoserver.war
cd /var/lib/tomcat7/webapps/geoserver/WEB-INF/lib
sudo wget http://ares.boundlessgeo.com/geoserver/2.6.x/ext-latest/geoserver-2.6-SNAPSHOT-printing-plugin.zip
sudo unzip geoserver-2.6-SNAPSHOT-printing-plugin.zip
sudo service tomcat7 restart
Go to the GEOSERVER_DATA_DIR (/var/lib/tomcat7/webapps/geoserver/data) and a new folder called printing should be present, with config.yaml inside.

But I use 2.8 versions. http://localhost:8080/geoserver/pdf/info.json produces the right specs:

{"scales":[{"name":"1:25,000","value":"25000.0"},{"name":"1:50,000","value":"50000.0"},{"name":"1:100,000","value":"100000.0"},{"name":"1:200,000","value":"200000.0"},{"name":"1:500,000","value":"500000.0"},{"name":"1:1,000,000","value":"1000000.0"},{"name":"1:2,000,000","value":"2000000.0"},{"name":"1:4,000,000","value":"4000000.0"}],"dpis":[{"name":"75","value":"75"},{"name":"150","value":"150"},{"name":"300","value":"300"}],"outputFormats":[{"name":"pdf"}],"layouts":[{"name":"A4 portrait","map":{"width":440,"height":483},"rotation":true},{"name":"Legal","map":{"width":440,"height":483},"rotation":false}],"printURL":"http://localhost:8080/geoserver/pdf/print.pdf","createURL":"http://localhost:8080/geoserver/pdf/create.json"}

I use LinuxMint Rebecca (14.04 if I'm right), I read somewhere that Tomcat has some permissions issues, therefore I used from here:

sudo apt-get install authbind
sudo touch /etc/authbind/byport/80
sudo chmod 500 /etc/authbind/byport/80
sudo chown tomcat7 /etc/authbind/byport/80

However, using the default config.yaml I get:

Error while generating PDF:
org.mapfish.print.InvalidValueException: url has an invalid value: http://geoserver.org/img/geoserver-logo.png
    at org.mapfish.print.PDFUtils.createImage(PDFUtils.java:668)
    at org.mapfish.print.PDFUtils.createImageChunk(PDFUtils.java:656)
    at org.mapfish.print.PDFUtils.createImageChunk(PDFUtils.java:653)
    at org.mapfish.print.config.layout.ImageBlock.render(ImageBlock.java:66)
    at org.mapfish.print.PDFUtils.createCell(PDFUtils.java:624)
    at org.mapfish.print.PDFUtils.buildTable(PDFUtils.java:609)
    at org.mapfish.print.config.layout.ColumnsBlock.render(ColumnsBlock.java:72)
    at org.mapfish.print.PDFUtils.createCell(PDFUtils.java:624)
    at org.mapfish.print.PDFUtils.buildTable(PDFUtils.java:609)
    at org.mapfish.print.config.layout.HeaderFooter.render(HeaderFooter.java:55)
    at org.mapfish.print.PDFCustomBlocks.addFooter(PDFCustomBlocks.java:134)
    at org.mapfish.print.PDFCustomBlocks.onEndPage(PDFCustomBlocks.java:89)
    at com.itextpdf.text.pdf.PdfDocument.newPage(PdfDocument.java:911)
    at com.itextpdf.text.Document.newPage(Document.java:363)
    at org.mapfish.print.config.layout.Page.render(Page.java:63)
    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:30)
    at org.mapfish.print.output.PdfOutputFactory.print(PdfOutputFactory.java:58)
    at org.mapfish.print.MapPrinter.print(MapPrinter.java:173)
    at org.mapfish.print.servlet.MapPrinterServlet.doCreatePDFFile(MapPrinterServlet.java:366)
    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:620)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at org.springframework.web.servlet.mvc.ServletWrappingController.handleRequestInternal(ServletWrappingController.java:159)
    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:923)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.geoserver.filters.ThreadLocalsCleanupFilter.doFilter(ThreadLocalsCleanupFilter.java:28)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.geoserver.filters.SpringDelegatingFilter$Chain.doFilter(SpringDelegatingFilter.java:75)
    at org.geoserver.wms.animate.AnimatorFilter.doFilter(AnimatorFilter.java:71)
    at org.geoserver.filters.SpringDelegatingFilter$Chain.doFilter(SpringDelegatingFilter.java:71)
    at org.geoserver.filters.SpringDelegatingFilter.doFilter(SpringDelegatingFilter.java:46)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.geoserver.platform.AdvancedDispatchFilter.doFilter(AdvancedDispatchFilter.java:50)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311)
    at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:69)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
    at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:73)
    at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:92)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:69)
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
    at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:73)
    at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:92)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    at org.geoserver.security.filter.GeoServerAnonymousAuthenticationFilter.doFilter(GeoServerAnonymousAuthenticationFilter.java:54)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:69)
    at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
    at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:73)
    at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:92)
    at org.geoserver.security.filter.GeoServerBasicAuthenticationFilter.doFilter(GeoServerBasicAuthenticationFilter.java:83)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:69)
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
    at org.geoserver.security.filter.GeoServerSecurityContextPersistenceFilter$1.doFilter(GeoServerSecurityContextPersistenceFilter.java:53)
    at org.geoserver.security.filter.GeoServerCompositeFilter$NestedFilterChain.doFilter(GeoServerCompositeFilter.java:73)
    at org.geoserver.security.filter.GeoServerCompositeFilter.doFilter(GeoServerCompositeFilter.java:92)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:173)
    at org.geoserver.security.GeoServerSecurityFilterChainProxy.doFilter(GeoServerSecurityFilterChainProxy.java:135)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.geoserver.filters.LoggingFilter.doFilter(LoggingFilter.java:87)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.geoserver.filters.GZIPFilter.doFilter(GZIPFilter.java:42)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.geoserver.filters.SessionDebugFilter.doFilter(SessionDebugFilter.java:48)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.geoserver.filters.FlushSafeFilter.doFilter(FlushSafeFilter.java:44)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: Circular redirect to 'http://geoserver.org:80/img/geoserver-logo.png'
    at org.mapfish.print.PDFUtils.handleImageLoadError(PDFUtils.java:357)
    at org.mapfish.print.PDFUtils.loadImageFromUrl(PDFUtils.java:341)
    at org.mapfish.print.PDFUtils.getImageDirect(PDFUtils.java:182)
    at org.mapfish.print.PDFUtils.getImage(PDFUtils.java:102)
    at org.mapfish.print.PDFUtils.createImage(PDFUtils.java:666)
    ... 109 more

What would be the problem here?

Software installed:

ii  libtomcat7-java                             7.0.52-1ubuntu0.3                                   all          Servlet and JSP engine -- core libraries
ii  tomcat7                                     7.0.52-1ubuntu0.3                                   all          Servlet and JSP engine
ii  tomcat7-admin                               7.0.52-1ubuntu0.3                                   all          Servlet and JSP engine -- admin web applications
ii  tomcat7-common                              7.0.52-1ubuntu0.3                                   all          Servlet and JSP engine -- common files
ii  tomcat7-docs                                7.0.52-1ubuntu0.3                                   all          Servlet and JSP engine -- documentation
ii  tomcat7-examples                            7.0.52-1ubuntu0.3                                   all          Servlet and JSP engine -- example web applications

This GeoServer instance is running version 2.8.0. For more information please contact the administrator.

After testing Iant's answer I get:

Warning: Couldn't read data from file "spec.json", this makes an empty POST.

What I did was:

gery@gery ~ $ curl -H "Content-Type: application/json" -X POST --data @spec.json http://localhost:8080/geoserver/pdf/print.pdf > print.pdf
Warning: Couldn't read data from file "spec.json", this makes an empty POST.
% Total    % Received % Xferd  Average Speed   Time    Time    Time  Current
                             Dload  Upload   Total   Spent    Left  Speed
100  9379    0  9379    0     0   384k      0 --:--:-- --:--:--

--:--:-- 398k

  • Does that image exist? Try removing the reference to it. – Ian Turton Nov 14 '15 at 16:14
  • the image exists, that's the weird thing – Gery Nov 14 '15 at 16:24
  • I found that /var/lib/tomcat7/work/Catalina/localhost/geoserver contains mapfish-print2446310071355869802.pdf.printout (mapfish-print2446310071355869802.pdf.printout: PDF document, version 1.5 ) which is a PDF file (not completed afaik), also found that in the geoserver.log appears a WARN before PDF generation failed: 2015-11-14 14:38:31,935 WARN [servlet.BaseMapServlet] - Cannot delete file:/var/lib/tomcat7/work/Catalina/localhost/geoserver/wicket-filestore – Gery Nov 14 '15 at 20:22
  • After deleting this *.pdf.printout file, I re-run the creation of PDF and the same *.pdf.printout appeared, why is that? – Gery Nov 14 '15 at 20:41
  • may be you have a template issue – Ian Turton Nov 18 '15 at 14:38
2

I can't recreate your issue though I'm using GeoServer 2.7.2 which might matter.

If I install GeoServer and add the matching print extension, I can then do:

curl -H "Content-Type: application/json" -X POST --data @spec.json http://localhost:8080/geoserver/pdf/print.pdf > print.pdf

when spec.json contains the following:

{"pages":[
{
  "center":[-98,36],
  "mapTitle":"Map title",
  "comment":"Some comments", 
  "scale": 4000000.0,
  "rotation":"0"
}
],"dpi":"75","units":"degrees","srs":"EPSG:4326","layers":[
{
  "baseURL":"http://vmap0.tiles.osgeo.org/wms/vmap0",
  "opacity":1,
  "singleTile":false,
  "customParams":{},
  "type":"WMS",
  "layers":["basic"],
  "format":"image/png",
  "styles":[],
  "overview":true
},
{
  "baseURL":"http://localhost:8080/geoserver/wms?",
  "opacity":1,
  "singleTile":true,
  "customParams":{"TRANSPARENT":true},
  "type":"WMS",
  "layers":["topp:states"],
  "format":"image/png",
  "styles":[],
  "overview":false
}
],
  "layout":"A4 portrait"}

and I've modified the default config.yaml file to point to a local logo and added vmap0.tiles.osgeo.org to the list of permitted hosts using:

- !dnsMatch
    host: vmap0.tiles.osgeo.org
    port: 80

and everything works fine.

|improve this answer|||||
  • Thanks for your answer, I got Warning: Couldn't read data from file "spec.json", this makes an empty POST., what does it mean? I mean, is a software piece missing? – Gery Nov 19 '15 at 2:27
  • did you install geoserver with the web archive (i.e., geoserver.war)? perhaps that would be my issue? I updated my post and put what I have installed related to geoserver. – Gery Nov 19 '15 at 2:32
  • you have to have a file called "spec.json" for curl to send to the server, see the example I gave in the answer. – Ian Turton Nov 19 '15 at 8:40
  • ok, I did and it didn't give any warnings, but this outputs when I open it: mupdf print.pdf error: cannot recognize version marker warning: trying to repair broken xref error: cannot find page -1 in page tree mupdf: warning: Cannot load page Segmentation fault. Moreover, it says Segmentation fault when I click on the opened pdf. – Gery Nov 19 '15 at 13:43
  • try upgrading to GeoServer 2.7 or 2.8 (though it should be ok) and make sure you have matched the extension to GS Version exactly – Ian Turton Nov 19 '15 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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