-1

Hi all we are planning to upgrade our project from Java 8 to Java 11. Therefore Spring version of the project shall be changed from Spring 4x to Spring 5x

The view resolving was done in Spring 4x as follows

1) spring xml configuration:

<bean class="org.springframework.web.servlet.view.XmlViewResolver">
    <property name="location" value="/WEB-INF/jasper-view.xml"/>
    <property name="order" value="0"/>
</bean>

2) jasper-view.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xsi:schemaLocation="
  http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

    <!--here all the url value should contains the valid path for the jrxml file-->

    <bean id="purchasePdf"
          class="org.springframework.web.servlet.view.jasperreports.JasperReportsPdfView"
          p:url="classpath:reports/purchaseReport.jrxml"
          p:reportDataKey="datasource" />

So with the upgrade Spring version was updated to 5.2.5.RELEASE and jasper version was updated as follows:

<dependency>
    <groupId>net.sf.jasperreports</groupId>
    <artifactId>jasperreports</artifactId>
    <version>6.4.0</version>
</dependency>

The project is building without and error but gives the following error when deploying in Tomcat server:

Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.web.servlet.view.jasperreports.JasperReportsPdfView] for bean with name 'purchasePdf' defined in ServletContext resource [/WEB-INF/jasper-view.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.web.servlet.view.jasperreports.JasperReportsPdfView

It seems Spring 5 has dropped it's Jasper support

https://github.com/spring-projects/spring-framework/issues/17884

Is there an alternative solution for this?

B378
  • 987
  • 2
  • 12
  • 27

1 Answers1

1

It recommends to use the native JasperReports API:

As a consequence, we rather recommend native use of the JasperReports API in Spring MVC handler methods, generating reports from specifically designed RESTful endpoints. We are dropping our now semi-useless JasperReports view class hierarchy as of Spring Framework 5.0. Note that our existing support against the deprecated JRExporter API remains around in the Spring Framework 4.3.x line until 2019, in particular for existing applications. However, even with 4.3, native use of the JasperReports API is worth considering.

I suppose these are part of the challenges / pains of doing an upgrade.

geffchang
  • 3,279
  • 2
  • 32
  • 58