Plugin Operation Failed with Velocity ParseErrorException

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.

Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Symptoms

  1. Certain plugin operations always fail with a ParseErrorException as below, both in the browser and in the atlassian-confluence.log:

    Sample error from the Copy Space plugin
    2011-02-01 17:21:16,485 ERROR [TP-Processor22] [opensymphony.webwork.dispatcher.VelocityResult] doExecute Unable to 
    render Velocity Template, '/templates/extra/copyspace/copyspaceoptions.vm'
     -- space: 9633795 | url: /spaces/copyspaceoptions.action | userName: mbuford | referer: 
    http://mfwiki.mfoundry.com/spaces/spacepermissions.action?key=MB22 | action: copyspaceoptions
    org.apache.velocity.exception.ParseErrorException: Invalid arg #0 in directive 
    #bodytag/templates/extra/copyspace/copyspaceoptions.vm[line 36, column 21]
    
    	at org.apache.velocity.Template.process(Template.java:141)
    	at com.atlassian.confluence.util.velocity.ConfigurableResourceManager.loadResource(ConfigurableResourceManager.java:363)
    	at com.atlassian.confluence.util.velocity.ConfigurableResourceManager.getResource(ConfigurableResourceManager.java:304)
    	at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1400)
    	at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1380)
    	at org.apache.velocity.app.VelocityEngine.getTemplate(VelocityEngine.java:401)
    	at com.opensymphony.webwork.dispatcher.VelocityResult.getTemplate(VelocityResult.java:146)
    
  2. The plugin is installed by placing it in <confluence install>/confluence/WEB-INF/lib folder

Cause

The plugin is not compatible with the latest version of Velocity, and it is avoiding the compatibility layer provided for plugins installed in the regular way (through the UI).

According to Migrating to Velocity 1.5 the version of Velocity used since Confluence 2.8 does not accept the bodytag directive's syntax below because the first argument TextField is not surrounded in quotes. However, plugins have a special resourceloader applied that should fix the broken syntax. They are not applied to plugins loaded from WEB-INF/lib for performance reasons.

Using the stack trace from the Copy Space plugin above as an example. The offending line was:

#bodytag( TextField "label='space-name'" "name='newName'" "size=40" )

Workaround

This work around is provided only for educational purposes. Since it will cause a performance issue, please follow the advice provided in the Resolution section.

There is a compatibility layer configured in the velocity.properties file. By default it includes this line:

confplugin.resource.loader.confluence.velocity13.compatibility=true

But if you install the plugin through WEB-INF/lib it does not use the "confplugin" resource loader, it uses the "confclass" resource loader, which does not use the velocity13 compatibility mode.

If one very much wanted to run the plugin from WEB-INF/lib, it can be done by extracting the velocity.properties file from WEB-INF/lib/confluence.jar and placing it in WEB-INF/classes. Then adding this line:

confclass.resource.loader.confluence.velocity13.compatibility=true

Resolution

  1. Stop Confluence
  2. Move the plugin out of the WEB-INF/lib directory
  3. Restart Confluence
  4. Go to Admin Console -> Plugins and upload the jar to the system. This will install the plugin into Confluence's database and it will have the compatibility layer applied.

Related Content

Last modified on Dec 30, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.