mapfish / mapfish-print

A component of MapFish for printing templated cartographic maps. This module is the Java serverside module.
http://mapfish.github.io/mapfish-print-doc/
BSD 2-Clause "Simplified" License
184 stars 417 forks source link

Dynamic table generation don't woks anymore #194

Closed sbrunner closed 9 years ago

sbrunner commented 9 years ago

Project datas: https://github.com/camptocamp/demo_geomapfish/tree/printV3/print/print-apps/demo

Result:

15:32:53.110 [ForkJoinPool-1-worker-1] DEBUG o.m.p.p.ProcessorDependencyGraph - Finished executing processor graph: 
+ JasperReportBuilder(/home/sbrunner/demo_geomapfish/print/print-apps/demo/.)
+ LegendProcessor
+ CreateNorthArrowProcessor
+ CreateScalebarProcessor
+ CreateMapProcessor
+ DataSourceProcessor
Exception in thread "main" java.util.concurrent.ExecutionException: java.lang.NullPointerException
        at jsr166y.ForkJoinTask.get(ForkJoinTask.java:913)
        at org.mapfish.print.output.AbstractJasperReportOutputFormat.getJasperPrint(AbstractJasperReportOutputFormat.java:159)
        at org.mapfish.print.output.AbstractJasperReportOutputFormat.print(AbstractJasperReportOutputFormat.java:109)
        at org.mapfish.print.MapPrinter.print(MapPrinter.java:138)
        at org.mapfish.print.cli.Main.run(Main.java:156)
        at org.mapfish.print.cli.Main.main(Main.java:112)
Caused by: java.lang.NullPointerException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        at jsr166y.ForkJoinTask.getThrowableException(ForkJoinTask.java:507)
        at jsr166y.ForkJoinTask.get(ForkJoinTask.java:912)
        ... 5 more
Caused by: java.lang.NullPointerException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        at jsr166y.ForkJoinTask.getThrowableException(ForkJoinTask.java:507)
        at jsr166y.ForkJoinTask.reportResult(ForkJoinTask.java:567)
        at jsr166y.ForkJoinTask.join(ForkJoinTask.java:611)
        at org.mapfish.print.processor.ProcessorDependencyGraph$ProcessorGraphForkJoinTask.compute(ProcessorDependencyGraph.java:206)
        at org.mapfish.print.processor.ProcessorDependencyGraph$ProcessorGraphForkJoinTask.compute(ProcessorDependencyGraph.java:161)
        at jsr166y.RecursiveTask.exec(RecursiveTask.java:64)
        at jsr166y.ForkJoinTask.doExec(ForkJoinTask.java:305)
        at jsr166y.ForkJoinWorkerThread.execTask(ForkJoinWorkerThread.java:575)
        at jsr166y.ForkJoinPool.scan(ForkJoinPool.java:755)
        at jsr166y.ForkJoinPool.work(ForkJoinPool.java:617)
        at jsr166y.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:369)
Caused by: java.lang.NullPointerException
        at java.net.URI$Parser.parse(URI.java:3023)
        at java.net.URI.<init>(URI.java:595)
        at org.mapfish.print.servlet.fileloader.AbstractFileConfigFileLoader.resolveChildFile(AbstractFileConfigFileLoader.java:142)
        at org.mapfish.print.servlet.fileloader.AbstractFileConfigFileLoader.isAccessible(AbstractFileConfigFileLoader.java:108)
        at org.mapfish.print.servlet.fileloader.ConfigFileLoaderManager.loadFile(ConfigFileLoaderManager.java:157)
        at org.mapfish.print.config.Configuration.loadFile(Configuration.java:526)
        at org.mapfish.print.processor.jasper.TableProcessor.generateSubReport(TableProcessor.java:311)
        at org.mapfish.print.processor.jasper.TableProcessor.execute(TableProcessor.java:281)
        at org.mapfish.print.processor.jasper.TableProcessor.execute(TableProcessor.java:77)
        at org.mapfish.print.processor.ProcessorGraphNode$ProcessorNodeForkJoinTask.compute(ProcessorGraphNode.java:210)
        at org.mapfish.print.processor.ProcessorDependencyGraph$ProcessorGraphForkJoinTask.compute(ProcessorDependencyGraph.java:203)
        at org.mapfish.print.processor.ProcessorDependencyGraph$ProcessorGraphForkJoinTask.compute(ProcessorDependencyGraph.java:161)
        at jsr166y.RecursiveTask.exec(RecursiveTask.java:64)
        at jsr166y.ForkJoinTask.doExec(ForkJoinTask.java:305)
        at jsr166y.ForkJoinWorkerThread.execTask(ForkJoinWorkerThread.java:575)
        at jsr166y.ForkJoinPool.scan(ForkJoinPool.java:733)
        ... 2 more
