Vaadin and JasperReport

Hai everyone,

I have been using Vaadin with Netbeans about 3 month now. Until now Vaadin do produce desirable output and work very seamless with Netbeans 6.7.1.

However I have been using JasperReports in my previous Struts Framework and I would like to use JasperReports in Vaadin. Can you show me the correct and best way to code it?

I have compiled JasperReports into jasper and like to know how to call it in Vaadin and let the application download it for user.

Any help is very appreciated :slight_smile:

Thank You.

What exactly would you like to achieve - downloading reports (and in which format) or embedding reports on pages with Vaadin components.

If you would like to let the users download PDF reports, you should be able to generate the reports with JasperExportManager. If the reports are not too big, you can even export them to an in-memory byte and serve them directly from it.

Some options:

To create a download link from a page where the report is generated, use the Link component (see e.g.
this forum post
). See also the different types of
Resources
provided by Vaadin.

To embed reports inside an application, you can take a look at the
Embedded
component. There is also an example on the first page linked above.

Creating a permanent download URL for dynamically generated content requires the use of a URIHandler. See
the book
for a window-level URIHandler (preferred) or
this forum post
if you need to handle it on the application level.

Disclaimer: I have not used JasperReports myself, just took a look at its API.

I have tried this:

private void produceForm() {
        User user = (User) getApplication().getUser();
        Connection con = ((MrsApplication) getApplication()).getCon();

        HashMap map = new HashMap();
        map.put("prompt", user.getUserid());
        map.put("date", date.getValue());
        map.put("starttime", null);
        map.put("endtime", null);
        map.put("promptname", user.getFirstname());

        try {
            
            FileOutputStream of = new FileOutputStream("TokenReport.pdf");
            JasperRunManager.runReportToPdfStream(getClass().getClassLoader().getResourceAsStream("reports/TokenReport.jasper"), of, map,con);

        } catch (Exception ex) {
            Logger.getLogger(TokenForm.class.getName()).log(Level.SEVERE, null, ex);
        }
}

Although there is something processing the pdf file did not download.

