Trouble with integrating JasperReports with Icinga2

Hi all,

As indicated by the title, I’m having some trouble with getting JasperReports to work with Icinga2

I have JasperReports Server Community Edition v7.1.0 installed and ready to go already (can access web interface, etc.) but I can’t seem to import what I think are the Icinga reporting templates from the icinga-reports module.
Note: I did receive an error telling me that PhantomJS was not working correctly when I initially installed the JasperReports software, but I installed PhantomJS and tested it and it seemed to work just fine, so I proceeded with the installation of JasperReports ignoring this error.

I found this video on the process of doing so, but it is pretty dated – JasperReports as well as Icinga2 have both changed since then.

I first tried to import the contents of icinga-reports/reports/resources into the corresponding JasperReports directory (jasperreports-server-cp-7.1.0/buildomatic/install_resources/export/js-catalog/resources/) and changed the respective .folder.xml files to include the newly added directory and files, but this doesn’t seem to populate the web interface with the new folder/files. This makes me wonder if there is something else that I need to configure located somewhere else.
I then tried to zip the icinga-reports files and import it using the js-import.sh --input-zip method like in the video, with the same result; nothing.

Without this step, I’m unable to connect the Icinga2 IDO DB, so I’m unable to generate reports yet.

Does anybody have some insight? I reached out to @PatrickBahr because he had a similar thread and he seemed to get JasperReports integrated into his environment but he hasn’t responded yet.

Thank you for your time!
watermelon

Never tried it with Jasperserver 7, but here is my dump:

adduser icingareports
cd /usr/src/icinga-reports
./configure --with-jasper-server=/opt/jasperreports-server-cp-latest/  --with-icinga-user=icingareports --with-icinga-group=icingareports
make install-mysql-connector
/opt/jasperreports-server-cp-latest/ctlscript.sh stop tomcat
/opt/jasperreports-server-cp-latest/ctlscript.sh start tomcat
make install
make update #Aktualisiert die jasperreports
mkdir /opt/jasperreports-server-cp-latest/buildomatic/extras
cd /opt/jasperreports-server-cp-latest/buildomatic
cp /usr/src/icinga-reports-1.10.0/reports/icinga/package/js-icinga-reports.zip /opt/jasperreports-server-cp-latest/buildomatic/extras/
/opt/jasperreports-server-cp-latest/buildomatic/js-import.sh --input-zip /opt/jasperreports-server-cp-latest/buildomatic/extras/js-icinga-reports.zip
/opt/jasperreports-server-cp-latest/ctlscript.sh stop tomcat
/opt/jasperreports-server-cp-latest/ctlscript.sh start tomcat
2 Likes

Thanks for that @unic. @PatrickBahr gave me a similar answer via PM, so credit goes to him as well!

It seems that the latest version of the icinga-reports module (v1.10.0) does not include the js-icinga-reports.zip or the option for make install-mysql-connector. Is there a reason for this? So instead of using version 1.10.0 of icinga-reports, I went back a release to v1.10.0-beta, and these options became available for me.

As far as the configure and make routines, they seemed to go as expected (after reverting back to the beta release), pastebin link here for the make output. I then went ahead with @unic’s commands and they ran fine with no errors, and finally I was able to get the templates in Jasper.

I then went to Icinga > Data Sources > IDO to connect the IDO DB. I uploaded the JDBC driver .jar that I got from https://dev.mysql.com/downloads/connector/j/ (v8.0.12, Platform Independent ZIP), under the ‘JDBC Driver’ section for the Data Source properties, making sure to select ‘MySQL (com.mysql.jdbc.Driver)’ as the type also. Then, I filled out all of my DB information and the url turned out to be:
jdbc:mysql://<myServer>:3306/<myDB>

However, when I try to test the connection, it gives me an error saying:

I checked to see that MySQL was listening on 3306, allowed the port through the firewall, disabled SELinux even. There seems to be nothing generated in the logs when I test the connection in /var/log/mariadb or /var/log/messages/, but I do see somehting in the catalina.out logfile:

2018-07-31 14:57:16,668 ERROR JNDIResourceProvider,localhost-startStop-1:75 - error closing context
javax.naming.OperationNotSupportedException: Context is read only
        at org.apache.naming.NamingContext.checkWritable(NamingContext.java:963)
        at org.apache.naming.NamingContext.close(NamingContext.java:758)
        at com.tonbeller.tbutils.res.JNDIResourceProvider.close(JNDIResourceProvider.java:72)
        at com.tonbeller.tbutils.res.CompositeResourceProvider.close(CompositeResourceProvider.java:56)
        at com.tonbeller.tbutils.res.ResourcesFactory.initialize(ResourcesFactory.java:163)
        at com.tonbeller.tbutils.res.ResourcesFactory.<init>(ResourcesFactory.java:92)
        at com.tonbeller.tbutils.res.ResourcesFactory.<clinit>(ResourcesFactory.java:89)
        at com.tonbeller.tbutils.res.ResourcesFactoryContextListener.contextInitialized(ResourcesFactoryContextListener.java:23)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4776)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5240)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1140)
        at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1874)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
...

<later on>

...

Loading class `com.mysql.jdbc.Driver'. This is deprecated. 
The new driver class is `com.mysql.cj.jdbc.Driver'. 
The driver is automatically registered via the SPI and manual 
loading of the driver class is generally unnecessary.

I also tried to use the MariaDB Connector/J instead of the MySQL one, but no change with the “There was an error on the server” message. Now I’m at a loss.

What could I possibly be doing wrong here?

TLDR;
Installed the templates from icinga-reports successfully, but now I can’t connect the IDO DB.

Thanks for your time so far!

1 Like

if you Jaspersever is not on the same Server, try to connect with some other sql tool and try if it works. I switched from mysql to mariaDB because of Debian 9 and I learned the hard way, that there ist more configuration on mariaDB nessesary to allow remote connections.

Quick and dirty allow remote root access without security in mind:

mysql_secure_installation
mysql
use mysql;
UPDATE user SET plugin=""; #to enable remoteaccess 

This SET Plugin is not the best solution i think and proberly it would be better to configure the correct plugin.

1 Like

The problem wasn’t with remote access…

I made a rookie mistake. I was inputting the server’s IP address rather than ‘localhost’ or ‘127.0.0.1’, and therefore, MySQL thought I was connecting externally and either disallowed the connection or the connection was simply unroutable (from my understanding). So, the solution was to just use ‘localhost’ instead of the IP address, and the DB connects!!! I can’t believe I didn’t try that sooner.

I ran a test report and it seems to pull the data off the DB fine, now I just have to figure out how to use JasperReports :grin:

I will write an installation/configuration howto guide for Jasperserver/Jasperreports when I get a chance!

Thanks for your help @unic and @PatrickBahr!