agmoyano / node-jasper

JasperReports from Node.js
84 stars 52 forks source link

Error: Could not create class net.sf.jasperreports.engine.JREmptyDataSource #45

Closed codingmikesh closed 5 years ago

codingmikesh commented 5 years ago

Hi, I get an error on using this script :

var express = require('express'), app = express(), jasper = require('node-jasper')({ path: 'reports', reports: { hw: { jasper: 'vehicles.jasper', jrxml: 'vehicles.jrxml', conn: 'in_memory_json' } } }); app.get('/pdf', function(req, res, next) { //beware of the datatype of your parameter. var report = { report: 'hw', data:{}, dataset: _data }; var pdf = jasper.pdf(report); res.set({ 'Content-type': 'application/pdf', 'Content-Length': pdf.length }); res.send(pdf); });

H:\jasper\node_modules\node-jasper\node_modules\java\lib\nodeJavaBridge.js:227 var clazz = java.findClassSync(name); // TODO: change to Class.forName when classloader issue is resolved. ^ Error: Could not create class net.sf.jasperreports.engine.JREmptyDataSource java.lang.NoClassDefFoundError: net/sf/jasperreports/engine/JREmptyDataSource Caused by: java.lang.ClassNotFoundException: net.sf.jasperreports.engine.JREmptyDataSource at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

at Java.java.import (H:\jasper\node_modules\node-jasper\node_modules\java\lib\nodeJavaBridge.js:227:20)
at Array.async.auto.imports (H:\jasper\node_modules\node-jasper\index.js:176:28)
at listener (H:\jasper\node_modules\async\lib\async.js:490:46)
at H:\jasper\node_modules\async\lib\async.js:441:17
at _each (H:\jasper\node_modules\async\lib\async.js:46:13)
at Immediate.taskComplete (H:\jasper\node_modules\async\lib\async.js:440:13)
at runCallback (timers.js:705:18)
at tryOnImmediate (timers.js:676:5)
at processImmediate (timers.js:658:5)

What can I do ? Thanks

edifortcarlos commented 5 years ago

Hello, i am facing the same issue, can you help @agmoyano ?

agmoyano commented 5 years ago

Hi, it seems it cannot find the path to jasper reports project..

It's where the untarred jasperreports-x.x.x-project.tar.gz should be.

The error says that it cannot find the definition of net.sf.jasperreports.engine.JREmptyDataSource, and that's defined in jasperreports project.

Hope it helps

edifortcarlos commented 5 years ago

Thanks for the prompt response @agmoyano, was very helpfull.

In my case i did not was using the the entire jasperreport_project package, instead i was using only the jasperreport jar.

The node-jasper look for all dependences placed in lib and dist folder inside of jasperreport_project main directory, and if one of those is missing, it will trigger the error.

Problem solved, i think thes issue can be closed.

agmoyano commented 5 years ago

Great!

najaroen commented 4 years ago

Hi, how can i see structure project . i get same issue

agmoyano commented 4 years ago

Hi @najaroen, could you please elaborate a little more?.. what do you mean exactly with structure project?

Do you mean the Jasper report project tar.gz file?

najaroen commented 4 years ago

@agmoyano yes

agmoyano commented 4 years ago

@najaroen here you can download Jasper Reports project.

https://sourceforge.net/projects/jasperreports/files/jasperreports/JasperReports%206.11.0/

Remember to download the one named like this "jasperreports-x.x.x-project.tar.gz" or "jasperreports-x.x.x-project.zip"

Once you decompress it, point the path to it.

Hope it helps!

DanielAcosta2395 commented 4 years ago

Hello @agmoyano, i have a simple question, it may be silly, this package only works on linux dist?

CristianAlvarado82 commented 4 years ago

Hi, i have this same problem and don't know resolve, need helpfull step by step please, have in to the proyect nodejs the proyect /lib/jasperreports-6.15.0/lib and dist but dont start proyect, sorry for the english