Jump to content

Recommended Posts

Posted

I have a jasper project that I compile in a .jar to be use in a main project. Everything works just fine until I want to use the preview option, and it throws me this error:

net.sf.jasperreports.engine.JRException: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text:  Utils.modifyHtmlForJasper($F{line_alternative_short_description})    at com.jaspersoft.studio.editor.preview.view.control.ReportController.fillReport(ReportController.java:553)    at com.jaspersoft.studio.editor.preview.view.control.ReportController$1.run(ReportController.java:446)    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)Caused by: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: Utils.modifyHtmlForJasper($F{line_alternative_short_description})    at net.sf.jasperreports.engine.fill.JREvaluator.handleEvaluationException(JREvaluator.java:294)    at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:328)    at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:673)    at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:641)    at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:1247)    at net.sf.jasperreports.engine.fill.JRFillTextField.evaluateText(JRFillTextField.java:555)    at net.sf.jasperreports.engine.fill.JRFillTextField.evaluate(JRFillTextField.java:540)    at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:383)    at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:548)    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2614)    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:837)    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:276)    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:119)    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:623)    at net.sf.jasperreports.engine.fill.BaseFillHandle$ReportFill.run(BaseFillHandle.java:135)    at java.base/java.lang.Thread.run(Unknown Source)Caused by: java.lang.Error: Unresolved compilation problems:     Whitelist cannot be resolved to a type    Whitelist cannot be resolved    Jsoup cannot be resolved    at Utils.modifyHtmlForJasper(Utils.java:122)    at TravelDetail_1684445308128_220990.evaluate(TravelDetail_1684445308128_220990:303)    at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:313)    ... 14 more[/code]

This is the class Utils:

package com.toursys.jasper.util;import org.jsoup.Jsoup;import org.jsoup.safety.Whitelist;import static com.toursys.jasper.util.JsfUtil.getContextPath;public final class Utils {public static String modifyHtmlForJasper(String text) {        if (text != null && !"".equals(text)) {            String str = text                    .replace("<strong>", "htmlstrong")                    .replace("</strong>", "htmlclosestrong")                    .replace("</p>", HTML_BR)                    .replace("<em>", "htmli")                    .replace("</em>", "htmcloseli")                    .replace("<sup>", "htmlsup")                    .replace("</sup>", "htmlclosesup")                    .replace("<sub>", "htmlsub")                    .replace("</sub>", "htmlclosesub")                    .replace("<li>", "htmlli")                    .replace("</li>", "htmlcloseli")                    .replace("<ul>", "htmlul")                    .replace("</ul>", "htmlcloseul")                    .replace("<br />", HTML_BR)                    .replace("<div>", HTML_BR)                    .replace(" ", " ");            Whitelist wl = Whitelist.none();            wl.addTags("a");            wl.addAttributes("a", "href");            wl.addProtocols("a", "href", "ftp", "http", "https", "mailto");            str = Jsoup.clean(str, wl);            str = str                    .replace("htmlstrong", "<b>")                    .replace("htmlclosestrong", "</b>")                    .replace("htmlbr", "<br />")                    .replace("htmli", "<i>")                    .replace("htmcloseli", "</i>")                    .replace("htmlsup", "<sup>")                    .replace("htmlclosesup", "</sup>")                    .replace("htmlsub", "<sub>")                    .replace("htmlclosesub", "</sub>")                    .replace("htmlli", "<li>")                    .replace("htmlcloseli", "</li>")                    .replace("htmlul", "<ul>")                    .replace("htmlcloseul", "</ul>");            return str;        }        return null;    }}[/code]

I tried by adding the jar for jsoup into the classpath

 

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Posted


Thank you for posting to the Jaspersoft Community. Our team of experts has read your question and we are working to get you an answer as quickly as we can. If you have a Jaspersoft Professional Subscription plan, please visit https://support.tibco.com/s/ for direct access to our technical support teams offering guaranteed response times.

Posted

Hello Bryan,

Looking at the error, it seems that you are mising some dependencies in the project classpaths. Can you check that you have added all needed jars? 

    Whitelist cannot be resolved to a type    Whitelist cannot be resolved    Jsoup cannot be resolved

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...