jesseeichar commented 9 years ago

from the stack trace it appears that there is a URL with no schema or host. Make sure all urls are valid

sbrunner commented 9 years ago

Witch URL ? I didn't see any URL in the log ...

sbrunner commented 9 years ago

I run this standalone (without Tomcat) ...

jesseeichar commented 9 years ago

I dont know what url but if you look at the stacktrace:

Caused by: java.lang.NullPointerException
    at java.net.URI$Parser.parse(URI.java:3023)
    at java.net.URI.<init>(URI.java:595)

you can see it is problem with the uri. in my experience this is usually the host name is missing.

sbrunner commented 9 years ago

What's this jasperTemplate ? https://github.com/mapfish/mapfish-print/blob/development/core/src/main/java/org/mapfish/print/processor/jasper/TableProcessor.java#L311

jesseeichar commented 9 years ago

If I remember right. You can define a jasper tempalte with all the styles and columns you want for the table and it will construct a table dynamically with arbitrary number of columns based on the styles declared in the jasper template.

The idea was that for certain projects you need an arbitrary number of columns but want to be able to design the table using jasper studio or some editor. This permits this functionality.

tsauerwein commented 9 years ago
    - !createDataSource
        reportTemplate: table.jrxml
        reportKey: reportTemplate
        processors:
        - !prepareTable
            dynamic: true

I think you don't need a datasource, or do you? Try to do it like in this example: https://github.com/mapfish/mapfish-print/tree/development/core/src/test/resources/org/mapfish/print/processor/jasper/table_converters_dyn

sbrunner commented 9 years ago

Yes I need a data source because I have list of table, Than your example didn't have a list of table, and he isn't dynamic ...

sbrunner commented 9 years ago

dynamic initially mean that we don't know the number of column ...

sbrunner commented 9 years ago

And we strongly need this in GeoMapFish

jesseeichar commented 9 years ago

Have you looked at the examples on how to use this?

On Fri, Feb 20, 2015 at 8:53 AM, Stéphane Brunner notifications@github.com wrote:

And we strongly need this in GeoMapFish

— Reply to this email directly or view it on GitHub https://github.com/mapfish/mapfish-print/issues/194#issuecomment-75201739 .

sbrunner commented 9 years ago

I have a look on this file: https://github.com/mapfish/mapfish-print/blob/development/core/src/test/resources/org/mapfish/print/processor/jasper/table_converters_dyn/requestData.json Only one table, than not the same case as me, And this file: https://github.com/mapfish/mapfish-print/blob/development/core/src/test/resources/org/mapfish/print/processor/jasper/table_converters_dyn/table.jrxml On witch one we should know the number of columns that not my case :-(

jesseeichar commented 9 years ago

so I have this figured out now. the table is configured as dynamic but there is no jasper report configured for the processor.

This is a major problem in that there should be an error message if the table processor is incorrectly configured. I am thinking of:

  1. Providing a default template so you can set default == true and it will automatically work dynamically.
  2. Check that the templates exist and that the styles exist.

After more research I found that the problem was actually DataSourceProcessor not calling validate on all of its contained processor so the errors are never reported. I have fixed this issue and added defaults to the jasperReport template file is optional instead of required.

See:

https://github.com/mapfish/mapfish-print/pull/200

and

https://github.com/mapfish/mapfish-print/pull/202