Hi All,
In my report I want to insert a barcode image that is generated using Barbecue(Sourceforge) software. I have Jasper 3.0 version installed on my system. I am able to run the demo sample using ant from command prompt. Now, I want to use iReport to create a report with this barcode. I copied BarbecueReport.jrxml to my iReport folder and tried to run it and got this:
net.sf.jasperreports.engine.JRException:ÂErrorsÂwereÂencounteredÂwhenÂcompilingÂreportÂexpressionsÂclassÂfile: 1.Ânet.sf.jasperreports.renderers.BarbecueRendererÂcannotÂbeÂresolvedÂtoÂaÂtype ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂvalueÂ=Â(net.sf.jasperreports.engine.JRRenderable)(newÂnet.sf.jasperreports.renderers.BarbecueRenderer(net.sourceforge.barbecue.BarcodeFactory.createCode128("1234567890")));//$JR_EXPR_ID=11$ ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ<---------------------------------------------> 2.Ânet.sf.jasperreports.renderers.BarbecueRendererÂcannotÂbeÂresolvedÂtoÂaÂtype ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂvalueÂ=Â(net.sf.jasperreports.engine.JRRenderable)(newÂnet.sf.jasperreports.renderers.BarbecueRenderer(net.sourceforge.barbecue.BarcodeFactory.createCode128("1234567890")));//$JR_EXPR_ID=11$ ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ<---------------------------------------------> 3.Ânet.sf.jasperreports.renderers.BarbecueRendererÂcannotÂbeÂresolvedÂtoÂaÂtype ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂvalueÂ=Â(net.sf.jasperreports.engine.JRRenderable)(newÂnet.sf.jasperreports.renderers.BarbecueRenderer(net.sourceforge.barbecue.BarcodeFactory.createCode128("1234567890")));//$JR_EXPR_ID=11$ ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ<---------------------------------------------> 3Âerrors
I have Barbecue..jar and ireport.jar in the classpath. Is there any thing I should do to get this work???
Thanks!
There is no image rotation feature in JasperReports, but you can adapt the Barbecue renderer to rotate the barcode based on a flag. The code would be something like:
public class BarbecueRenderer extends JRAbstractSvgRenderer
private boolean rotate;
private Barcode barcode = null;
public BarbecueRenderer(Barcode barcode)
this(barcode, false);
public BarbecueRenderer(Barcode barcode, boolean rotate)
this.barcode = barcode;
this.rotate = rotate;
public void render(Graphics2D grx, Rectangle2D rectangle)
if (barcode != null)
Graphics2D graphics = (Graphics2D) grx.create();
graphics.translate(rectangle.getX(), rectangle.getY());
if (rotate)
graphics.translate(barcode.getBounds().getHeight(), 0);
graphics.rotate(Math.PI / 2);
barcode.draw(graphics, 0, 0);
}
Then you would do new BarbecueRenderer(..barcode.., true) to get a rotateed barcode.
Regards,
Lucian
Hi Lucian,
I got another problem. Everything works good in ireport and I am able to generate a pdf. But, when I use the same jrxml file in jboss it's throwing below error at "jasper 's fill report".
Error:
javax.servlet.ServletException: Error evaluating expression : Source text : new net.sf.jasperreports.renderers.BarbecueRenderer2(BarcodeFactory.createUPCA("30054897073")) org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791) org.apache.jsp.PrescriptionLabel_jsp._jspService(PrescriptionLabel_jsp.java:220) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) javax.servlet.http.HttpServlet.service(HttpServlet.java:810) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) javax.servlet.http.HttpServlet.service(HttpServlet.java:810) org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
I thought this is a classpath issue and added my jrbarbecue.jar and barbecue..jar to classpath. I tried placing them in jbossdeplylib folder and also under myprojectsrcweb-inflib. But, so far no luck.
Can you please guide me thru' this?
Thanks,
Sammy
I have also the same problem. I created a jar file (jr-barbecue.jar) which contains the class net.sf.jasperreports.renderers.BarbecueRenderer. For iReport I added the barbecue-1.5-beta1.jar and jr-barbecue.jar to the classpath. It works fine. But for my web application it does not work. There is an error (java.lang.NoClassDefFoundError: net/sf/jasperreports/renderers/BarbecueRenderer) even I added the two files to the classpath of my web application.