-
Notifications
You must be signed in to change notification settings - Fork 14
java.lang.NoSuchMethodError: com.vaadin.ui.Grid$Column.getValueProvider() issue #30
Description
I am able to run you sample demo smoothly in my local. It look nice, thanks.
But I encounter some issue when I try to leverage it into my own project.
== Add comment at Oct 16 , 2017==
I use Vaadin 8.1.5.
after add below into ExportExcelComponentConfiguration, I find the error change to "getValueProvider()" not find issue.
It can export to excel in case I provide empty data to that grid. So, I am sure it caused by com.vaadin.ui.Grid$Column.getValueProvider()
Other people also report similar issue, so it should be the Vaadin 8.0 & 8.1 grid column.getValueProvider() method change issue.
Can you help to correct it to match latest Vaadin 8.1.X version? Thanks.
private ExportToExcel<Customer> customizeExportExcelUtility(ExportType exportType) { ExportExcelComponentConfiguration<Customer> componentConfig1 = new ExportExcelComponentConfigurationBuilder<Customer>() .withGrid(this.grid) .withVisibleProperties(new String[]{"id","firstName","lastName"}) .withHeaderConfigs(Arrays.asList(new ComponentHeaderConfigurationBuilder().withAutoFilter(true) .withColumnKeys(new String[]{"id_","firstName_","lastName_"}) .build())) .build();
== Original comment at Oct 15 , 2017, at that time is NPE issue==
The "Customer" is my own pojo class.
Dataprovider as below, it is spring JPA for MySQL.
grid.setDataProvider(new ListDataProvider<>(repo.findAll()));
The customizeExportExcelUtility defined as below.
` private ExportToExcel customizeExportExcelUtility(ExportType exportType) {
ExportExcelComponentConfiguration componentConfig1 = new ExportExcelComponentConfigurationBuilder()
.withGrid(this.grid)
.build();
/* Configuring Sheets */
ExportExcelSheetConfiguration sheetConfig1 = new ExportExcelSheetConfigurationBuilder()
.withReportTitle("Grid (Default)")
.withSheetName("Grid (default)")
.withComponentConfigs(Arrays.asList(componentConfig1))
.withIsHeaderSectionRequired(Boolean.TRUE)
.withDateFormat("yyyy-mm-dd")
.build();
/* Configuring Excel */
ExportExcelConfiguration<Customer> config1 = new ExportExcelConfigurationBuilder<Customer>()
.withGeneratedBy("Scott Huang")
.withSheetConfigs(Arrays.asList(sheetConfig1))
.build();
return new ExportToExcel<>(exportType, config1);
}`
Everything is smooth, grid can show/filter as usual.
However, I encounter NPE issue as below when I try to click to export to excel.
Can you help shed a light on it? Thanks.
`java.lang.NullPointerException: null
at org.vaadin.addons.excelexporter.ExportToExcel.addGridDataRow(ExportToExcel.java:395) [vaadin-excel-exporter-2.0.jar:2.0]
at org.vaadin.addons.excelexporter.ExportToExcel.addGridContent(ExportToExcel.java:248) [vaadin-excel-exporter-2.0.jar:2.0]
at org.vaadin.addons.excelexporter.ExportToExcel.addGridToExcelSheet(ExportToExcel.java:231) [vaadin-excel-exporter-2.0.jar:2.0]
at org.vaadin.addons.excelexporter.ExportToExcel.addGridToExcelSheet(ExportToExcel.java:197) [vaadin-excel-exporter-2.0.jar:2.0]
at org.vaadin.addons.excelexporter.ExportToExcel.addComponents(ExportToExcel.java:124) [vaadin-excel-exporter-2.0.jar:2.0]
at org.vaadin.addons.excelexporter.ExportToExcel.process(ExportToExcel.java:115) [vaadin-excel-exporter-2.0.jar:2.0]
at org.vaadin.addons.excelexporter.ExportToExcel.(ExportToExcel.java:91) [vaadin-excel-exporter-2.0.jar:2.0]
at com.example.demo.view.UIScopedView.customizeExportExcelUtility(UIScopedView.java:155) [classes/:na]
at com.example.demo.view.UIScopedView.lambda$init$61446b05$2(UIScopedView.java:96) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
......
java.lang.NullPointerException: null
at org.vaadin.addons.excelexporter.ExportToExcel.addGridToExcelSheet(ExportToExcel.java:235) ~[vaadin-excel-exporter-2.0.jar:2.0]
at org.vaadin.addons.excelexporter.ExportToExcel.addGridToExcelSheet(ExportToExcel.java:197) ~[vaadin-excel-exporter-2.0.jar:2.0]
at org.vaadin.addons.excelexporter.ExportToExcel.addComponents(ExportToExcel.java:124) ~[vaadin-excel-exporter-2.0.jar:2.0]
at org.vaadin.addons.excelexporter.ExportToExcel.process(ExportToExcel.java:115) ~[vaadin-excel-exporter-2.0.jar:2.0]
at org.vaadin.addons.excelexporter.ExportToExcel.(ExportToExcel.java:91) ~[vaadin-excel-exporter-2.0.jar:2.0]
at com.example.demo.view.UIScopedView.customizeExportExcelUtility(UIScopedView.java:155) ~[classes/:na]
at com.example.demo.view.UIScopedView.lambda$init$61446b05$2(UIScopedView.java:96) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
`