Jasper Reports : Unable to upload jrxml file

Seems like java don’t find the driver to connect to mysql/mariadb. I add mysql driver connector, just to be sure, but i don’t think this will solve the problem. Don’t heart to try! So please update again!

The jar files needed to jasper work are in jasper_erpnext_report/java/lib/ folder. It has by default mariadb driver included, and this folder is added to classpath by jasper_erpnext_report on startup and before pyjnius start in jasper_erpnext_report/jasper_reports/__init__.py.

If this don’t work try to find out why it is not finding the java/lib folder. Set java CLASSPATH in ~/.bashrc or .bash_profile or other file.

Cherry report is prepared to work with User doctype because it will get username and email.

Let me know if this work!

Luis.

Hi @luisfmfernandes,
Jus bk after vacation. Will update jasper and confirm. It seems to have worked for itsdave!

Krithi

Hi @krithi_ramani.

Wellcome, happy new year!

Let me know if you can now make reports.

Luis.

You too Luis! :slight_smile:

Couple of issues:

  1. Earlier, when I created a report and tried to upload the jrxml, it did not allow me to. The report has been saved in the db, but not listed in the Jasper Reports list. So, after pulling your fix, I tried to create a new report with the same name, it says ‘Duplicate entry…’. So I went to the db and deleted the old entry. Now when I create a new report with the same name, it says ‘Import logo.png image for report COA first.’ Not sure why it is looking for this image file even before I save the form. The upload button is not visible yet(as I cudn’t save the form), so I can’t upload the image anyways.

  2. When I create a new report with a different name, I save it the first time and upload the jrxml file. Now, the ‘save’ button is not visible and if I say ‘Ctrl+S’ I get ‘No permission to ‘Save’ Jasper Reports’. I never changed any of the permissions after pulling your fix.

Appreciate your help!

Thanks
Krithi

@krithi_ramani i think your point 2. is the normal behaviour.

The uploaded files should be visible at the left side as attachments.

I think theres no need to press the save button again.

@luisfmfernandes thanks again, i will give it a try this evening.

@itsdave,
No, it isn’t. On uploading the jrxml and only after saving the form, will the query and the parameters get displayed.

If this is the case, then i`m for the same issue. Save button only works one time in my installation, too.

Hi,
i`ve updated and tested, and its still quite the same.

