0

Yes, before you mark this question as "possible duplicate of", please, I actualy tried diferent solutions of the list below:

  1. Set compability mode like this question. enter image description here

  2. Use the latest version of Jasper Report (Im using the 6.3.1 version).

  3. Here someone says "you need to add the latest version of JR Libary", maybe I need more jar files in my project...

My project already have this jar files

[enter image description here]

What netbeans says when I call the report?

net.sf.jasperreports.engine.JRException: org.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 441; cvc-complex-type.3.2.2: Attribute 'uuid' is not allowed to appear in element 'jasperReport'. at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:247) at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:230) at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source) at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:218)

This is how I call the report now from JAVA:

public class Reportes{
private Administrador admin;

public Reportes() throws ClassNotFoundException, SQLException{
    admin = new Administrador();
}

public JRViewer obtenerPaciente(String ced) throws JRException, FileNotFoundException{
    HashMap parameters = new HashMap();
    InputStream is = new FileInputStream("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;
}
}

Where I call it

bbusca.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if(txtbusc.getText().length() != 0){
                try {
                    reporte.obtenerPaciente(txtbusc.getText()).setVisible(true);
                } catch (JRException | FileNotFoundException ex) {
                    Logger.getLogger(BuscarPaciente.class.getName()).log(Level.SEVERE, null, ex);
                }
            }else{
                JOptionPane.showMessageDialog(null, "No has ingresado nada.");
            }
        }
    });

I dont know if is necesary put the jrxml code here

    <?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.3.1.final using JasperReports Library version 4.5.0  -->
