piatok 28. apríla 2017

JasperServer 6.3.0: how to change default output destination in job scheduling

Default output to repository is impractical when you prefer storing to filesystem, e.g. to /var/local/reports/ directory. You can achieve that by editing following files:

in file scripts/scheduler/model/jobModel.js on two places change this one line:

saveToRepository: false,

to these two lines:

saveToRepository: false,
outputLocalFolder: "/var/local/reports/",

and in files:

optimized-scripts/scheduler/model/jobModel.js
optimized-scripts/scheduler/schedulerMain.js

change all occurences of this:

saveToRepository:!0

to this:

saveToRepository:0,outputLocalFolder:"/var/local/reports/"

and enjoy desired behaviour. JasperServer needs to have write permission to specified folder.

streda 26. apríla 2017

How to run JasperServer 6.3.0 via systemd as non-root user on Linux

Prerequisities

  • JasperServer 6.3.0 installed as root into /opt/jasperreports-server-cp-6.3.0/
  • user apache existing in /etc/passwd (if it is not the case, use other user or create one - shell access not needed... subsequent how to is out of scope of this article)
  • tested on CentOS 7, but should be working also on other systems with systemd
Now, let's do it.

Change ownership of installation from root to user

sudo chown -R apache /opt/jasperreports-server-cp-6.3.0/

Create systemd unit configuration file

sudo vim /usr/lib/systemd/system/jasper-server.service

with this content:

[Unit]
Description=Jasper Server 6.3.0
After=syslog.target
After=network.target

[Service]
Type=forking

User=apache
Group=apache

Restart=on-failure
PIDFile=/run/jasper_server.pid
KillMode=mixed
ExecStart=/opt/jasperreports-server-cp-6.3.0/ctlscript.sh start
ExecStop=/opt/jasperreports-server-cp-6.3.0/ctlscript.sh stop
RestartSec=10s

TimeoutSec=900

[Install]
WantedBy=multi-user.target

Daemon reload after later changes of jasper-server.service file:

sudo systemctl daemon-reload

Set it to start-up automatically

sudo chkconfig jasper-server on

Then it could be controlled this way:

sudo service jasper-server start
sudo service jasper-server stop
sudo service jasper-server restart

And checked, if running, this way:

ps -ef | grep jasper

Or checked if running locally (in its default configuration on TCP/HTTP port 8080 of Apache Tomcat):

telnet localhost 8080

Troubleshoot, if needed:

cat /opt/jasperreports-server-cp-6.3.0/apache-tomcat/logs/catalina.out
cat /opt/jasperreports-server-cp-6.3.0/apache-tomcat/logs/catalina.out | grep -i error

If needed, allow JasperServer HTTP port on firewall

CentOS 7 netfilter is controlled by firewall-cmd by default, so when JasperServer / Apache Tomcat is in its default configuration, do this:

sudo firewall-cmd --zone=public --permanent --add-port=8080/tcp
sudo firewall-cmd --reload

Then it should be accessible from remote browser via http://
:8080/jasperserver
.

Enjoy.