I`ve also set the CLASSPATH according to your sugestions in multiple files.

The thing that @krithi_ramani pointed out lead me to one detail: There is no connection string at the end of the error message: “JavaException: JVM exception occurred: No suitable driver found for”

So maybe its not the missing db driver but wrong syntax (or empty connection string)?

So i guess we are indeed missing a final save function which reads out the report parameters an maybe specifies the connection parameters?

.

Hi @itsdave.

In your case, some how, it is not finding mysql/mariadb driver. Has you can see in the case of krithi_ramani pyjnius find the driver. I set java to throws all the erros to python and if any occur i send it to javascript client.

Please check console/terminal output for printed CLASSPATH and see if /.../frappe-bench/apps/jasper_erpnext_report/jasper_erpnext_report/java/lib/* is there.

There is no need to set the CLASSPATH in multiples files, set only in one of them.

@krithi_ramani, i test it with Cherry report (I made a new one) and everything is ok and i can generate the report too. Please try also with Cherry.jrxml to see where is the error and also update to have java errors reports to client.

Thanks,
Luis.

Hey Luis,

I understand what you are saying, and i know that the CLASSPATH has to be set only once. But as i have learned from this discussion…

…i had to export it the init script of supervisor too. I just wanted to say that i exported it in all known files to make sure that is has be available for frappe.

Im logging in as the frappe user, doing “env”

CLASSPATH=/home/frappe/frappe-bench/apps/jasper_erpnext_report/jasper_erpnext_report/java/lib

in this folder are serveral .jar files like

mariadb-java-client-1.1.8.jar
or
mysql-connector-java-5.1.38-bin.jar

I do the bench start from this session and i get the the same exeption again.

So i do think that the classpath should be OK in this case?

@krithi_ramani did you even try to generate one report despite not beeing able to save it after the upload of a file? It should appear in the according doctype even if not saved a second time. Maybe you would get this error too?

Luis, as @krithi_ramani an myself cant press the save button again after uploading a report-file, and this seems to be neccessary i wanted to point out that there can be at least two reasons for this Java-Exeption:

  1. CLASSPATH or .jar missing/wrong

  2. Wrong/missing connection String:
    I guess Java doesnt even know which connector to use, because there is no connection string displayed in this exeption.
    It it could not find the mysql-connecter, it should be more like:

    no suitable driver found for jdbc:mysql://localhost:3306/mysql.
    instead of just like

    no suitable driver found for

I guess this is the case because of the save function after uploading a file cant be called because of the missing button. (krithis point no. 2)

There must be still some problem:

-create a new report
-press the save button
-upload cherry.jrxml and the other report files

Here ist the problem:

-report shows as unsaved in the upper left corner
-save button is not displayed
-Ctrl+S leads to permission error
-Query Field is just an empty yellow area, other fileds also empty
-report is in tabJasperReports and can be selected in the according doctype for printing, but throws exeption.
-report is not shown in the Jasper Reports, and so it cant be edited after you leave it once
-if you try to create a new report with the same name you get a duplicate-entry error.

I suspect that there is still some function which has to be executed, before the report is even able to work? Is it possible that there is still a permisson missing or something that you might not have seen in your last fix? Shouldnt i be able to save after i uploaded some files to a report?

I guess, Im in a similiar situation like krithi_ramani…

If it helps to troubleshoot the issue and you would like to take the time, i could provide you a fresh install of Debian Jessie with this setup and ssh access to it.

Please tell me, if can help somehow to get it working or if you have some ideas left for troubleshooting

Thanks, David

Should be: /* at the end.

CLASSPATH=/home/frappe/frappe-bench/apps/jasper_erpnext_report/jasper_erpnext_report/java/lib/*

But i will see what maybe wrong. With me everything is ok, but as i said i will check.

Note: When you upload a jrxml file as in your case jasper is called to compile the .jrxml file to .jasper, but in your case, because java don’t find the driver jasper don’t compile and you don’t get the save button enabled.
So please check in folder frappe-bench/sites/name of your site/jasper/name of report/compiled/ for the name of your report.jasper file. If do not have .jasper file or compiled folder then you must find out what is wrong with CLASSPATH… I need more info to find the error. Put some prints all the way to generate the report. Let me know if you want that i tell you where to put them.

Frappe team have been made some change and i have been adapt my jasper to that. Maybe i miss some thing.

Also update jasper again, because i think you don’t have the trace error feature. When i removed mariadb client driver i get the error and you should get in client this:

Error in report Cherry Local, error is: Traceback (innermost last):
File "/Users/saguas/erpnext4/erpnext/frappe_v5/frappe-bench/apps/jasper_erpnext_report/jasper_erpnext_report/core/JasperLocal.py", line 35, in run_local_report_async
cresp = self.prepare_report_async(path, doc, data=data, params=params, pformat=pformat, ncopies=ncopies, for_all_sites=for_all_sites)
File "/Users/saguas/erpnext4/erpnext/frappe_v5/frappe-bench/apps/jasper_erpnext_report/jasper_erpnext_report/core/JasperBase.py", line 398, in prepare_report_async
resps.append(self._run_report_async(path, doc, data=data, params=params, pformat=pformat, ncopies=ncopies, for_all_sites=for_all_sites))
File "/Users/saguas/erpnext4/erpnext/frappe_v5/frappe-bench/apps/jasper_erpnext_report/jasper_erpnext_report/core/JasperLocal.py", line 127, in _run_report_async
self._export_report(mparams, data.get("report_name"), data.get("grid_data"), frappe.local.batch.sessionId, cur_doctype, custom, ids, frappe.local.fds)
File "/Users/saguas/erpnext4/erpnext/frappe_v5/frappe-bench/apps/jasper_erpnext_report/jasper_erpnext_report/core/JasperLocal.py", line 151, in _export_report
frappe.local.batch.batchReport.addToBatch(mparams, data, cols, fds)
File "jnius_export_class.pxi", line 638, in jnius.JavaMethod.__call__ (jnius/jnius.c:22773)
File "jnius_export_class.pxi", line 732, in jnius.JavaMethod.call_method (jnius/jnius.c:23857)
File "jnius_utils.pxi", line 93, in jnius.check_exception (jnius/jnius.c:4427)
JavaException: JVM exception occurred: org.mariadb.jdbc.Driver

And yes you do not have a connection string because your .jrxml file do not compile. One condition to have connection string is to have query string. If do not compile do not save then you don’t have connection string.

Thanks.

Hi @krithi_ramani.

If you still get the same error after test with Cherry.jrxml, see if you have the report compiled in frappe-bench/sites/name of your site/jasper/name of report/compiled/ with .jasper extension.

Thanks,
Luis.

Hi @luisfmfernandes,
Am held up with a different issue. please give me some time to get back to you on this.

Thanks
Krithi

You are right, i missed “/*”.

Now my variable looks like:

CLASSPATH=/home/frappe/frappe-bench/apps/jasper_erpnext_report/jasper_erpnext_report/java/lib/*

No change.

I allready have the (btw very usefull) feature with the trace error display.

The error is simmilar to the error which was displayed at console level before:

Error in report Cherry_Test, error is: Traceback (innermost last):
File "/home/frappe/frappe-bench/apps/jasper_erpnext_report/jasper_erpnext_report/core/JasperLocal.py", line 35, in run_local_report_async
cresp = self.prepare_report_async(path, doc, data=data, params=params, pformat=pformat, ncopies=ncopies, for_all_sites=for_all_sites)
File "/home/frappe/frappe-bench/apps/jasper_erpnext_report/jasper_erpnext_report/core/JasperBase.py", line 398, in prepare_report_async
resps.append(self._run_report_async(path, doc, data=data, params=params, pformat=pformat, ncopies=ncopies, for_all_sites=for_all_sites))
File "/home/frappe/frappe-bench/apps/jasper_erpnext_report/jasper_erpnext_report/core/JasperLocal.py", line 127, in _run_report_async
self._export_report(mparams, data.get("report_name"), data.get("grid_data"), frappe.local.batch.sessionId, cur_doctype, custom, ids, frappe.local.fds)
File "/home/frappe/frappe-bench/apps/jasper_erpnext_report/jasper_erpnext_report/core/JasperLocal.py", line 151, in _export_report
frappe.local.batch.batchReport.addToBatch(mparams, data, cols, fds)
File "jnius/jnius_export_class.pxi", line 638, in jnius.JavaMethod.__call__ (jnius/jnius.c:24923)
File "jnius/jnius_export_class.pxi", line 732, in jnius.JavaMethod.call_method (jnius/jnius.c:26111)
File "jnius/jnius_utils.pxi", line 93, in jnius.check_exception (jnius/jnius.c:4584)
JavaException: JVM exception occurred: No suitable driver found for

As i wrote some days before: The report seems to compiled correctly. At least i have the .jasper file in this folder after upload. Its about 32kb of size.

What do you mean by “Put some prints” Sourcecode prints? Then it would be realy nice if you cound tell me the files and maybe positions where to put them.

Hi @luisfmfernandes,
Yes, I tried to add Cherry.jrxml and I could also see the compiled Cherry.jasper file in the mentioned folder. I get the following error in js console upon saving the page for the first time.

Uncaught TypeError: Cannot read property ‘clear_input’ of undefined

On uploading the file and saving(no save button here, saved as Ctrl+S) it again, I still get ‘No permission to ‘Save’ Jasper Reports’

Thanks
Krithi

@itsdave,@luisfmfernandes,

Solved! I unchecked ‘Apply User Permissions’ for the role in Role permissions manager. I could now save and assign parameters.

Thanks
Krithi

1 Like

Great! I can confirm that this works for beeing able to save changes to the report.

Just to mention it for someone who runs also into it:

Afterward i ran into the exeption when generating a report: Font ‘Times New Roman’ is not available to the JVM althoug i have installed mscorefonts on my system.

I was able to fix it by adding:

filename.Times_New_Roman=/usr/share/fonts/truetype/msttcorefonts/Times_New_Roman.ttf

to $JAVA_HOME/jre/lib/fontconfig.properties

Now the System shows:

Your report is ready to download. Click to download

But when i try to download the following error occurs:

Traceback (innermost last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/website/render.py", line 25, in render
    data = render_page_by_language(path)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/website/render.py", line 91, in render_page_by_language
    return render_page(path)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/website/render.py", line 113, in render_page
    return build(path)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/website/render.py", line 122, in build
    return build_method(path)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/website/render.py", line 138, in build_page
    context = get_context(path)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/website/context.py", line 31, in get_context
    context = build_context(context)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/website/context.py", line 94, in build_context
    context.data = build_template(context)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/website/template.py", line 18, in build_template
    render_blocks(context["template"], out, context)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/website/template.py", line 47, in render_blocks
    render_blocks(referenced_template_path, out, context)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/website/template.py", line 44, in render_blocks
    source = frappe.local.jloader.get_source(frappe.local.jenv, template_path)[0]
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/jinja2/loaders.py", line 399, in get_source
    raise TemplateNotFound(template)
 TemplateNotFound: templates/web.html

@krithi_ramani did you try to generate a Cherry report?

@itsdave: You have to update frappe to the latest version. To show the pdf Report jasper_erpnext extends templates/web.html as frappe now support.

No @itsdave, I never tried Cherry.

@luisfmfernandes, I still have this problem of ‘Report already exists’ error. Once a report is created with a particular name and deleted, and if I try to create a new report with the old name, it says - ‘Report already exists’…There is no entry in the db either. Where else should the old report be deleted from?

@krithi_ramani. The problem is not with jasper. You delete a frappe doc (in this case a jasper report) direct in database.

So, please ask to frappe team, because i don’t know all the relational tables that was created with doc or metadata.

If you delete in normal way then you can create another report with the same name.

Thanks,
Luis.