<!-- 2016-11-01T19:34:20 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="PerfilPaciente" pageWidth="612" pageHeight="792" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
    <property name="com.jaspersoft.studio.data.sql.tables" value=""/>
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="HospitalAccess"/>
    <parameter name="Cedula" class="java.lang.String">
        <parameterDescription><![CDATA[Cedula del paciente]]></parameterDescription>
        <defaultValueExpression><![CDATA[$P{Cedula}]]></defaultValueExpression>
    </parameter>
    <parameter name="Imagen" class="java.lang.String">
        <parameterDescription><![CDATA[Icono del reporte]]></parameterDescription>
        <defaultValueExpression><![CDATA[$P{Imagen}]]></defaultValueExpression>
    </parameter>
    <queryString language="SQL">
        <![CDATA[SELECT * FROM Pacientes WHERE Cedula=$P{Cedula}]]>
    </queryString>
    <field name="Nombre" class="java.lang.String">
        <fieldDescription><![CDATA[]]></fieldDescription>
    </field>
    <field name="Apellido" class="java.lang.String"/>
    <field name="Fecha_Nacimiento" class="java.lang.String"/>
    <field name="Cedula" class="java.lang.String"/>
    <field name="Sexo" class="java.lang.String"/>
    <field name="Tipo_Sangre" class="java.lang.String"/>
    <field name="Direccion" class="java.lang.String"/>
    <field name="Telefono" class="java.lang.String"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="145" splitType="Stretch">
            <rectangle>
                <reportElement x="-20" y="-20" width="612" height="165" backcolor="#9CD7FF"/>
            </rectangle>
            <staticText>
                <reportElement x="10" y="20" width="265" height="40"/>
                <textElement textAlignment="Center">
                    <font size="25" isBold="true" isItalic="true"/>
                </textElement>
                <text><![CDATA[Perfil del paciente]]></text>
            </staticText>
            <textField pattern="MMMMM dd, yyyy">
                <reportElement x="10" y="60" width="265" height="22" forecolor="#7D3E00"/>
                <textElement textAlignment="Center"/>
                <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
            </textField>
            <rectangle>
                <reportElement x="-20" y="100" width="612" height="30" backcolor="#DBF6FF"/>
            </rectangle>
            <staticText>
                <reportElement x="120" y="100" width="340" height="30" forecolor="#961212"/>
                <textElement textAlignment="Center">
                    <font size="16" isBold="true"/>
                </textElement>
                <text><![CDATA[Hospital Salud]]></text>
            </staticText>
            <image>
                <reportElement x="480" y="2" width="80" height="80"/>
                <imageExpression><![CDATA[$P{Imagen}]]></imageExpression>
            </image>
        </band>
    </title>
    <pageHeader>
        <band splitType="Stretch"/>
    </pageHeader>
    <columnHeader>
        <band splitType="Stretch"/>
    </columnHeader>
    <detail>
        <band height="437" splitType="Stretch">
            <staticText>
                <reportElement x="0" y="20" width="100" height="30"/>
                <textElement>
                    <font size="16" isUnderline="true"/>
                </textElement>
                <text><![CDATA[Nombre:]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="70" width="100" height="30"/>
                <textElement>
                    <font size="16" isUnderline="true"/>
                </textElement>
                <text><![CDATA[Apellido:]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="120" width="100" height="30"/>
                <textElement>
                    <font size="16" isUnderline="true"/>
                </textElement>
                <text><![CDATA[Nacimiento:]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="220" width="100" height="30"/>
                <textElement>
                    <font size="16" isUnderline="true"/>
                </textElement>
                <text><![CDATA[Sexo:]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="270" width="130" height="30"/>
                <textElement>
                    <font size="16" isUnderline="true"/>
                </textElement>
                <text><![CDATA[Tipo de sangre:]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="320" width="100" height="30"/>
                <textElement>
                    <font size="16" isUnderline="true"/>
                </textElement>
                <text><![CDATA[Dirección:]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="170" width="100" height="30"/>
                <textElement>
                    <font size="16" isUnderline="true"/>
                </textElement>
                <text><![CDATA[Cédula:]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="370" width="100" height="30"/>
                <textElement>
                    <font size="16" isUnderline="true"/>
                </textElement>
                <text><![CDATA[Télefono:]]></text>
            </staticText>
            <textField>
                <reportElement x="140" y="20" width="260" height="30"/>
                <textElement>
                    <font size="16"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{Nombre}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="140" y="70" width="260" height="30"/>
                <textElement>
                    <font size="16"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{Apellido}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="140" y="120" width="260" height="30"/>
                <textElement>
                    <font size="16"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{Fecha_Nacimiento}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="140" y="170" width="260" height="30"/>
                <textElement>
                    <font size="16"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{Cedula}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="140" y="220" width="260" height="30"/>
                <textElement>
                    <font size="16"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{Sexo}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="140" y="270" width="260" height="30"/>
                <textElement>
                    <font size="16"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{Tipo_Sangre}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="140" y="320" width="260" height="30"/>
                <textElement>
                    <font size="16"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{Direccion}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="140" y="370" width="260" height="30"/>
                <textElement>
                    <font size="16"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{Telefono}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <columnFooter>
        <band splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band height="144" splitType="Stretch">
            <rectangle>
                <reportElement x="-20" y="0" width="612" height="144" backcolor="#9CD7FF"/>
            </rectangle>
        </band>
    </pageFooter>
    <summary>
        <band splitType="Stretch"/>
    </summary>
</jasperReport>

I just cant understand whats going on here. :/

Nitin Nanda
  • 805
  • 2
  • 11
  • 27
TwoDent
  • 405
  • 7
  • 26
  • Which libraries are in classpath? – Alex K Nov 02 '16 at 07:26
  • I put a screenshot of the libraries that have added so far ... a couple belong to JasperViewer and one (jasperreports 6.3.1) belongs to JasperLibrary. I saw in a video that when you download this package, you had to add everything that contained a folder named "lib" but in the new version, I see that the folder is empty...(I added that I just mentioned). Others belong to UcanAccess. @AlexK – TwoDent Nov 02 '16 at 13:27
  • It is looks like a magic. You should check libraries loaded by application (with help of classloader) – Alex K Nov 02 '16 at 13:41

0 Answers0