My second attempt using below code is only show up blank dialog window:

        try {
            //FileOutputStream of = new FileOutputStream("TokenReport.pdf");
            //JasperRunManager.runReportToPdfStream(getClass().getClassLoader().getResourceAsStream("reports/TokenReport.jasper"), of, map, con);

            StreamResource.StreamSource source = new StreamResource.StreamSource() {

                public InputStream getStream() {
                    byte[] b = null;
                    try {
                        b = JasperRunManager.runReportToPdf(getClass().getClassLoader().getResourceAsStream("reports/TokenReport.jasper"), map, con);
                    } catch (JRException ex) {
                        Logger.getLogger(TokenForm.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    //throw new UnsupportedOperationException("Not supported yet.");
                    return new ByteArrayInputStream(b);
                }
            };

            StreamResource resource = new StreamResource(source, "TokenReport.pdf", getApplication());

            Embedded e = new Embedded();
            e.setMimeType("application/pdf");
            e.setType(Embedded.TYPE_BROWSER);
            e.setSource(resource);
            e.setParameter("Content-Disposition", "attachment; filename=" + resource.getFilename());
            Window w = new Window("Token Form");
            w.addComponent(e);
            getWindow().addWindow(w);

        } catch (Exception ex) {
            Logger.getLogger(TokenForm.class.getName()).log(Level.SEVERE, null, ex);
        }

Maybe I code the whole thing in the wrong way?

Problem Solved -_-

After exploring about two days the code below works as I want to. Thanks vaadin team :grin:

        try {
            //FileOutputStream of = new FileOutputStream("TokenReport.pdf");
            //JasperRunManager.runReportToPdfStream(getClass().getClassLoader().getResourceAsStream("reports/TokenReport.jasper"), of, map, con);

            StreamResource.StreamSource source = new StreamResource.StreamSource() {

                public InputStream getStream() {
                    byte[] b = null;
                    try {
                        b = JasperRunManager.runReportToPdf(getClass().getClassLoader().getResourceAsStream("reports/TokenReport.jasper"), map, con);
                    } catch (JRException ex) {
                        Logger.getLogger(TokenForm.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    //throw new UnsupportedOperationException("Not supported yet.");
                    return new ByteArrayInputStream(b);
                }
            };

            StreamResource resource = new StreamResource(source, "TokenReport.pdf", getApplication());
            resource.setMIMEType("application/pdf");

//            Window w = new Window("Token Form");
//            w.setSizeFull();
//            //getWindow().addWindow(w);
//
//            Embedded e = new Embedded();
//            e.setMimeType("application/pdf");
//            e.setType(Embedded.TYPE_OBJECT);
//            e.setSizeFull();
//            e.setSource(resource);
//            e.setParameter("Content-Disposition", "attachment; filename=" + resource.getFilename());
//
//            w.addComponent(e);

            getApplication().getMainWindow().open(resource, "_new");
            

        } catch (Exception ex) {
            Logger.getLogger(TokenForm.class.getName()).log(Level.SEVERE, null, ex);
        }

StreamResource.StreamSource source = new StreamResource.StreamSource() {

            public InputStream getStream() {
                byte[] b = null;
                try {
                    b = JasperRunManager.runReportToPdf(getClass().getClassLoader().getResourceAsStream("reports/TokenReport.jasper"), map, con);

//
//
//
What is map and con?
What about using dynamicreports ?

Hi,

map = the Parameter map which you can send to JasperReports.
con = the connection, for example to a database.

You can find those things in the JasperReports documentation.

Greatings

Hans-Jörg

I have a issue with Jasper and Vaadin while generating HTML Report.
Code sample:


                        JasperPrint print = JasperFillManager.fillReport(report, parameter, ds);
			JRHtmlExporter exporter = new JRHtmlExporter();
			final ByteArrayOutputStream output=new ByteArrayOutputStream();
			exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
			exporter.setParameter(JRExporterParameter.OUTPUT_STREAM,output);			
                        exporter.exportReport();
			output.flush();
                        StreamResource.StreamSource source = new StreamResource.StreamSource() {
				 
				                public InputStream getStream() {
				                   byte[] b = null;
				                    b=output.toByteArray();
			                    return new ByteArrayInputStream(b);
				                }
			            };
                         StreamResource resource = new StreamResource(source, "TestReport.html", application);

When Jasper generating HTML report it is use an empty images tags for width and space formatting and in result HTML we have a lot of empty images like:

<td><img alt="" src="px" style="width: 7px; height: 20px;"/></td>
  <td colspan="2"><span style="font-family: SansSerif; color: #000000; font-size: 10px;">5000</span></td>
  <td><img alt="" src="px" style="width: 5px; height: 20px;"/></td>

Workaraund in Servlet environment is to add specific servlet:

              <servlet-name>ImageServlet</servlet-name>
                <servlet-class>net.sf.jasperreports.j2ee.servlets.ImageServlet</servlet-class>
        </servlet>
<servlet-mapping>
                <servlet-name>ImageServlet</servlet-name>
                <url-pattern>/image</url-pattern>
        </servlet-mapping>

And to add this code to servlet:

exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI,"image?image="); 

I try this in servlet and it is works prefectly, but in Vaadin application image uri is - <APP_Name>/APP/1/image?image=px
and In result I see “image not found” in all positions where empty images is presented.
I try to add in Servlet environment:

</servlet-mapping>
    <servlet-mapping>
    <servlet-name>ImageServlet</servlet-name>
    <url-pattern>/APP/1/image</url-pattern>
  </servlet-mapping>

And seek for others workaraunds without any positive result.
Do you have any ideas?

hi azwa muhd,

Im new to vaadin… I have been using vaadin last one month… i need one help… in my application it needs to generate jasper report… i read your forum… and tried code that you provided but for me its not working… can you give full source code and instructions for generating report…can you help me… Im awaiting for reply soon…

thanks

prabu

Hi!

It works with:

    exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI,"../../image?image=");

Regards

helloo, i have try this, but my application can’t load my .jasper

error like this :

INFO: admin: getPersonRolesByPersonRolesId(1,)
SEVERE: Terminal error:

java.lang.NullPointerException

at java.io.ObjectInputStream$PeekInputStream.read(ObjectInputStream.java:2266)
at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2279)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2750)
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:780)
at java.io.ObjectInputStream.(ObjectInputStream.java:280)
at net.sf.jasperreports.engine.util.ContextClassLoaderObjectInputStream.(ContextClassLoaderObjectInputStream.java:56)
at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:195)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:361)
at net.sf.jasperreports.engine.JasperRunManager.runReportToPdf(JasperRunManager.java:242)
at com.vaadin.cmms.utility.CmmsUtility$2.getStream(CmmsUtility.java:202)
at com.vaadin.terminal.StreamResource.getStream(StreamResource.java:167)
at com.vaadin.Application.handleURI(Application.java:801)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

