Search code examples
jasper-reportshsqldbjasperstarter

Running a JasperReport with JasperStarter doesn't create an output file


I have the following set-up:

  • A LibreOffice Base mybase.odb connected to an HSQLDB Split-DB named mydb
  • A form within with a button to open a report
  • A macro behind this button that basically performs:
   shell(convertToUrl(Tools.Strings.DirectoryNameOutOfPath( _
                      ThisComponent.Parent.getURL(), "/") & "myReport.cmd"), HIDE)
  • myReport.cmd contains:
    :: From: http://hsqldb.org/doc/2.0/guide/listeners-chapt.html#lsc_listener_types
    start /min java -cp %~dp0driver/hsqldb.jar org.hsqldb.server.Server
        --database.0 file:mydb --dbname.0 mydb

    timeout /t 3

    :: From: http://jasperstarter.cenote.de/index.html
    jasperstarter -v pr %~dp0myReport.jasper -r -o . -f pdf
        -H [localhost|127.0.0.1] --db-port 9001 -n mydb -u myuser

[Line breaks inserted for easier reading here.]

The HSQLDB server starts succesfully:

...
[Server@1742700]: Startup sequence completed in 382 ms.
[Server@1742700]: 2016-05-09 23:05:49.129 HSQLDB server 2.3.2 is online on port 9001
...

The subsequent JasperStarter doesn't show any error but no PDF is created.

Following the HSQLDB server output Server@1742700 I also tried (with little hope):

jasperstarter ... -H 1742700 ... -n Server

to no avail.

The following in myReport.cmd works like a charm standalone:

jasperstarter pr %~dp0myReport.jasper -r -o . -f pdf -t generic
    --jdbc-dir %~dp0driver --db-driver org.hsqldb.jdbcDriver
    --db-url jdbc:hsqldb:file:%~dp0database/mydb;sql.syntax_mys=true;shutdown=true
    -u myuser

[Line breaks inserted for easier reading here.]

But not, of course, if mybase.odb is open:

Unable to connect to database: Database lock acquisition failure: lockFile:
org.hsqldb.persist.LockFile@68306856[file =<path>\database\mydb.lck, exists=true,
locked=false, valid=false, ] method: checkHeartbeat read: 2016-05-09 21:25:13
heartbeat - read: -6188 ms.

BTW, why locked=false when the lock file exists?


Solution

  • Only one Java process at a time can connect to a file: database. The message indicates the second process cannot acquire a lock because the lock file has been created by the other process and does exist.

    You should change the setup so that HSQLDB Server is started before you start LibreOffice. LibreOffice then connects to the server database, and your macro no longer starts the server and just starts the report generator with the Server URL.