javaexcelspringexport-to-pdfdandelion

java.lang.ClassNotFoundException: com.github.dandelion.datatables.core.export.ExportProperties


I am using dandalion datatables with my spring project. I want to export my datatables grid to pdf,excel etc.

So I started with PDF

As per this link

I followed the steps one by one.

Step 1 : Added jar files

datatables-export-itext-0.10.0.jar
datatables-export-poi-0.10.0.jar
datatables-export-poi-ooxml-0.10.0.jar
itext-1.3.jar

Step 2 : Web.xml Filter adding

 <!-- Dandelion-Datatables filter definition (used for export) -->
<filter>
    <filter-name>datatablesFilter</filter-name>
    <filter-class>com.github.dandelion.datatables.extras.servlet2.filter.DatatablesFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>datatablesFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

And in jsp

 <datatables:table id="roles" data="${list}" cssClass="table table-striped" pageable="true" displayLength="5" filterable="true" processing="true" autoWidth="true" export="pdf">
  <datatables:column title="Id" property="roleId" />
  <datatables:column title="Role" property="role" />
  <datatables:export type="pdf" cssClass="btn btn-small" />
 </datatables:table>

But I am getting following error.

java.lang.ClassNotFoundException: com.github.dandelion.datatables.core.export.ExportPropertiesat org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1360) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1206) at com.github.dandelion.datatables.extras.servlet2.filter.DatatablesFilter.doFilter(DatatablesFilter.java:88) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.github.dandelion.core.web.DandelionFilter.doFilter(DandelionFilter.java:157) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) at org....

What am I missing??

Please provide any help. Thanks in advance.


Solution

  • Starting from the v0.10.0, the installation steps have changed and the datatables-servlet2 extra, in which leaved the old DatatablesFilter class you've mentionned, no longer exist.

    First of all, ensure to have declared all needed components in your web.xml file, especially DandelionFilter and DandelionServlet. Installation guides here. A migration guide from 0.9.x to 0.10.x has also been written.

    Regarding the export features, it seems you've preferred the filter-based export. In this situation, you have to update your web.xml file as well:

    <!-- Dandelion-Datatables filter used for basic export -->
    <filter>
        <filter-name>datatables</filter-name>
        <filter-class>com.github.dandelion.datatables.core.web.filter.DatatablesFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>datatables</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping> 
    

    Read more here about the requirements when using filter-based exports.

    By default, the datatables-core JAR provides utility classes for XML and CSV formats. If you want to export in PDF, XLS or XLSX formats, other utilities exist, located in different extras. See the new introduction about export feature here.

    Of course, in order to avoid any other dependency issue, I strongly recommend to use a build tool, such as Maven or Gradle.

    (Disclaimer required by StackOverflow: I'm the author of Dandelion)