
In the enterprise world, reporting plays a very crucial part of enterprise application. In the market, there are several products such as Power BI, Oracle Business Intelligence, etc. But those of products is proprietary and comes with very expensive cost. So in this post I will demonstrate how to use jasper report server community edition for the reporting system and deploy it on Wildfly application server. In order to install jasper report server, we need to install databases, jasper report server support many types of database product like MySQL, Postgres, MS SQL Server, Oracle, DB2, etc. But in this post, we will use PostgreSQL for installing jasper report server. The step to install Jasper Report Server is arranged as following.
Table Contents
- Installing PostgreSQL Database Server On Ubuntu
- Installing Wildfly Application Server
- Installing Jasper Report Server
- Reference
For our system, we have created platform as below set up
- OS is Unbuntu 20.0.4 LTS
- Open JDK 1.8
- Wildfly Application Server 10.1.0.Final
- PostgreSQL 12
- Jasper Report Server 7.8.0
1.Installing PostgreSQL On Ubuntu
First is to install Database, on our system we use PostgreSQL 12. Installing PostgreSQL on Ubuntu is very easy.
$sudo apt update
$sudo apt install postgresql postgresql-contrib
After installing, we need to configure initail set up. For the setup we will
- Change password for postgres, Create user and assign privileges
- Configure postgres.conf to listener to remote client
- Configure pg_hba.conf for security setup
- Restart PostgreSQL and check whether PostgreSQL is running
$sudo -u postgres psql postgres
#\password postgres
#create user user01 with encrypted password 'password';
#alter user user01 with SUPERUSER;
#\q
$exit
Next we need to configure postgres.conf
$sudo vi /etc/postgresql/12/main/postgresql.conf
listen_addresses = '*'
Then we configure security control
$ sudo vi /etc/postgresql/12/main/pg_hba.conf
# Database administrative login by Unix domain socket
local all postgres md5
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 0.0.0.0/0 md5
After configure both files, we need to restart PostgreSQL
$sudo systemctl restart postgresql
$sudo systemctl status postgresql
$sudo systemctl enable postgresql
$netstat -ntl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN
tcp6 0 0 ::1:3350 :::* LISTEN
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 ::1:631 :::* LISTEN
tcp6 0 0 :::5432 :::* LISTEN
Now, we finished with preparing PostgreSQL
2.Installing Wildfly Service
Next step is to install Widlfly into Ubuntu. But before we install Wildfly, we need to install JDK (OpenJDK) and setup environment. The step we need to prepare Wildfly to install Wildfly is shown following.
- Install JDK
- Download Wildfly
- Install Wildfly Service
First we will install JDK in Ubuntu as below
$sudo apt-get install openjdk-8-jdk
After installing JDK, we need to setup JAVA_HOME and JRE_HOME
$sudo vi /etc/profile
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
JRE_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH
Then we have to apply variable that we just add to the system
$sudo source /etc/profile
$sudo echo $JAVA_HOME
/usr/lib/jvm/java-8-openjdk-amd64
$sudo echo $JRE_HOME
/usr/lib/jvm/java-8-openjdk-amd64/jre
$java -version
openjdk version "1.8.0_275"
OpenJDK Runtime Environment (build 1.8.0_275-8u275-b01-0ubuntu1~20.04-b01)
OpenJDK 64-Bit Server VM (build 25.275-b01, mixed mode)
After we install JDK, next step is to install Wildfly. Wildfly is packed in zip file, so to install wildfly, we just need to download zip file.
$mkdir download
$cd download
$wget http://download.jboss.org/wildfly/10.1.0.Final/wildfly-10.1.0.Final.zip
Note here that on this tutorial we use wildfly 10.1.0.Final. After downloading wildfly, we need to create user and installing folder
$sudo groupadd -r wildfly
$sudo useradd -r -g wildfly -d /opt/wildfly -s /sbin/nologin wildfly
$sudo chown -RH wildfly:wildfly /opt
$sudo mkdir /opt/wildfly
$unzip wildfly-10.1.0.Final.zip
$sudo cp -R wildfly-10.1.0.Final/* /opt/wildfly/
$sudo echo "export JBOSS_HOME=/opt/wildfly" >> /etc/profile
$sudo source /etc/profile
$echo $JBOSS_HOME
/opt/widlfly
Now we need to install wildfly as system service
$sudo mkdir -p /etc/wildfly
$sudo cp /opt/wildfly/docs/contrib/scripts/systemd/wildfly.conf /etc/wildfly/
$sudo cp /opt/wildfly/docs/contrib/scripts/systemd/launch.sh /opt/wildfly/bin/
$sudo sh -c 'chmod +x /opt/wildfly/bin/*.sh'
$sudo cp /opt/wildfly/docs/contrib/scripts/systemd/wildfly.service /etc/systemd/system/
Jasper server has some module (for example, ehcache, etc) need to create file in some directories (For instance, /tmp). These directory is belong to root. So, we need to run Wildfly as root privilege. To run wildfly in root privileges we need to configure /etc/systemd/system/wildfly.service. And change User from wildfly to root as below.
$sudo vim /etc/systemd/system/wildfly.service
[Unit]
Description=The WildFly Application Server
After=syslog.target network.target
Before=httpd.service
[Service]
Environment=LAUNCH_JBOSS_IN_BACKGROUND=1
EnvironmentFile=-/etc/wildfly/wildfly.conf
User=root
LimitNOFILE=102642
PIDFile=/var/run/wildfly/wildfly.pid
ExecStart=/opt/wildfly/bin/launch.sh $WILDFLY_MODE $WILDFLY_CONFIG $WILDFLY_BIND
StandardOutput=null
[Install]
WantedBy=multi-user.target
Then we need to reload daemon.
$sudo systemctl daemon-reload
To configure Wildfly heap memory to run Jasperserver, we can create from $JBOSS_HOME/bin/standalone.conf
$sudo vim /opt/wildfly/bin/standalone.conf
#
# Specify options to pass to the Java VM.
#
if [ "x$JAVA_OPTS" = "x" ]; then
JAVA_OPTS="-Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true"
JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=$JBOSS_MODULES_SYSTEM_PKGS -Djava.awt.headless=true"
else
echo "JAVA_OPTS already set in environment; overriding default settings with values: $JAVA_OPTS"
fi
# Sample JPDA settings for remote socket debugging
Next we need to allow remote access in Wildlfy by editing standalone.xml
$ sudo vi $JBOSS_HOME/standalone/configuration/standalone.xml
<interfaces>
<interface name="management">
<inet-address value="${jboss.bind.address.management:127.0.0.1}"/>
</interface>
<interface name="public">
<inet-address value="${jboss.bind.address:0.0.0.0}"/>
</interface>
</interfaces>
Finally we allow connection port in firewall and start wildfly
$sudo ufw allow 8080/tcp
$sudo systemctl enable wildfly
$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 Sat 2021-01-02 15:27:04 +07; 1s ago
Main PID: 4001 (launch.sh)
Tasks: 51 (limit: 2234)
Memory: 178.9M
CGroup: /system.slice/wildfly.service
├─4001 /bin/sh /opt/server/wildfly-10.1.0.Final/bin/launch.sh standalone standalone.xml 0.0.0.0
├─4004 /bin/sh /opt/server/wildfly-10.1.0.Final/bin/standalone.sh -c standalone.xml -b 0.0.0.0
└─4073 java -D[Standalone] -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.mod>
Jan 02 15:27:04 phoud-ubuntu-vm systemd[1]: Started The WildFly Application Server.
Or we can confirm as following
$ netstat -ntl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:10990 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:40019 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8443 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:9990 0.0.0.0:* LISTEN
tcp6 0 0 ::1:3350 :::* LISTEN
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 ::1:631 :::* LISTEN
tcp6 0 0 :::5432 :::* LISTEN
Now, our application server is installed and ready to run.
3.Secure connection with SSL/TLS for Wildfly
But before installing Jasper Report server on Wildfly, let's do one more step to establish HTTPS for Wildfly connection. we can secure connection to Wildfly we need to setup SSL/TLS to enable HTTPS communication. To do so, we followup
- Create Key
- Configuring Widlfly to enable HTTPS and redirection HTTP to HTTPS
Firstly, we create application key
$su wildfly
$keytool -genkey -keystore application.keystore -alias server -keyalg RSA -storetype pkcs12 -keysize 2048 -validity 36500 -storepass 'password' -keypass 'password' -dname "CN=wildfly.tikkwiki.pro, o=itstikk, c=LA"
$chmod 600 application.keystore
$cp application.keystore $JBOSS_HOME/standalone/configuration
we configuring standalone.xml to enable HTTPS and redirection HTTP to HTTPS
$cd $JBOSS_HOME/standalone/configuration/
$vi standalone.xml
Edit as below.
<security-realm name="ApplicationRealm">
<server-identities>
<ssl>
<keystore path="application.keystore" relative-to="jboss.server.config.dir" keystore-password="password" alias="server" key-password="password" generate-self-signed-certificate-host="localhost"/>
</ssl>
</server-identities>
</security-realm>
Then we redirect all traffic from port 8080 to port 8443
<server name="default-server">
<http-listener name="default" socket-binding="http" redirect-socket="https" enable-http2="true"/>
<https-listener name="https" socket-binding="https" security-realm="ApplicationRealm" enable-http2="true"/>
<host name="default-host" alias="localhost">
<location name="/" handler="welcome-content"/>
<filter-ref name="server-header"/>
<filter-ref name="x-powered-by-header"/>
<filter-ref name="http-to-https" predicate="equals(%p,8080)"/>
</host>
</server>
One more line to add
<filters>
<response-header name="server-header" header-name="Server" header-value="WildFly/10"/>
<response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
<rewrite name="http-to-https" target="https://localhost:8443%U" redirect="true"/>
</filters>
Next we just need to restart server and check whether port 8443 is opened and allow through firewall.
$sudo ufw allow 8443/tcp
$sudo systemctl restart widlfly
$systemctl status wildfly
● wildfly.service - The WildFly Application Server
Loaded: loaded (/etc/systemd/system/wildfly.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2021-01-02 16:07:49 +07; 29min ago
Main PID: 5417 (launch.sh)
Tasks: 117 (limit: 2234)
Memory: 993.0M
CGroup: /system.slice/wildfly.service
├─5417 /bin/sh /opt/server/wildfly-10.1.0.Final/bin/launch.sh standalone standalone.xml 0.0.0.0
├─5418 /bin/sh /opt/server/wildfly-10.1.0.Final/bin/standalone.sh -c standalone.xml -b 0.0.0.0
└─5489 java -D[Standalone] -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.mod
And we check whether the port 8443 is opened
$ netstat -ntl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:10990 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:37903 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8443 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:9990 0.0.0.0:* LISTEN
tcp6 0 0 ::1:3350 :::* LISTEN
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 ::1:631 :::* LISTEN
tcp6 0 0 :::5432 :::* LISTEN
4.Installing Jasper Report Server On Wildfly
Once our platform included database (PostgreSQL) and Application Server is ready. we can start installing Jasper Report Server. We install JapserReport Server from WAR package. First we need to download package.
We unzip the package and reconfigure installation file as below.
$cd download
$wget https://sourceforge.net/projects/jasperserver/files/JasperServer/JasperReports%20Server%20Community%20edition%207.8.0/TIB_js-jrs-cp_7.8.0_bin.zip
$unzip TIB_js-jrs-cp_7.8.0_bin.zip
$ ls
jasperreports-server-cp-7.8.0-bin TIB_js-jrs-cp_7.8.0_bin.zip
$cd jasperreports-server-cp-7.8.0-bin
$ ls
apache-ant buildomatic docs jasperserver.war samples TIB_js-jrs-ce_7.8.0_license.pdf TIB_js-jrs-ce_7.8.0_license.txt
$ cp buildomatic/sample_conf/postgresql_master.properties buildomatic/default_master.properties
Then we need to edit installation file (default_master.properties) we have just copied as following.
$vi buildomatic/default_master.properties
# appServerType = tomcat
# appServerType = jboss-eap-7
# appServerType = wildfly
# appServerType = glassfish
# appServerType = skipAppServerCheck
appServerType = wildfly
# Tomcat app server root dir
# appServerDir = /home/devuser/apache-tomcat-9.0
# if linux package managed tomcat instance, set two properties below
# CATALINA_HOME = /usr/share/tomcat9
# CATALINA_BASE = /var/lib/tomcat9
# JBoss app server root dir
# appServerDir = C:\\wildfly-14.0.1.Final
# appServerDir = /home/devuser/wildfly-14.0.1.Final
appServerDir = /opt/wildfly
# jboss.profile = default
# Glassfish app server root dir
# appServerDir = C:\\glassfish-4.1.2
# appServerDir = /home/devuser/glassfish-4.1.2
# database type
dbType=postgresql
# database location and connection settings
dbHost=localhost
dbUsername=user01
dbPassword=password
# additional database parameters
# (uncomment these if you want non-default settings)
dbPort=5432
Now we could run installation script
$cd buildomatic
$sudo bash js-install-ce.sh
Once installation is completed, we could check by opening browser and go through https://localhost:8443/jasperserver
We could login by using default username/password as jasperadmin/jasperadmin
Now we could access the portal.
No comments:
Post a Comment