[ 
https://issues.apache.org/jira/browse/DOXIASITETOOLS-179?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Hervé Boutemy updated DOXIASITETOOLS-179:
-----------------------------------------
    Affects Version/s:     (was: 1.6)
                       1.7

> Report error line and column from Velocity runtime exception
> ------------------------------------------------------------
>
>                 Key: DOXIASITETOOLS-179
>                 URL: https://issues.apache.org/jira/browse/DOXIASITETOOLS-179
>             Project: Maven Doxia Sitetools
>          Issue Type: Improvement
>          Components: Site renderer
>    Affects Versions: 1.7, 1.8
>            Reporter: Jan Krupička
>            Priority: Major
>              Labels: usability
>             Fix For: 1.8.1
>
>         Attachments: velocity-exception-site.zip
>
>
> I have a site page {{index.apt.vm}} which is a Velocity template:
> {noformat}
> My best index page
>   #set ($text = 'text')
>   #set ($text = $text.charAt(-1))
> {noformat}
> When building maven site, this template fails (of course) with a runtime 
> exception. Also the maven build fails (good) with the following output:
> {noformat}
> [ERROR] Error parsing My/site/path/index.apt.vm as a velocity template, using 
> as text.
> [ERROR] Failed to execute goal 
> org.apache.maven.plugins:maven-site-plugin:3.6:site (default-site) on project 
> test-project: Error getting a parser for 'My/site/path/index.apt.vm'
> {noformat}
> This output is not much helpful and is a little misleading. Velocity throws 
> an exception with parsing error line and column. It would be nice to see this 
> in maven error message so it is easy to see where the problem is.
> I can see full stack trace with maven debug build (-X) but I would expect 
> this type of error to be reported in normal build.
> Related class and method:
> {{org.apache.maven.doxia.siterenderer.DefaultSiteRenderer.renderDocument(DefaultSiteRenderer.java:381)}}
> Velocity method that throws useful exception with error description 
> (line/column)
> {{org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.java:354)}}
> Velocity exception to catch and use:
> {{org.apache.velocity.exception.ParseErrorException}}
> Full stacktrace from debug output:
> {noformat}
> [ERROR] Error parsing My/site/path/index.apt.vm as a velocity template, using 
> as text.
> org.apache.velocity.exception.MethodInvocationException: Invocation of method 
> 'charAt' in  class java.lang.String threw exception 
> java.lang.StringIndexOutOfBoundsException: String index out of range:
> -1 at d:\projects\test\tmp\test\src\site\apt\index.apt.vm[line 3, column 23]
>         at 
> org.apache.velocity.runtime.parser.node.ASTMethod.handleInvocationException(ASTMethod.java:243)
>         at 
> org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:187)
>         at 
> org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:280)
>         at 
> org.apache.velocity.runtime.parser.node.ASTReference.value(ASTReference.java:567)
>         at 
> org.apache.velocity.runtime.parser.node.ASTExpression.value(ASTExpression.java:71)
>         at 
> org.apache.velocity.runtime.parser.node.ASTSetDirective.render(ASTSetDirective.java:142)
>         at 
> org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:342)
>         at org.apache.velocity.Template.merge(Template.java:356)
>         at org.apache.velocity.Template.merge(Template.java:260)
>         at 
> org.apache.velocity.app.VelocityEngine.mergeTemplate(VelocityEngine.java:354)
>         at 
> org.apache.maven.doxia.siterenderer.DefaultSiteRenderer.renderDocument(DefaultSiteRenderer.java:381)
>         at 
> org.apache.maven.doxia.siterenderer.DoxiaDocumentRenderer.renderDocument(DoxiaDocumentRenderer.java:53)
>         at 
> org.apache.maven.doxia.siterenderer.DefaultSiteRenderer.render(DefaultSiteRenderer.java:337)
>         at 
> org.apache.maven.plugins.site.render.SiteMojo.renderDoxiaDocuments(SiteMojo.java:262)
>         at 
> org.apache.maven.plugins.site.render.SiteMojo.renderLocale(SiteMojo.java:168)
>         at 
> org.apache.maven.plugins.site.render.SiteMojo.execute(SiteMojo.java:132)
>         at 
> org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
>         at 
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
>         at 
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
>         at 
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
>         at 
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
>         at 
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
>         at 
> org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
>         at 
> org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
>         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
>         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
>         at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
>         at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
>         at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
>         at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>         at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:497)
>         at 
> org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
>         at 
> org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
>         at 
> org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
>         at 
> org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
> Caused by: java.lang.StringIndexOutOfBoundsException: String index out of 
> range: -1
>         at java.lang.String.charAt(String.java:658)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>         at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:497)
>         at 
> org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.doInvoke(UberspectImpl.java:395)
>         at 
> org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:384)
>         at 
> org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:173)
>         ... 36 more
> [INFO] 
> ------------------------------------------------------------------------
> [INFO] BUILD FAILURE
> [INFO] 
> ------------------------------------------------------------------------
> {noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to