Java Agent and Jasper Reports

Have developed a Java Agent that uses a class within a shared .JAR library which in turn attempts to load, run a compiled JasperReport (.jasper) file. The output is to be exported as a .PDF file. I am able to activate the report which attaches to a remote Oracle database, runs a query and starts filling the report.

However, as the fill begins the JRProperties class attempts to load ‘default.jasperreports.properties’ from the classpath. After copying the file to numerous locations that I know to be on the classpath and ensuring that the java.policy file has what I think to be the correct read permissions to directories and .JAR file that contains this property file a JRException indicatingt that the “default property file could not be found” is raised.

I have read through the source for JasperReports v.1.3.4 and have traced the exception to it trying to load an inputstream from “/default.jasperreports.properties” .

I am guessing that it will have somthing to do with a mix of file permissions and classloading with Domino but I am at a loss as to what to do to solve this after making numerous attempts and finding nothing specific on the net that would help.

Please, any assistance would be appreciated as this is the final leg to a project I would like to get finished.

Kind Regards, Bruce

Subject: Java Agent and Jasper Reports

Bruce -The forward slash in “/default.jasperreports.properties” effectively points to the root directory of the current drive. In a Notes agent, the current directory at runtime should be your Notes program directory. So, for example, since my program files are installed to c:\notes, if I place a dummy version of the file on the root of my c drive, I can load and print out the properties file as follows:

import lotus.domino.*;

import java.util.Properties;

import java.io.*;

public class JavaAgent extends AgentBase {

public void NotesMain() {

try {

Properties aprops = new Properties();

FileInputStream fis = new FileInputStream(new File(“/default.jasperreports.properties”));

aprops.load(fis);

System.out.println("PROPERTIES → " + aprops);

fis.close();

} catch(Exception e) {

e.printStackTrace();

}

}

}

Does that help?

dgg

Subject: RE: Java Agent and Jasper Reports

Thanks Dallas

I had noticed the slash and also considered what you were suggesting but wasn’t sure if I had tested it and even now am not sure if I have tested it “CORRECTLY”. But to be sure I tried again and the same issue presents itself. So I have included the java dump: -

30/08/2007 12:51:35 PM AMgr: Agent (‘Reporter’ in ‘Clients\Lago\QueryRequests.nsf’) error message: java.lang.ExceptionInInitializerError

30/08/2007 12:51:35 PM AMgr: Agent (‘Reporter’ in ‘Clients\Lago\QueryRequests.nsf’) error message: at net.sf.jasperreports.engine.util.JRQueryExecuterUtils.getQueryExecuterFactory(JRQueryExecuterUtils.java:53)

30/08/2007 12:51:35 PM AMgr: Agent (‘Reporter’ in ‘Clients\Lago\QueryRequests.nsf’) error message: at net.sf.jasperreports.engine.fill.JRFillDataset.createQueryDatasource(JRFillDataset.java:678)

30/08/2007 12:51:35 PM AMgr: Agent (‘Reporter’ in ‘Clients\Lago\QueryRequests.nsf’) error message: at net.sf.jasperreports.engine.fill.JRFillDataset.initDatasource(JRFillDataset.java:614)

30/08/2007 12:51:35 PM AMgr: Agent (‘Reporter’ in ‘Clients\Lago\QueryRequests.nsf’) error message: at net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:892)

30/08/2007 12:51:35 PM AMgr: Agent (‘Reporter’ in ‘Clients\Lago\QueryRequests.nsf’) error message: at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:716)

30/08/2007 12:51:35 PM AMgr: Agent (‘Reporter’ in ‘Clients\Lago\QueryRequests.nsf’) error message: at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:669)

30/08/2007 12:51:35 PM AMgr: Agent (‘Reporter’ in ‘Clients\Lago\QueryRequests.nsf’) error message: at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:63)

30/08/2007 12:51:35 PM AMgr: Agent (‘Reporter’ in ‘Clients\Lago\QueryRequests.nsf’) error message: at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:402)

30/08/2007 12:51:35 PM AMgr: Agent (‘Reporter’ in ‘Clients\Lago\QueryRequests.nsf’) error message: at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:363)

30/08/2007 12:51:35 PM AMgr: Agent (‘Reporter’ in ‘Clients\Lago\QueryRequests.nsf’) error message: at au.com.lago.wms.reports.JasperReportEngine.run(JasperReportEngine.java:74)

30/08/2007 12:51:35 PM AMgr: Agent (‘Reporter’ in ‘Clients\Lago\QueryRequests.nsf’) error message: at au.com.lago.wms.reports.Requestor.run(Requestor.java:82)

