click-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bob Schellink (JIRA)" <j...@apache.org>
Subject [jira] Commented: (CLK-606) Remove Click core's dependency on Velocity
Date Tue, 16 Mar 2010 09:51:27 GMT

    [ https://issues.apache.org/jira/browse/CLK-606?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12845781#action_12845781
] 

Bob Schellink commented on CLK-606:
-----------------------------------

Thanks Malcolm, the latest checkin looks good. I'm wondering if we should only print the cause
and not the template exception trace. By changing TemplateException to this:


public class TemplateException {
    ...

    @Override
    public void printStackTrace (java.io.PrintStream s) {
        synchronized(s) {
            if(getCause() == this) {
                super.printStackTrace(s);
            } else {
                getCause().printStackTrace(s);
            }
        }
    }

    @Override
    public void printStackTrace (java.io.PrintWriter s) {
        synchronized(s) {
            if(getCause() == this) {
                super.printStackTrace(s);
            } else {
                getCause().printStackTrace(s);
            }
        }
    }

    @Override
    public Throwable fillInStackTrace () {
        if(getCause() == this) {
            return super.fillInStackTrace ();
        }
        return this;
    }
}


The stackTrace goes from this:

[Click] [error] handleException: org.apache.click.service.TemplateException: java.lang.NullPointerException
        at org.apache.click.service.VelocityTemplateService.internalRenderTemplate(VelocityTemplateService.java:621)
        at org.apache.click.service.VelocityTemplateService.renderTemplate(VelocityTemplateService.java:331)
        at org.apache.click.ClickServlet.renderTemplate(ClickServlet.java:842)
        at org.apache.click.ClickServlet.performRender(ClickServlet.java:800)
        at org.apache.click.ClickServlet.processPage(ClickServlet.java:566)
        at org.apache.click.ClickServlet.handleRequest(ClickServlet.java:374)
        ...
  Caused by: java.lang.NullPointerException
        at org.apache.click.examples.page.general.ExceptionPage$BrokenRenderer.toString(ExceptionPage.java:101)
        at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:393)
        at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:336)
        at org.apache.velocity.runtime.directive.Parse.render(Parse.java:260)


to this:

[Click] [error] handleException: java.lang.NullPointerException
        at org.apache.click.examples.page.general.ExceptionPage$BrokenRenderer.toString(ExceptionPage.java:101)
        at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:393)
        at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:336)
        at org.apache.velocity.runtime.directive.Parse.render(Parse.java:260)



> Remove Click core's dependency on Velocity
> ------------------------------------------
>
>                 Key: CLK-606
>                 URL: https://issues.apache.org/jira/browse/CLK-606
>             Project: Click
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 2.1.0, 2.1.0 RC1
>         Environment: click-nodeps-2.1.0-RC1-incubating.jar , click-extras-2.1.0-RC1-incubating.jar,
ognl-2.6.9.jar, freemarket2.3.16.jar
>            Reporter: Andrey Rybin
>            Assignee: Malcolm Edgar
>            Priority: Minor
>             Fix For: 2.2.0
>
>
> I use freemarker and dependencies in separate jars. 
> I haven't 'velocity' in my classpath.
> So I found bug: common click core depends on Velocity.
> Namely:
> org.apache.click.ClickServlet.java
> org.apache.click.util.ErrorReport.java
> They both depend on
> org.apache.velocity.exception.ParseErrorException   (search:
> instanceof ParseErrorException)
> and require Velocity be present in classpath even if freemarker are used.
> My workaround:
> I made fake public class ParseErrorException extends Exception {}.
> But you can make generic solution, for example:
> TemplateService
> + boolean isParseErrorException (Exception e)
> + Map<String, Object> describeParseErrorException (Exception e)
> or your own ClickTemplateException to wrap low level velocity/freemarker exceptions.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message