Velocity scripts fail to run after upgrading to Confluence 8 or later

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問


プラットフォームについて: Data Center - この記事は、Data Center プラットフォームのアトラシアン製品に適用されます。

このナレッジベース記事は製品の Data Center バージョン用に作成されています。Data Center 固有ではない機能の Data Center ナレッジベースは、製品のサーバー バージョンでも動作する可能性はありますが、テストは行われていません。サーバー*製品のサポートは 2024 年 2 月 15 日に終了しました。サーバー製品を利用している場合は、アトラシアンのサーバー製品のサポート終了のお知らせページにて移行オプションをご確認ください。

*Fisheye および Crucible は除く

要約

Velocity scripts (.vm) cannot be executed succesfully after upgrading to Confluence 8 or later

環境

Confluence 8 or later

診断

Apart from the fact that the script fails, in the atlassian-confluence.log you could find the following error message: 

2023-11-21 08:52:50,361 WARN [http-nio-8090-exec-10 url: /confluence/login.action] [confluence.impl.hibernate.ConfluenceHibernateTransactionManager] doRollback Performing rollback. Transactions:\n  ->[null]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT (Session #1227624352)
 -- url: /confluence/login.action | userName: anonymous | referer: https://CONFLUENCE_URL/confluence/ | traceId: 9d59d9013c4856bb
2023-11-21 08:52:50,362 ERROR [http-nio-8090-exec-10 url: /confluence/login.action] [apache.struts2.dispatcher.DefaultDispatcherErrorHandler] sendErrorResponse Exception occurred during processing request: Encountered \"#end\\n\" at /login.vm[line 119, column 25]\nWas expecting one of:\n    <EOF> \n    \"(\" ...\n    <RPAREN> ...\n    <ESCAPE_DIRECTIVE> ...\n    <SET_DIRECTIVE> ...\n    \"##\" ...\n    \"\\\\\\\\\" ...\n    \"\\\\\" ...\n    <TEXT> ...\n    \"*#\" ...\n    \"*#\" ...\n    <STRING_LITERAL> ...\n    <IF_DIRECTIVE> ...\n    <STOP_DIRECTIVE> ...\n    <INTEGER_LITERAL> ...\n    <FLOATING_POINT_LITERAL> ...\n    <WORD> ...\n    <BRACKETED_WORD> ...\n    <IDENTIFIER> ...\n    <DOT> ...\n    \"{\" ...\n    \"}\" ...\n
 -- url: /confluence/login.action | userName: anonymous | referer: https://CONFLUENCE_URL/confluence/ | traceId: 9d59d9013c4856bb
org.apache.velocity.exception.ParseErrorException: Encountered "#end\n" at /login.vm[line 119, column 25]
Was expecting one of:
    <EOF>
    "(" ...
    <RPAREN> ...
    <ESCAPE_DIRECTIVE> ...
    <SET_DIRECTIVE> ...
    "##" ...
    "\\\\" ...
    "\\" ...
    <TEXT> ...
    "*#" ...
    "*#" ...
    <STRING_LITERAL> ...
    <IF_DIRECTIVE> ...
    <STOP_DIRECTIVE> ...
    <INTEGER_LITERAL> ...
    <FLOATING_POINT_LITERAL> ...
    <WORD> ...
    <BRACKETED_WORD> ...
    <IDENTIFIER> ...
    <DOT> ...
    "{" ...
    "}" ...

        at org.apache.velocity.Template.process(Template.java:141)
        at com.atlassian.confluence.velocity.ConfigurableResourceManager.loadResource(ConfigurableResourceManager.java:350)
        at com.atlassian.confluence.velocity.ConfigurableResourceManager.getResource(ConfigurableResourceManager.java:298)
        at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1400)
        at org.apache.velocity.app.VelocityEngine.getTemplate(VelocityEngine.java:422)
        at org.apache.struts2.result.VelocityResult.getTemplate(VelocityResult.java:219)
        at com.atlassian.xwork.results.ProfiledVelocityResult.getTemplate(ProfiledVelocityResult.java:27)
        at org.apache.struts2.result.VelocityResult.doExecute(VelocityResult.java:146)
        at com.atlassian.xwork.results.ProfiledVelocityResult.doExecute(ProfiledVelocityResult.java:18)
        at com.atlassian.confluence.setup.struts.EncodingVelocityResult.doExecute(EncodingVelocityResult.java:43)
        at org.apache.struts2.result.StrutsResultSupport.execute(StrutsResultSupport.java:206)
...
...

原因

Confluence 8.0 introduced many platform related changes which can cause app failures. The full list of changes can be found in Preparing for Confluence 8.0

In order to modernise our code base, reduce tech debt and secure against OGNL attacks, Confluence team decided to move to Struts2.

ソリューション

As part of this migration, the #tag  and #bodytag  tags need to be migrated to the recommended new tags as per the Struts2 Upgrade Guide.

In depth details are available under section Update from 30 Aug 2022, where it is explained how to migrate the #bodytag( "Component" <parameters>) and #bodytag( "TextField" <parameters>). Thought it is not mentioned, a similar approach also applies for #bodytag ( "Password" <parameters>) if you are using it. 

最終更新日: 2023 年 12 月 6 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.