Wednesday, August 12, 2009

Groovy compilation problem while creating report using Jasper Reports

Sorry for so big delay in posting :)

Recently while creating report using Jasper Reports 3.5.2 I faced the issue with compilation error:
java.lang.NoClassDefFoundError: org/codehaus/groovy/control/CompilationFailedException

It was quiet strange cause I'm using pure Java without Groovy.
I found solution on somebody's blog.

In order to solve mentioned issue simple edit your jrxml template and remove the language="groovy" attribute from jasperReport node.

Enjoy!

75 comments:

  1. So simple :) As I understood - removing [language="groovy"] line set "language" variable to default value (let me guess - "java" ?).

    ReplyDelete
  2. Another solution is to copy groovy-all-{version}.jar from the groovy binary distribution into the application's /WEB-INF/lib directory. The file is located in the /embeddable directory within the Groovy distribution. Cheers! :D

    ReplyDelete
    Replies
    1. this is best solution than first one Thanks dude

      Add groovy-all-1.7.5.jar file in ur lib

      Delete
    2. You are great...Alternate solution worked for me after adding groovy jar file to my apache libraries and restarting services...Thank you very much..

      Delete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Thanks, very helpful. To add to suhaizal's comment, if you are using iReport you can get the Groovy JAR from it under ireport/modules/ext and copy that into your project.

    ReplyDelete
  5. Very, very helpful
    I love you all!!!

    ReplyDelete
  6. Really helpful thanks for sharing :)

    ReplyDelete
  7. Thanks from me to ;)

    ReplyDelete
  8. Take care about your subreports.

    If you have a report with subreports, change the language parameter to 'Java'.

    Cheers!

    ReplyDelete
  9. And this error type culd appear in other case if you are passing parameter for fill the report and have a directory route.

    If you have a directory route, you have to set this route without "".

    Example:

    Correct: SUBREPORT_DIR=C:\Documents\reports\

    Incorrect: SUBREPORT_DIR="C:\Documents\reports\"

    Thanks for all and code well!!

    For any question about, feel free to contact me.

    ReplyDelete
    Replies
    1. here u told to remove that double quotes,but that directory class is class="java.lang.String" so if i removed the quotes means then i am getting an error like syntax error

      Delete
  10. Thanks for sharing!

    ReplyDelete
  11. thanks ! i've been stuck on this for hours! i did the second solution of copying the groovy jar into the web proj.

    ReplyDelete
  12. thank you so much... that's really simple though.

    ReplyDelete
  13. thank you so much!this problem confused me couple of hour

    ReplyDelete
  14. Visagan - SLIIT Sri Lanka

    thanks really did help with my stand alone project iacwebsysadmin and Taras Matyashovsky
    and i got some interesting facts about generating reports from ireort + with the help of yours its working properly. :)

    http://kristantohans.wordpress.com/2010/03/01/new-to-jasperreport-build-your-first-impressive-application-part-2/

    ReplyDelete
  15. Thank you so much

    ReplyDelete
  16. If you are using Maven and want to explicitly include the Groovy jar file, you can insert this into your pom.xml file (pretend the '['s and ']'s are open and close angle brackets; this blog software stripped out the XML element tags):

    [dependency]
    [groupId]org.codehaus.groovy[/groupId]
    [artifactId]groovy-all[/artifactId]
    [version]1.7.2[/version]
    [/dependency]

    I would think it possible to add:

    [scope]runtime[/scope]

    ...but when I did so, the jar file was not downloaded by maven.

    The Jasper POM file specifies an earlier version of groovy-all, but I'm going with the later version and have no compatibility problems yet.

    - Keith

    ReplyDelete
  17. greate article.. very - very thank' alot.. visit my blog
    http://ekawidiarto.wordpress.com

    ReplyDelete
  18. Hi there, could you PLEASE help me here :
    in iReport3.7.4
    I found 2 places that we can set the language one of them is for each report in repot properties and one of them is report
    default language in iReport ,
    also there are 3 laguages that u can set (groovy,javascript,java) if u set it to groovy and javascript it would have language="groovy" or language="javascript"
    and it keeps this after save but if u set it to java it doesn't have language="java" and if u yourself add it manualy it would be removed after each save again...so ur report has this error because the language is null
    "javax.servlet.ServletException: au.com.rmt.ca.exceptions.SystemException: net.sf.jasperreports.engine.JRException: Language "javascript" not supported by this report compiler.
    Expecting "java" instead.
    "

    ReplyDelete
  19. Gracias de verdad llevo una semana en esto, al verdad grax por el aporte.. De un programador a programador saludos..! :)

    ReplyDelete
  20. marvellous!!! thank you very much!!

    ReplyDelete
  21. thanks :) it helps

    ReplyDelete
  22. JasperReports declares its dependency to Groovy libraries as optional. You can find a complete explanation of what are the optional dependencies here: http://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html

    ReplyDelete
  23. While im passing .jasper file as argument in java program it says FILENOTFOUND plz tell me how to pass .jasper file from our pacakage

    ReplyDelete
  24. Un buen aporte. no sabia como solucionarlo y este post milagroso me salvo la vida.

    Gracias!!!

    ReplyDelete
  25. thank you soo much dear friend..

    ReplyDelete
  26. Thanx dear...
    Imran Soomro

    ReplyDelete
  27. thank you, I spend my time in other sites, and you are very simple in your answer.

    ReplyDelete
  28. It has been more than 6 hour I was searching for the solution and finally I came up to this site. Thank you very much.....

    ReplyDelete
  29. THANK YOU SOO MUCH GUY I WAS ON THIS ISSUE SINCE THE MORNING

    ReplyDelete
  30. Hi!
    I did as you say, and I get new exception (it's too long so I copy a little), can you help me?


    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at java.lang.Class.isAssignableFrom(Native Method)
    at net.sf.jasperreports.engine.fill.JRFillTextField.getFormat(JRFillTextField.java:706)
    at net.sf.jasperreports.engine.fill.JRFillTextField.evaluateText(JRFillTextField.java:394)
    at net.sf.jasperreports.engine.fill.JRFillTextField.evaluate(JRFillTextField.java:368)
    at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:258)
    at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:499)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2016)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:757)

    ReplyDelete
  31. Thank you for the post, it was great to find the answer pretty quickly.

    So, how to configure iReport to not include the language="groovy" definition in any new report??

    Regards,

    ReplyDelete
  32. I also got this error...

    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at java.lang.Class.isAssignableFrom(Native Method)
    at net.sf.jasperreports.engine.fill.JRFillTextField.getFormat(JRFillTextField.java:706)
    at net.sf.jasperreports.engine.fill.JRFillTextField.evaluateText(JRFillTextField.java:394)
    at net.sf.jasperreports.engine.fill.JRFillTextField.evaluate(JRFillTextField.java:368)
    at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:258)
    at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:499)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillBandNoOverflow(JRVerticalFiller.java:438)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnHeader(JRVerticalFiller.java:481)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:265)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:127)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:938)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:860)
    at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:84)
    at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:624)
    at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:540)

    ReplyDelete
  33. Thanks for your excellent solution

    ReplyDelete
  34. Thanks for removing groovy jar from my project.

    ReplyDelete
  35. This comment has been removed by a blog administrator.

    ReplyDelete
  36. thanks a lot! it works

    ReplyDelete
  37. thank you so much.. it was so simple?? thanks a ton :)

    ReplyDelete
  38. you save my time sir :)

    ReplyDelete
  39. sliit sri lanka
    i tried all above solutions but it didnt help any thing to my jsp i report
    java.lang.NoSuchMethodError: org.codehaus.groovy.runtime.GroovyCategorySupport.getCategoryNameUsage(Ljava/lang/String;)Ljava/util/concurrent/atomic/AtomicInteger;

    ReplyDelete
  40. very helpful thank you very much

    ReplyDelete
  41. just removing language ="groovy" in the xml of jasper
    Simple but very helpful, Thanks v.much

    ReplyDelete
  42. Thank you, this have worked perfectly for me !

    ReplyDelete
  43. I am facing similar error with Jasper Studio Pro 6.2.0final
    Below is trace:

    java.lang.NoClassDefFoundError: net/sf/jasperreports/components/items/fill/FillItemData
    at com.jaspersoft.jasperreports.tibco.maps.fill.TibcoMapFillFactory.toFillComponent(TibcoMapFillFactory.java:23)
    at net.sf.jasperreports.engine.fill.JRFillComponentElement.(JRFillComponentElement.java:72)
    at net.sf.jasperreports.engine.fill.JRFillObjectFactory.visitComponentElement(JRFillObjectFactory.java:1704)
    at net.sf.jasperreports.engine.base.JRBaseComponentElement.visit(JRBaseComponentElement.java:81)
    at net.sf.jasperreports.engine.JRAbstractObjectFactory.getVisitResult(JRAbstractObjectFactory.java:88)
    at net.sf.jasperreports.engine.fill.JRFillElementGroup.(JRFillElementGroup.java:82)
    at net.sf.jasperreports.engine.fill.JRFillElementContainer.(JRFillElementContainer.java:89)
    at net.sf.jasperreports.engine.fill.JRFillBand.(JRFillBand.java:121)
    at net.sf.jasperreports.engine.fill.JRFillObjectFactory.getBand(JRFillObjectFactory.java:522)
    at net.sf.jasperreports.engine.fill.JRFillSection.(JRFillSection.java:74)
    at net.sf.jasperreports.engine.fill.JRFillObjectFactory.getSection(JRFillObjectFactory.java:498)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.(JRBaseFiller.java:254)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.(JRVerticalFiller.java:69)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.(JRVerticalFiller.java:57)
    at net.sf.jasperreports.engine.fill.JRFiller.createBandReportFiller(JRFiller.java:201)
    at net.sf.jasperreports.engine.fill.JRFiller.createReportFiller(JRFiller.java:216)
    at net.sf.jasperreports.engine.fill.BaseFillHandle.(BaseFillHandle.java:74)
    at net.sf.jasperreports.engine.fill.AsynchronousFillHandle.(AsynchronousFillHandle.java:97)
    at net.sf.jasperreports.engine.fill.AsynchronousFillHandle.(AsynchronousFillHandle.java:86)
    at net.sf.jasperreports.engine.fill.AsynchronousFillHandle.createHandle(AsynchronousFillHandle.java:188)
    at com.jaspersoft.studio.editor.preview.view.control.ReportControler$5.run(ReportControler.java:377)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
    Caused by: java.lang.ClassNotFoundException: net.sf.jasperreports.components.items.fill.FillItemData cannot be found by com.jaspersoft.studio.tibcomaps_6.2.0.final
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:439)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:352)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:344)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 22 more

    Although i can see the JAR related to this class is included. But still can't found. Can someone please explain ???

    ReplyDelete
  44. Congratulations!!!!! This works fine !!! (remove groovly from jrxml)

    ReplyDelete


  45. org.codehaus.groovy
    groovy-all
    2.4.10

    ReplyDelete