i think file .jasper not found.

loaded script :

JasperRunManager.runReportToPdf(getClass().getClassLoader().getResourceAsStream(“pdfcreator/faultreportx.jasper”), map, connection);

StreamResource resource = new StreamResource(source, “faultreportx.pdf”, getApplication());

file faultreportx.jasper under directory build/web/pdfcreator/faultreportx.jasper.

how i can use this file in getResourceAsStream

anyone can help me… thanks

Hi,

Here’s your problem : I am assuming that build\web is the root of the web application. In this case, web/pdfcreator/faultreportx.jasper is not on the classpath. web/WEB-INF/classes (and web/WEB-INF/lib/*.jar) are on the classpath, but the root of the web application is not.

I, personally, would split things out a little, something like this (not typed in IDE, not tested, probably won’t compile!):

InputStream reportInputStream = getClass().getClassLoader().getResourceAsStream("pdfcreator/faultreportx.jasper");
if(reportInputStream == null){
   throw new RuntimeException("Could not find report source");
}

JasperRunManager.runReportToPdf(reportInputStream, map, connection);

This way you can see what’s failing a little clearer.
(I’d actually split it out into separate methods, probably different classes - but that’s just me!)
I’d then change the build so that the *.jasper files end up in WEB-INF/classes (or in a jar in WEB-INF/lib)

You could access the .jasper file where it is, but you’d need access to the ServletContext IIRC, and that would get even more complex.

Hope That Helps A Little,
Cheers,

Charles

ok thaks for your help,
my application its ok, but any problem again… pdf embedded from jasper file can’t show data (blank pdf).

here is my code


public ServletContext getServletContext() {
        ApplicationContext ctx = getApplication().getContext();
        if (ctx == null) {
            return null;
        }
        final ServletContext sCtx = ((WebApplicationContext) ctx).getHttpSession().getServletContext();
        return sCtx;
    }

public void printFaultReport() {

        final Connection connection = entityManager.unwrap(java.sql.Connection.class);
        final HashMap map = new HashMap();
        map.put("Nota", "0101A");
        map.put("Tanggal", new Date());
        map.put("Harga", "Rp 20000");
        map.put("Bayar", "Rp 25000");
        map.put("Kembalian", "Rp 5000");

        try {
            StreamResource.StreamSource source = new StreamResource.StreamSource() {

                @Override
                public InputStream getStream() {
                    byte[] b = null;
                    try {
                        InputStream reportInputStream = getServletContext().getResourceAsStream("/pdfcreator/nota.jasper");
                        if (reportInputStream == null) {
                            throw new RuntimeException("Could not find report source");
                        } else {
                            b = JasperRunManager.runReportToPdf(reportInputStream, map, connection);
                        }
                    } catch (JRException ex) {
                        Logger.getLogger(CmmsUtility.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    return new ByteArrayInputStream(b);
                }
            };
            StreamResource resource = new StreamResource(source, "Nota.pdf", getApplication());
            resource.setMIMEType("application/pdf");

            Embedded e = new Embedded();
            e.setSource(resource);
            e.setMimeType("application/pdf");
            e.setType(Embedded.TYPE_BROWSER);
            e.setParameter("Content-Disposition", "attachment; filename=" + resource.getFilename());
            e.setSizeFull();

            Window w = new Window("Nota");
            w.addComponent(e);
            w.setWidth("500px");
            w.setHeight("500px");
            w.setModal(true);
            getWindow().addWindow(w);
        } catch (Exception ex) {
            Logger.getLogger(CmmsUtility.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

any one can help me to find problems…

i use
iReport 3.0.0
to create jasper file and jrxml and
jasperreport versi 4-0.1.

jrxml code


<?xml version="1.0" encoding="UTF-8"  ?>
<!-- Created with iReport - A designer for JasperReports -->
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport
		 name="nota"
		 columnCount="1"
		 printOrder="Vertical"
		 orientation="Portrait"
		 pageWidth="595"
		 pageHeight="842"
		 columnWidth="535"
		 columnSpacing="0"
		 leftMargin="30"
		 rightMargin="30"
		 topMargin="20"
		 bottomMargin="20"
		 whenNoDataType="NoPages"
		 isTitleNewPage="false"
		 isSummaryNewPage="false">
	<property name="ireport.scriptlethandling" value="0" />
	<property name="ireport.encoding" value="UTF-8" />
	<import value="java.util.*" />
	<import value="net.sf.jasperreports.engine.*" />
	<import value="net.sf.jasperreports.engine.data.*" />

	<parameter name="Harga" isForPrompting="false" class="java.lang.String"/>
	<parameter name="Bayar" isForPrompting="false" class="java.lang.String"/>
	<parameter name="Nota" isForPrompting="false" class="java.lang.String"/>
	<parameter name="Tanggal" isForPrompting="false" class="java.util.Date"/>
	<parameter name="Kembali" isForPrompting="false" class="java.lang.String"/>

	<field name="COLUMN_0" class="java.lang.String"/>
	<field name="COLUMN_1" class="java.lang.String"/>
	<field name="COLUMN_2" class="java.lang.String"/>
	<field name="COLUMN_3" class="java.lang.String"/>

		<background>
			<band height="0"  isSplitAllowed="true" >
			</band>
		</background>
		<title>
			<band height="0"  isSplitAllowed="true" >
			</band>
		</title>
		<pageHeader>
			<band height="0"  isSplitAllowed="true" >
			</band>
		</pageHeader>
		<columnHeader>
			<band height="60"  isSplitAllowed="true" >
				<staticText>
					<reportElement
						x="199"
						y="0"
						width="144"
						height="27"
						key="staticText-1"/>
					<box></box>
					<textElement textAlignment="Justified">
						<font pdfFontName="Helvetica-Bold" size="18" isBold="true"/>
					</textElement>
				<text><![CDATA[Nota Penjualan]
]></text>
				</staticText>
				<staticText>
					<reportElement
						x="0"
						y="44"
						width="115"
						height="16"
						key="staticText-2"/>
					<box></box>
					<textElement>
						<font/>
					</textElement>
				<text><![CDATA[Barang]
]></text>
				</staticText>
				<staticText>
					<reportElement
						x="129"
						y="44"
						width="115"
						height="16"
						key="staticText-3"/>
					<box></box>
					<textElement>
						<font/>
					</textElement>
				<text><![CDATA[Harga]
]></text>
				</staticText>
				<staticText>
					<reportElement
						x="262"
						y="44"
						width="115"
						height="16"
						key="staticText-4"/>
					<box></box>
					<textElement>
						<font/>
					</textElement>
				<text><![CDATA[Jumlah]
]></text>
				</staticText>
				<staticText>
					<reportElement
						x="392"
						y="44"
						width="115"
						height="16"
						key="staticText-5"/>
					<box></box>
					<textElement>
						<font/>
					</textElement>
				<text><![CDATA[Total]
]></text>
				</staticText>
			</band>
		</columnHeader>
		<detail>
			<band height="30"  isSplitAllowed="true" >
				<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="0"
						y="7"
						width="115"
						height="18"
						key="textField"/>
					<box></box>
					<textElement>
						<font/>
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA[$F{COLUMN_0}]
]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="129"
						y="7"
						width="115"
						height="18"
						key="textField"/>
					<box></box>
					<textElement>
						<font/>
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA[$F{COLUMN_2}]
]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="262"
						y="7"
						width="115"
						height="18"
						key="textField"/>
					<box></box>
					<textElement>
						<font/>
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA[$F{COLUMN_1}]
]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="392"
						y="7"
						width="115"
						height="18"
						key="textField"/>
					<box></box>
					<textElement>
						<font/>
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA[$F{COLUMN_3}]
]></textFieldExpression>
				</textField>
			</band>
		</detail>
		<columnFooter>
			<band height="60"  isSplitAllowed="true" >
				<staticText>
					<reportElement
						x="0"
						y="9"
						width="61"
						height="19"
						key="staticText-6"/>
					<box></box>
					<textElement>
						<font/>
					</textElement>
				<text><![CDATA[No Nota]
]></text>
				</staticText>
				<staticText>
					<reportElement
						x="0"
						y="36"
						width="61"
						height="19"
						key="staticText-7"/>
					<box></box>
					<textElement>
						<font/>
					</textElement>
				<text><![CDATA[Tanggal]
]></text>
				</staticText>
				<staticText>
					<reportElement
						x="343"
						y="0"
						width="78"
						height="15"
						key="staticText-8"/>
					<box></box>
					<textElement>
						<font/>
					</textElement>
				<text><![CDATA[Total]
]></text>
				</staticText>
				<staticText>
					<reportElement
						x="343"
						y="22"
						width="78"
						height="15"
						key="staticText-9"/>
					<box></box>
					<textElement>
						<font/>
					</textElement>
				<text><![CDATA[Pembayaran]
]></text>
				</staticText>
				<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="435"
						y="0"
						width="100"
						height="18"
						key="textField"/>
					<box></box>
					<textElement>
						<font/>
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA[$P{Harga}]
]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="435"
						y="22"
						width="100"
						height="18"
						key="textField"/>
					<box></box>
					<textElement>
						<font/>
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA[$P{Bayar}]
]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="75"
						y="9"
						width="100"
						height="18"
						key="textField"/>
					<box></box>
					<textElement>
						<font/>
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA[$P{Nota}]
]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="75"
						y="36"
						width="100"
						height="18"
						key="textField"/>
					<box></box>
					<textElement>
						<font/>
					</textElement>
				<textFieldExpression   class="java.util.Date"><![CDATA[$P{Tanggal}]
]></textFieldExpression>
				</textField>
				<staticText>
					<reportElement
						x="343"
						y="44"
						width="78"
						height="13"
						key="staticText-10"/>
					<box></box>
					<textElement>
						<font/>
					</textElement>
				<text><![CDATA[Kembalian]
]></text>
				</staticText>
				<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="435"
						y="41"
						width="100"
						height="18"
						key="textField"/>
					<box></box>
					<textElement>
						<font/>
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA[$P{Kembali}]
]></textFieldExpression>
				</textField>
			</band>
		</columnFooter>
		<pageFooter>
			<band height="0"  isSplitAllowed="true" >
			</band>
		</pageFooter>
		<summary>
			<band height="0"  isSplitAllowed="true" >
			</band>
		</summary>
</jasperReport>

thanks for help

Hi,
I want use JasperReports with HTML export to build in Embedded component of vaadin. I can see the html report but I have empty images to fill in spaces. Did you find a solution to fix this problem ?

thanks

Hi.
I have a problem with integretion vaadin and jasperreport. I’m using Netbeans 6.9.1. I have Vaadin app and I want to print report. I’ve added jasperreport-4.0.2.jar to my web app libs. I put my code below. Every thing is ok, I can load stream, but I get exception:

                    
                    
                    final Map paramMap = new HashMap();
                    paramMap.put("CompanyName", "My Company Inc.");
                    final Connection con;                 
                    FirmaJpaController jpaFirma = new FirmaJpaController();
                    con = jpaFirma.getEntityManager().unwrap(java.sql.Connection.class);
                   StreamResource.StreamSource source = new StreamResource.StreamSource() {

                   public InputStream getStream() { 

                        byte[] b = null;
                        try {
                            b = JasperRunManager.runReportToPdf(getClass().getClassLoader().getResourceAsStream("reports/myreport.jasper"), paramMap, con);
                        } catch (JRException ex) {
                            Logger.getLogger(ClientMenu.class.getName()).log(Level.SEVERE, null, ex);
                        }
                        return new ByteArrayInputStream(b);
                }
            };

              InputStream inputStream = getClass().getClassLoader().getResourceAsStream("reports/myreport.jasper");

                     StreamResource resource = new StreamResource(source, "myreport_" + System.currentTimeMillis() + ".pdf", getApplication());
                                  getApplication().getMainWindow().open(resource, "_new");
            }

I’m newbie in Java. I’m looking forward for replay.

Hi Tomasz,

I strongly suspect that jasper reports has more dependencies - in other words, you need to add more to the webapp “lib” directory. For example, I can see that you are trying to export a PDF file, so you will need to add iText-xxx.jar

According to http://www.installationwiki.org/JasperReports (which is a little out of date), it looks like you’ll also need to add commons-beanutils,commons-collections, commons-digester, and commons-logging too. All of those jars should be in the download archive.

Essentially, this is really a Jasper issue - if adding those jars doesn’t work, I’d go and search on the Jasper forums.

Cheers,

Charles.

Problem solved.
You were right Charles.
I have added all jars files from download archive (*.zip file with Jasper project) to my web app lib folder and now it’s working.

Thanks a lot!

Hi.

I have another problem.
Im using Vaadin with JasperReport. Every thing works under Windows+NetBeans. But now I want to put my Web Application on Linux Server (Centos 5.5). I’ve installed tomcat6 and my Firebird databese. It works fine, but when I want to print report it fails.

To load *.jasper file Im using method:

        static public void PrintReport(final Map paramMap, final String repName){
               final Connection con;
               FirmaJpaController jpaFirma = new FirmaJpaController();
               con = jpaFirma.getEntityManager().unwrap(java.sql.Connection.class); 
               StreamResource.StreamSource source = new StreamResource.StreamSource() {
                public InputStream getStream() {
                        byte[] b = null;
                        try {
                            InputStream rep = app.getContext().getClass().getResourceAsStream(repName.concat(".jasper"));
                            if (rep!=null)  {
                                JasperReport report = (JasperReport) JRLoader.loadObject(rep);
                                report.setWhenNoDataType(JasperReport.WHEN_NO_DATA_TYPE_ALL_SECTIONS_NO_DETAIL);
                                b = JasperRunManager.runReportToPdf(report, paramMap, con);
                            } else {
                                app.getMainWindow().showNotification("There is no report file!");
                            }
                        } catch (JRException ex) {
                            Logger.getLogger(MainApp.class.getName()).log(Level.SEVERE, null, ex);

                        }
                        return new ByteArrayInputStream(b);    
                }
            };
             StreamResource resource = new StreamResource(source, "myreport_" + System.currentTimeMillis() + ".pdf", app);
             app.getMainWindow().open(resource, "_new");
        }

I don’t know what to do. Im loading my *.war file to linux tomcat6 (there should by all needed libs) and it works but i can’t print any report.

Should I install something on Centos to work with JasperReports
?

Im loking forward for replay.

well first of all i am not a good programmer but try your netbeans project on a centos installation (netbeans + centos) and see if it works. do you store the files on the filesystem? if yes look at the path’s. good luck

Hi Francis. Thanks for you message.

I solve the problem. It was font problem. In my libs I haven’t ArialFont package. It was a little strange because I hadn’t any visible exception. I found it in catalina.log.

hi everyone, i’m new in vaadin. i have a developed an almost complete working application, but no with jasperreport. i have tried to change IDE, container, adding all jasper dependencies, etc, with no result. i also tried to run enterpriseapp add-on on my environment, it’s worked except for report. can anyone publish a simple project / add on that show a worked solution for integrating vaadin & jasper? thanks for your help.