I try to generate report with pyreportjasper. With jaspersoft studio no problem, report is good. But when i try this code I have this error:
init: Bootstrapping class not in BootstrapTypesSingleton.getInstance()[class=class org.python.core.PyStringMap]
Traceback (most recent call last):
File "test.py", line 26, in <module>
PyReportJasper.process_report()
File "/usr/local/lib/python3.8/dist-packages/pyreportjasper/pyreportjasper.py", line 182, in process_report
raise error
NameError: Error fill report: Erro fill internal: java.lang.NullPointerException
install version is :
java -version
openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.20.04)
OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing)
java -version
openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.20.04)
OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing)
python --version
Python 3.8.5
And pyreportjasper is 2.1.2. My code is :
from pyreportjasper import PyReportJasper
REPORTS_DIR = "/home/carto/reports/DW/"
input_file= REPORTS_DIR + "test.jrxml"
output_file="/home/carto/reports/DW/" + "S257E"
conn = {
'driver': 'postgres',
'username': 'postgres',
'password': 'pass',
'host': 'localhost',
'database': 'db1',
'schema': 'export',
'port': '5432'
}
PyReportJasper= PyReportJasper()
PyReportJasper.config (input_file,output_file,output_formats=["pdf"],parameters={'python_version': '1'},db_connection=conn,locale='fr-FR')
PyReportJasper.process_report()
Error is in db.py of the PyReportJasper but I don't understand... but config.dbDriver is null. why ?
elif dbtype == "postgres":
driver = config.dbDriver
port = config.dbPort or 5434
dbname = config.dbName
connect_string = "jdbc:postgresql://{}:{}/{}".format(host, port, dbname)
elif dbtype == "oracle":
driver = config.dbDriver
port = config.dbPort or 1521
sid = config.dbSid
connect_string = "jdbc:oracle:thin:@{}:{}:{}".format(host, port, sid)
elif dbtype == "generic":
driver = config.dbDriver
connect_string = config.dbUrl
self.Class.forName(driver)
to use driver you need add the jdbc_driver parameters than :
conn = {
'driver': 'postgres',
'username': 'postgres',
'password': 'pass',
'host': 'localhost',
'database': 'db1',
'schema': 'export',
'port': '5432'
'jdbc_driver' : 'org.postgresql.Driver'
}