There are several open source reporting solutions in the "market" but the most promising one from my view point is combination of http://jasperreports.sourceforge.net/" title="JasperReports">JasperReports as report engine, http://ireport.sourceforge.net/index.php?p_module=page&pageid=25">iReports as report designer and http://oreports.com/">Open Reports as the reporting portal. I am not java programmer (although I have done some serious maintenance coding with Java and Lotus Domino) nor an expert of deploying or installing java software. The task of setting up Open Reports application seems daunting to me and might take a while to complete. These are my notes, mainly for myself, as what I have done and what needs to be done. I write these in English in hope that they will help some one else struggling with the same task.
Prerequisites. I'm doing this on Ubuntu 5.10 and have already installed java:
java version "1.5.0_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)
I've downloaded the Open Reports zip-file and read the installation guide. It seems to me that I should have two other applications installed: Tomcat (as the servlet engine) and Ant (to build the servlet) that I don't yet have. I do have both MySQL and Postgresql installed and also have downloaded jdbc-driver for Postgresql on my previous adventures. I probably have jdbc-driver for MySQL as well but I am not going to use it. Ant can be installed from Synaptic, which I do. While Synaptic is installing Ant I download http://tomcat.apache.org/download-55.cgi#5.0.28" title="Tomcat core">Tomcat core from apache.org. If I recall right the easiest method of installing it is just untar it somewhere and you have working version. Securing Tomcat is another matter and will be left for another time.
- cd /data/shared
- tar zxvf ~/Desktop/jakarta-tomcat-5.0.28.tar.gz
- export JAVA_HOME=/usr
- cd jakarta-tomcat-5.0.28/bin
- ./startup.sh
Done. Browsing to http://localhost:8080/ confirms that Tomcat is up and running happily.
Ant is installed as well, so it is time to tackle the harder part of the installation, configuring, compiling and deploying the Open Reports.
- cd /data/shared
- unzip ~/Desktop/openreports-1.0-M1.zip
- cd openreports/database/schema
- createuser openreports (no permission to create databases or new users)
- createdb -Oopenreports -EUTF-8 oreports
- psql oreports
- alter user openreports with encrypted password 'xxxx';
- \q
- psql -U openreports -h localhost oreports
- \i or_ddl_postgre.sql
DOH:
psql:or_ddl_postgre.sql:48: ERROR: syntax error at or near "create" at character 309
There are no semicolons at the end of the statements. Let's edit the file. We will do the whole thing in one big transaction so that we don't have to drop tables when additional errors are encountered. First line should be "begin;" and the last line "commit;". To my surprise the file completes nicely after inserting the semicolons. There are additional tables under quartz-directory and this time I take a peek at the file before attempting anything. There are semicolons and even a commit at the end of the file. There also is a note that should be taken in account:
In your Quartz properties file, you'll need to set org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.PostreSQLDelegate
I have no idea what the Quartz is or where the properties-file lies, but I'm quite confident that I will encounter it in the later steps of the installation. So
- psql -U openreports -h localhost oreports
- begin
- \i tables_postgres.sql
Too much bash programming rottens your spinal core or at least your ability to spot problems:
psql:tables_postgres.sql:161: ERROR: syntax error at or near "#" at character
The postgresql supports two kinds of comments: c-style or sql-style which means "--" as the comment marker, not "#" comments. There is also a set of drop commands that are not needed unless we are doing re-install. I'l comment them out and add the begin-clause just in case. Done.
- insert into report_user (name,password,admin,external_id,email_address,pdf_export_type) values ('mos','xxxx',true,,,0);
DOH:
ERROR: null value in column "reportuser_id" violates not-null constraint
As I have no idea how report_user_ids are set or distributed I'll pick 42 as the ultimate truth.
- insert into report_user (report_user_id,name,password,admin,external_id,email_address,pdf_export_type) values (42,'mos','xxxx',true,,,0);
- cd ../../src
- xemacs hibernate.properties
I'm completely guessing here but probably something like this is required:
hibernate.dialect net.sf.hibernate.dialect.PostgreSQLDialectI also commented JNDI-line out.
hibernate.connection.driver_class=org.postgresql.Driver
hibernate.connection.url=jdbc:postgresql:localhost:5432/oreports
hibernate.connection.username=openreports
hibernate.connection.password=xxxx
- xemacs quartz.properties
Again, a shot in the dark.
org.quartz.dataSource.myDS.driver = org.postgresql.Driver
org.quartz.dataSource.myDS.URL = jdbc:postgresql:localhost:5432/oreports
org.quartz.dataSource.myDS.user = openreports
org.quartz.dataSource.myDS.password = xxxx
org.quartz.dataSource.myDS.maxConnections = 5
- cd ..
- ant war
What now? I have war-file somewhere. This probably needs now to be deployed into tomcat somehow. I guess this is done by copying the .war-file to the tomcat/webapps-directory and restarting the tomcat. But wait, did I remember to copy the necessary libs to right places before building the war-file? No. Redo.
- cd lib
- cp /usr/share/java/pg74.216.jdbc3.jar .
- ant war
War-file seems to be under deploy, let's see what it contains: jar tvf openreports.war. Nope, no pg74.216.jdbc3.jar, this will not work. I guess I could redo this by putting the jar-file under /WebRoot/WEB-INF/lib or perhaps if I deploy it separately as it. I'll try the latter one first. I'm bored and want to see results as soon as possible. Yet one other thing to take note is the version of jasperReports.jar file. It seems to be version 1.0.1, which I hope is the same one the iReports I'm going to install uses.
- cp openreports.war /data/shared/jakarta-tomcat-5.0.28/webapps/
- cp lib/pg74.216.jdbc3.jar /data/shared/jakarta-tomcat-5.0.28/common/lib/
- cd /data/shared/jakarta-tomcat-5.0.28/bin/
- ./shutdown.sh
- ./startup.sh
iReport is easy to install. Download and untar. The only catch is after starting where you have to provide correct classpath with jdbc-drivers you are going to use. That is done under Tools/Classpath. Then I need a database to play with. I have plenty of those. A little bit this and that and vóila I have a report. Unfortunately a peek at the lib-directory under the iReports shows that it is running jaspereports 1.1.1, which might be a problem considering the compiled reports. I guess the compiled report is a file with ".jasper" extension. I'll redo the war-file with jasperreports 1.1.1 found under iReport-lib directory, just to be on the safe side. I note that the version of jchart is the same in both apps. My first report does nothing fancy, just dumps rows from a single table, so it should not need the freechart to anything. I also do a directory where I shall deploy the reports, the so called "basedirectory".
- cp jasperreports-1.1.1.jar /data/shared/openreports/WebRoot/WEB-INF/lib/
- cd /data/shared/openreports/
- ant war
- mkdir /data/shared/reports
And that was a mistake. Basedirectory should be under the webapps-directory where the war-file has "exploded" as directory tree under openreports. The directory to be created should have been: /data/shared/jakarta-tomcat-5.0.28/webapps/openreports/reports/
Some black magic is also needed to get the report ready for running. First of all you need to build a data source. That is easy if you have managed to compile and run a report and got this far. Simply copy the necessary settings from above. Then you need to upload the report-file and create a report. Then a report-group is needed and your new report needs to be added to it. Then you have to add yourself to the report group and logoff and login to see the report group under "home". After all this hassle you are ready to run and face brutal truth, "Your report was compiled with different version of jasperReports!". DOH!
The possible explanation is that once you "deploy" the .war file and it gets expanded any new .war files with same name will not get expanded. The fact that I can find old jasperReports.jar under webapps/openreports/WEB-INF/lib seems to support this theory. Oh, well. Just shutdown and copy new .jar-file manually, restart, and? Nope Sherlock, you just forgot to delete the old jar file when you did the rebuild. A rm-command was needed. Now it runs, but the result is not what it is supposed to be. Wait, if I run the report as an image instead! Eureka! We have a report!
There also is a setting under users to choose "Single request PDF" which fixes the problem with pdf-based reports. This definetely works! Now I should remember to delete the .jar file from the source and do a rebuild and redeploy of the .war file or I'll have broken Open Reports again when I restart the Tomcat. This notice concludes this entry and I'm off to build some serious reports with parameters and graphics and...