Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Nenadst023 opened this issue Mar 5, 2023 · 5 comments
Labels
closing-soon investigating This issue is being investigated and/or work is in progress to resolve the issue. question

Comments

@Nenadst023
Copy link

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
Copy link
Collaborator

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
Copy link

roomm commented Feb 14, 2024

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
Copy link

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

@jadsonbr jadsonbr added the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Feb 14, 2024
@Zyten
Copy link

Zyten commented Apr 1, 2024

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
Copy link
Collaborator

Unsupported Java version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closing-soon investigating This issue is being investigated and/or work is in progress to resolve the issue. question
Projects
None yet
Development

No branches or pull requests

5 participants