acesseonline / pyreportjasper

Python Reporting with JasperReports
https://pyreportjasper.readthedocs.io/en/latest/
GNU General Public License v3.0
125 stars 68 forks source link

ERROR: java.io.IOException: Error, could not add URL to system classloader! #142

Open Nenadst023 opened 1 year ago

Nenadst023 commented 1 year ago

Hi,

I have same problem. My code..

import os
from pyreportjasper import PyReportJasper

os.environ["JAVA_HOME"] ="jvm/jdk-19.0.2/"

def advanced_example_using_database():
   REPORTS_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'jrxml')
   input_file = os.path.join(REPORTS_DIR, 'stampaCenaA4.jrxml')
   output_file = os.path.join(REPORTS_DIR, 'stampaCenaA4')

   conn = {
     'driver': 'oracle',
     'username': '***',
     'password': '***',
     'host': '***',
     'port': '1521',
     'db_sid': '***',
     'jdbc_dir': 'x:\\nenad_ws\\-- PY RAZVOJ\\StampaCena\\oracle\\',
     'jdbc_driver': 'oracle.jdbc.driver.OracleDriver'
   }

   pyreportjasper = PyReportJasper()
   pyreportjasper.config(
     input_file,
     output_file,
     db_connection=conn,
     output_formats=["pdf"],
     parameters={'poj': '114', 'pbarkod':'8600043003444,8605006902987,7622210702593,9012200872739,3080216031811'},
     resource="x:\\nenad_ws\\-- PY RAZVOJ\\StampaCena\\oracle",
     locale='en_US'
   )
   pyreportjasper.process_report()

advanced_example_using_database()

Output: NameError: Error fill report: It was not possible to add the path x:\nenad_ws-- PY RAZVOJ\StampaCena\oracle\ to the Class Path: ERROR: java.io.IOException: Error, could not add URL to system classloader!

Project path.. image

Python ver: 3.10.7 Lib installed with pip3 install git+https://github.com/acesseonline/pyreportjasper.git - Version: 2.1.2 Java: open jdk-19.0.2 Jvm: Oracle OS: windows 11

Jaspersoft Studio: 6.20.0

jadsonbr commented 6 months ago

On Windows, we need to handle spaces in the path or try to provide a directory without spaces. If there are spaces, inform it like this: C:\"My Folder"\project. Please check this and try again, then let us know the outcome.

roomm commented 4 months ago

Same here with ubuntu :

def processing():
    input_file = os.path.join(REPORTS_DIR, 'Blank_A4_1.jrxml')
    output_file = os.path.join(REPORTS_DIR, 'csv')

    conn = {
        'driver': 'json',
        'data_file': os.path.join(RESOURCES_DIR, 'resources/restaurants.json'),
        'json_query': 'restaurants'
    }
    pyreportjasper = PyReportJasper()
    pyreportjasper.config(
        input_file,
        output_file,
        output_formats=["pdf"],
        db_connection=conn,
        resource="/home/roman/JaspersoftWorkspace/restaurant_card/resources/libs/"

    )
    # pyreportjasper.list_report_params()
    pyreportjasper.process_report()
    print('Result is the file below.')
    print(output_file + '.pdf')

Output:

NameError: Error fill report: It was not possible to add the path /home/roman/JaspersoftWorkspace/restaurant_card/resources/libs/ to the Class Path: ERROR: java.io.IOException: Error, could not add URL to system classloader!

Python ver: 3.10.12 pyreportjasper: 2.1.3 Java: open jdk-18.0.2 OS: Ubuntu 22.04

robsonmarcelino commented 4 months ago

I have a same error:

NameError: Error fill report: It was not possible to add the path /home/evol/jasperreports/app/report_evol/reports/adapters to the Class Path: ERROR: java.io.IOException: Error, could not add URL to system classloader!

Python ver: 3.9 pyreportjasper: 2.1.3 Java: openjdk21 OS: FreeBSD 14.0-RELEASE

Zyten commented 3 months ago

Happens to me with the image example.

Placed logo-pyreportjasper.png, main.py and with_image.jrxml in a fresh env, installed pyreportjasper (master) then ran python3 main.py

Output:

OpenJDK 64-Bit Server VM warning: Archived non-system classes are disabled because the java.system.class.loader property is specified (value = "org.update4j.DynamicClassLoader"). To use archived non-system classes, this property must not be set
Traceback (most recent call last):
  File "/workspace/development/test-pyreportjasper-images/main.py", line 23, in <module>
    contains_image()
  File "/workspace/development/test-pyreportjasper-images/main.py", line 18, in contains_image
    pyreportjasper.process_report()
  File "/home/frappe/.pyenv/versions/3.11.6/lib/python3.11/site-packages/pyreportjasper/pyreportjasper.py", line 169, in process_report
    raise error
NameError: Error fill report: It was not possible to add the path /workspace/development/test-pyreportjasper-images to the Class Path: ERROR: java.io.IOException: Error, could not add URL to system classloader!

Versions:

pyreportjasper @ git+https://github.com/acesseonline/pyreportjasper@3082ff5a0e5d9e730b689c4e06c9948d33ddfc3e

openjdk version "17.0.10" 2024-01-16
OpenJDK Runtime Environment (build 17.0.10+7-Debian-1deb12u1)
OpenJDK 64-Bit Server VM (build 17.0.10+7-Debian-1deb12u1, mixed mode, sharing)

Python 3.11.6

Debian GNU/Linux 12 (bookworm)
jadsonbr commented 2 months ago

Unsupported Java version.