I'm having a horrible problem and worst of all is that on the web I find almost nothing about this! I'm doing a report in java with jaspersoft studio. I made the template already (it has two parameters) and followed the guide of the following page .
Ok, my code is this:
public class Reportes{
private Administrador admin;
public Reportes() throws ClassNotFoundException, SQLException{
admin = new Administrador();
}
public JRViewer obtenerPaciente(String ced) throws JRException{
HashMap parameters = new HashMap();
InputStream is = getClass().getResourceAsStream("assets/PerfilPaciente.jrxml");
JRDesignQuery design = new JRDesignQuery();
design.setText("SELECT * FROM Pacientes");
JasperDesign jd = JRXmlLoader.load(is);
jd.setQuery(design);
parameters.put("Imagen", ClassLoader.getSystemResource("assets/perfil-azul.png").getPath());
parameters.put("Cedula",ced);
JasperReport report = JasperCompileManager.compileReport(jd);
JasperPrint jp = JasperFillManager.fillReport(report, parameters, admin.obtenerConexion());
JRViewer jrv = new JRViewer(jp);
return jrv;
}
}
And when I call this function in my JDialog, I get the following error:
net.sf.jasperreports.engine.JRException: java.net.MalformedURLException at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML (JRXmlLoader.java:251) at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML (JRXmlLoader.java:230) at net.sf.jasperreports.engine.xml.JRXmlLoader.load (JRXmlLoader.java:218)
The following line of code marks me:
InputStream is = getClass (). getResourceAsStream ("assets / Patient Profile.jrxml");
I tried to put it "/ProfilePatient.jrml", "ProfilePatient.jrxml" and nothing. Nor because it is in the project folder.
How could I solve this?
PS: My resources I put everything inside a folder of the project that creates called "assets", from there some images of my program in java come out also, and it has not given me problems like this file jrxml.