
In previous post, I have shown how to creae report in the jasper report studio and deployed the report on jasper server by using JDBC and JNDI datasource. It is very easy if you need only one database to create your reports. but what if you need to use two or more database, xml, excel files to create your reports. In this case, you need new approach to fetch all data you need from the datasources, manipulate in to single datasource and feed those data into your reports. Jasper Report Server support several datasources which included solution for this scenario. Manipluating multiple datasource into single one and allow reports consume those data could be done through,JRDataSource and Webservice datasource. In this post, I will show how to use webservice includes REST and SOAP webservice as datasource to develop and deploy the report into the server. Webservice is very popular api to provide datasource to application, it provides high flexibility application programming interface to application so it has been widely adapted in the industry.
Table Contents
Content of this post is arranged as below
- Install Webservice Datasource on Jasper Studio
- Install Webservice Datasource on Jasper Server
- Deploy Report by Webservice Datasource into Jasper Server
- Reference
For my environment setup, I have use as below
For Database Server
- OS - FreeBSD 12
- Database - PostgreSQL 12
For Report Server
- OS - Ubuntu 20.10 LTS
- OpenJDK 8
- Wildfly Application Server 10.0.10
- Jasper Report Server 6.8
I recommand you have more than 4GB Memory, 16 GB Storage, 2 Core for each server.
1. Install Webservice Datasource on Jasper Studio
First, you need to download webservice plugin for jasper studio from the website.
- unzip the download file and copy files in JSS floder
- Go Jaspersoft Studio Installation directory which refered as [JSS_DIR]. Paste copies files [WS_DS_DIR]\JSS
Note : For Jaspersoft Studio 6.4.0 and 6.5.1 on windows 10, You need to put the jar files into [JSS_DIR]\dropins\eclipse\plugins
Now, you can create on report on the report studio by using webservice
2. Install Webservice Datasource on Jasper Server
Once you create report on studio, when you deploy it to the server. You need to use webservice datasource in the server. To create webservice datasource on the server, you need to install plugin in to the server. You can follow by below step to install webservice plugin into the jasper report server.
- Go to download floder. Inside this folder, copy all files and folders in \JRS\WEB-INF
- Stop your web server running JasperReports Server
-
Go to server that you deploy report server.
$ sudo systemctl stop wildfly phoud@srv01:~/download/JRS/WEB-INF$ ls -la total 20 drwxr-xr-x 4 phoud phoud 4096 Jun 13 07:35 . drwxr-xr-x 3 phoud phoud 4096 Jun 13 07:35 .. -rw-r--r-- 1 phoud phoud 2525 Jul 25 2016 applicationContext-WebServiceDataSource.xml drwxr-xr-x 2 phoud phoud 4096 Jun 13 07:35 bundles drwxr-xr-x 2 phoud phoud 4096 Jun 13 07:35 lib $ sudo cp -R * /opt/wildfly/standalone/deployments/jasperserver-ce.war/WEB-INF/
-
Next is to edit applicationContext-WebServiceDataSource.xml in the deployed folder as below. At line 49 of the xml file, inside the bean addQueryLanguage change the property beanName from queryLanguagesPro to queryLanguagesCe
$ cd /opt/wildfly/standalone/deployments/jasperserver-ce.war/WEB-INF/ $ sudo vim applicationContext-WebServiceDataSource.xml <bean id="addQueryLanguage" class="com.jaspersoft.jasperserver.api.common.util.spring.GenericBeanUpdaterDefinition"> <property name="order" value="10"/> <!-- Replace line 49 with the commented line below if you are running Community Edition! --> <property name="beanName" value="queryLanguagesCe"/> <!-- <property name="beanName" value="queryLanguagesPro"/> --> <property name="propertyName" value="sourceList"/> <property name="operation" value="append"/> </bean>
-
Next is to start application server.
$ sudo systemctl start wildfly $ sudo systemctl status wildfly ● wildfly.service - The WildFly Application Server Loaded: loaded (/etc/systemd/system/wildfly.service; enabled; vendor preset: enabled) Active: active (running) since Sun 2021-06-13 08:41:58 UTC; 12min ago Main PID: 634 (launch.sh) Tasks: 80 (limit: 2281) Memory: 1.3G CGroup: /system.slice/wildfly.service ├─634 /bin/sh /opt/wildfly/bin/launch.sh standalone standalone.xml 0.0.0.0 ├─641 /bin/sh /opt/wildfly/bin/standalone.sh -c standalone.xml -b 0.0.0.0 └─738 java -D[Standalone] -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modu> Jun 13 08:41:58 srv01 systemd[1]: Started The WildFly Application Server.
3. Deploy Report by Webservice Datasource into Jasper Server
First, You need to create webservice datasource on the service side by logging in to the jasperserver. Go to repository.
-
Right click at Data sources > Add Resource > Datasource
-
Select webServiceDataSource, fill out connection information
-
Set data source name and description, finally save.
once finished creating webservice datasource, you just need to publish report to the server. In this process, just select data source but there is no need to select query. The process of deploy report to the server, you just follow below.
No comments:
Post a Comment