30/08/2007 12:51:35 PM AMgr: Agent (‘Reporter’ in ‘Clients\Lago\QueryRequests.nsf’) error message: at au.com.lago.wms.reports.AgentHelper.doFormatted(AgentHelper.java:629)

30/08/2007 12:51:35 PM AMgr: Agent (‘Reporter’ in ‘Clients\Lago\QueryRequests.nsf’) error message: at JavaAgent.NotesMain(JavaAgent.java:10)

30/08/2007 12:51:35 PM AMgr: Agent (‘Reporter’ in ‘Clients\Lago\QueryRequests.nsf’) error message: at lotus.domino.AgentBase.runNotes(Unknown Source)

30/08/2007 12:51:35 PM AMgr: Agent (‘Reporter’ in ‘Clients\Lago\QueryRequests.nsf’) error message: at lotus.domino.NotesThread.run(Unknown Source)

30/08/2007 12:51:35 PM AMgr: Agent (‘Reporter’ in ‘Clients\Lago\QueryRequests.nsf’) error message: Caused by: net.sf.jasperreports.engine.JRRuntimeException: Error loading the properties

30/08/2007 12:51:35 PM AMgr: Agent (‘Reporter’ in ‘Clients\Lago\QueryRequests.nsf’) error message: at net.sf.jasperreports.engine.util.JRProperties.initProperties(JRProperties.java:189)

30/08/2007 12:51:35 PM AMgr: Agent (‘Reporter’ in ‘Clients\Lago\QueryRequests.nsf’) error message: at net.sf.jasperreports.engine.util.JRProperties.(JRProperties.java:156)

30/08/2007 12:51:35 PM AMgr: Agent (‘Reporter’ in ‘Clients\Lago\QueryRequests.nsf’) error message: … 15 more

30/08/2007 12:51:35 PM AMgr: Agent (‘Reporter’ in ‘Clients\Lago\QueryRequests.nsf’) error message: Caused by: net.sf.jasperreports.engine.JRException: Default properties file not found.

30/08/2007 12:51:35 PM AMgr: Agent (‘Reporter’ in ‘Clients\Lago\QueryRequests.nsf’) error message: at net.sf.jasperreports.engine.util.JRProperties.getDefaults(JRProperties.java:216)

30/08/2007 12:51:35 PM AMgr: Agent (‘Reporter’ in ‘Clients\Lago\QueryRequests.nsf’) error message: at net.sf.jasperreports.engine.util.JRProperties.initProperties(JRProperties.java:166)

30/08/2007 12:51:35 PM AMgr: Agent (‘Reporter’ in ‘Clients\Lago\QueryRequests.nsf’) error message: … 16 more

Don’t ask me where the “… 16 more” is because I can’t find it. Additionally, the properties file is in the ROOT also of the Server C: drive as like yourself Domino is installed into C:\NOTES

However, here is the point that I am not sure about but I don’t think should make any difference unless there is some strange caching going on.

I am of the belief that if I do a “TELL AMGR QUIT” followed by a “LOAD AMGR” I can force a reload of the JVM that the Agent Manager would use and therefore affectively start again without having to cycle the whole Domino Server.

In anycase, I still get the DUMP as above and am no closer to solving this annoying issue which is starting to really frustrate me.

So unfortunatley no solution as yet.

Thank-you for your advice it certainly gave me some warmth in knowing I’m on the same path as others like yourself.

Kind Regards, Bruce

Subject: RE: Java Agent and Jasper Reports

Have you had any success with this?

Subject: RESOLVED: Java Agent and Jasper Reports

The resolution or rather workaround that I am prepared to live with for the moment is that I extracted the complete class library structure out to a specific directory local to the Domino Server but not the jvm\lib\ext directory (although I believe this would also be ok).

I then adjusted the jvm policy file to permit all permissions on this new directory and its child directories.

Additionally I included this path as an element in the JavaUserClasses element in the notes.ini file of the server.

I restarted the entire server rather than jsut bouncing the Agent manager task.

This seemed to do the trick as it appears to have sync’ed up the class loaders with the security permissions required by the Domino sandbox.

Additionally, although also a workaround at this stage. I made a seperate directory and directed the output from jasperReports to this directory as PDFs (as was my requirement) then again adjusted the policy file to include this directory again with all permissions. For completeness I cycled the domino server again.

There are possibly some othr minor adjustments made that I have neglected to remember but these instructions will still be close to the mark.

Obviously replication etc are not supported with this workaround but desperate times sometimes mean desperate measures and when time permits I will continue to refine this technique.