You are not logged in.

Roger L

Beginner

  • "Roger L" started this thread

Posts: 24

Date of registration: Apr 12th 2010

  • Send private message

1

Wednesday, May 26th 2010, 12:21am

Jasper Report and Jabaco

Hi,

I have written a Jasper report using iReport and my H2 database - all works fine in iReport. I am then using the following code to try to run the report from a button in my Jabaco application :-



Dim jd As JasperDesign=JRXmlLoader.load("TypeList.jrxml")
Dim jr As JasperReport=JasperCompileManager.compileReport(jd)
Dim jp As JasperPrint=JasperFillManager.fillReport(jr,Null,con)
JasperViewer.viewReport(jp,False)



I have set up all the references as described in the post on using JasperReports with Jabaco elsewhere on this site.



The file TypeList.jrxml is in my current directory, as is the database (which has already got a connection con from my Form_Load routine. I am getting the following error from the first line of my code, which suggests that the jrxml load routine is looking for the database in the directory in which jar for the referenced class exists - which doesn't make much sense to me as I don't believe I should be trying to access the database until the fill operation, and the connection con that I have is to the database in the current ie working directory.



org.h2.jdbc.JdbcSQLException: IO Exception: "java.io.FileNotFoundException: C:\Program Files\Jaspersoft\iReport-3.7.2\ireport\modules\ext\LodgeBooks.lock.db (Access is denied)"; "C:\Program Files\Jaspersoft\iReport-3.7.2\ireport\modules\ext\LodgeBooks.lock.db" [90031-134]



I suspect that I am a victim of either my java ignorance or my jasperReports ignorance! Any suggestions to resolve this issue much appreciated.



Regards

Roger L

Roger L

Beginner

  • "Roger L" started this thread

Posts: 24

Date of registration: Apr 12th 2010

  • Send private message

2

Wednesday, May 26th 2010, 6:19am

Very strange!

I shut down Jabaco and left my project for a couple of hours. I was hoping for a reply to my query above - but failing that I thought I would have another go at the project. No change to code (I promise) - but when I try to run it now everything works as intended - the error shown above does not occur.

The only conclusion I can come to is that there may be a need under certain circumstances to exit Jabaco and restart in order for registered libraries to work - but that doesn't sound right to me.

Anyway - the main thing is - it works now!



Roger L

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

3

Wednesday, May 26th 2010, 10:58am

Never assume a specific working directory

Hi Roger,
your observation reminds me of discussions we've had on the topic of "current working directory".
A Jabaco code should avoid assumptions with regard to the current working directory. This concept is not present in Java.
As a consequence, all filenames should be specified with full paths.

If you start the same code from within the Jabaco IDE, from a compiled Jar file and from a compiled exe file you usually
end up with different working directories. It makes a difference, if you start the IDE by double click on jabaco.exe or
by double click on a *.jba project file.

The "Access denied" in one of your error messages might be a problem of concurrent access or access rights in general.

Happy experimenting!

A1880

Roger L

Beginner

  • "Roger L" started this thread

Posts: 24

Date of registration: Apr 12th 2010

  • Send private message

4

Thursday, May 27th 2010, 2:41am

Thanks for the comments - I'll take them on board!

I am starting Jabaco with a shortcut pointing to the project file in an attempt to overcome path problems. What I am trying to do is avoid coding full paths by having all files in the same directory and running in that directory - this seems a good way to simplify code and allow the final app to be installed anywhere without the need to change any paths in the code or elsewhere. Perhaps I'm trying to follow the KISS principle too closely!

Thanks Again,

Roger L

Rate this thread
WoltLab Burning Board