pyreportjasper
pyreportjasper copied to clipboard
Error in generating pdf using json data
hi, i just install the pyreportjasper using pip and installed java SE 11
i try to run the sample json code with Blank_A4.jrxml in reports folder
the code i tried is
import os
from pyreportjasper import PyReportJasper
def json_to_pdf():
RESOURCES_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'resources')
REPORTS_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'reports')
input_file = os.path.join(REPORTS_DIR, 'Blank_A4.jrxml')
output_file = os.path.join(REPORTS_DIR, 'json')
conn = {
'driver': 'json',
'data_file': os.path.join(RESOURCES_DIR, 'generated.json'),
'json_query': 'contacts.person'
}
pyreportjasper = PyReportJasper()
pyreportjasper.config(
input_file,
output_file,
output_formats=["pdf"],
db_connection=conn
)
pyreportjasper.process_report()
print('Result is the file below.')
print(output_file + '.pdf')
json_to_pdf()
on running using py checl.py it shows the following .
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console. Set system property 'org.apache.logging.log4j.simplelog.StatusLogger.level' to TRACE to show Log4j2 internal initialization logging. Result is the file below. G:\Sample Py\reports\json.pdf
i can get the blank pdf only. i can't able to figure out . guide me what is the problem
Apparently you are using an example of blank jrxml, as the file name says.
There are two ways to generate using json.
Example 1 and the most suitable. https://replit.com/@JadsonRibeiro/json-pyreportjasper
Example 2 if your json is very large and you need to increase the maximum memory that the jvm can use to process your file https://replit.com/@JadsonRibeiro/jvmmax-mem-pyreportjasper#main.py
i have tried the example in replit it shows the error as
Traceback (most recent call last):
File "main.py", line 2, in
and also i copied all the files and i try in my own system it shows the following error
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console. Set system property 'org.apache.logging.log4j.simplelog.StatusLogger.level' to TRACE to show Log4j2 internal initialization logging.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by br.com.acesseonline.classpath.ApplicationClasspath (file:/C:/Users/laptopms/AppData/Local/Programs/Python/Python39/Lib/site-packages/pyreportjasper/libs/acesseonline-1.0.jar) to method java.net.URLClassLoader.addURL(java.net.URL)
WARNING: Please consider reporting this to the maintainers of br.com.acesseonline.classpath.ApplicationClasspath
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Traceback (most recent call last):
File "G:\Sample Py\check.py", line 27, in
ur help is much appreciated
The specified error is stating that you do not have the library.
To check run pip freeze
and check if the library is in the output of the command and if it shows which version you are using?
The current version is pyreportjasper==2.1.2
thanks for ur reply. i run the command pip freeze and it shows in my system
asgiref==3.3.1 astroid==2.4.2 colorama==0.4.4 Django==2.1.15 django-pyodbc==1.1.3 django-pyodbc-azure==2.1.0.0 isort==5.6.4 JPype1==1.2.1 lazy-object-proxy==1.4.3 mccabe==0.6.1 pyaes==1.6.1 pyasn1==0.4.8 pylint==2.6.0 pyodbc==4.0.30 pyreportjasper==2.1.2 pytz==2020.4 rsa==4.6 six==1.15.0 sql-server.pyodbc==1.0 sqlparse==0.4.1 Telethon==1.17.5 toml==0.10.1 wrapt==1.12.1
still i am getting the error
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console. Set system property 'org.apache.logging.log4j.simplelog.StatusLogger.level' to TRACE to show Log4j2 internal initialization logging. WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by br.com.acesseonline.classpath.ApplicationClasspath (file:/C:/Users/laptopms/AppData/Local/Programs/Python/Python39/Lib/site-packages/pyreportjasper/libs/acesseonline-1.0.jar) to method java.net.URLClassLoader.addURL(java.net.URL) WARNING: Please consider reporting this to the maintainers of br.com.acesseonline.classpath.ApplicationClasspath WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release Traceback (most recent call last): File "G:\Sample Py\check.py", line 27, in json_to_pdf() File "G:\Sample Py\check.py", line 22, in json_to_pdf pyreportjasper.process_report() File "C:\Users\laptopms\AppData\Local\Programs\Python\Python39\lib\site-packages\pyreportjasper\pyreportjasper.py", line 182, in process_report raise error NameError: Error fill report: Erro fill internal: net.sf.jasperreports.engine.JRException: Error loading expression class: json_1617165573005_332740.
sorry i am new to this python and java. can't figure out where is the problem. ur help is appreciated
If you can show the code you are trying to execute we can help you more effectively.
thanks for ur reponse. here the details of the code and platform i am running
Windows 10 Home, Python 3.9
regarding java version it shows java version "11.0.10" 2021-01-19 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.10+8-LTS-162) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.10+8-LTS-162, mixed mode)
on running pip freeze it shows asgiref==3.3.1 astroid==2.4.2 colorama==0.4.4 Django==2.1.15 django-pyodbc==1.1.3 django-pyodbc-azure==2.1.0.0 isort==5.6.4 JPype1==1.2.1 lazy-object-proxy==1.4.3 mccabe==0.6.1 pyaes==1.6.1 pyasn1==0.4.8 pylint==2.6.0 pyodbc==4.0.30 pyreportjasper==2.1.2 pytz==2020.4 rsa==4.6 six==1.15.0 sql-server.pyodbc==1.0 sqlparse==0.4.1 Telethon==1.17.5 toml==0.10.1 wrapt==1.12.1
i have attached the code which i run and it shows the same error that i mentioned in previous post Sample Py.zip
Remove the current installation and install via git to use a compiled version for your operating system and you will no longer have the problem.
pip install git+https://github.com/acesseonline/pyreportjasper@master#egg=pyreportjasper
thanks a lot. its works expected. but i have some delay in getting the pdf report around 20 sec for just 100 rows of data. is it normal.
Data source is in JSON, XML or database ?
json data
@jaganeee An example of this json could be made available to perform some tests?
Issue closed for lack of interaction.