tohokuaikiのチラシの裏

技術的ネタとか。

Confluenceのbandanaに任意のObjectを保存する時は引数がゼロのコンストラクタが必要

なんか、bandanaManagerを通してConfluenceに登録してたObjectが何かのタイミングで消えてしまってた現象が発生。

あれー?って思ってログ見たら

2015-06-18 16:59:45,738 WARN [http-1990-1] [confluence.setup.bandana.ConfluenceDaoBandanaPersister] getObjectFromValue Configuration could not be loaded because class could not be found (context: jp.junoe.confluence.plugins.conf2wp.Wordpress, key: wordpress_list).
com.thoughtworks.xstream.converters.ConversionException: Cannot construct jp.junoe.confluence.plugins.conf2wp.Wordpress as it does not have a no-args constructor

って盛大にエラーはいてた。

んー、*it does not have a no-args constructor* ってなんだろう?って思って調べたら、ここにまんま書いてあった。
Persistence in Confluence - Atlassian Developers

. It should typically implement Serializable. If the key or value types are defined within a plugin, the class should have a no-argument constructor to avoid class loading issues.

ってことで、シリアライズする時に引数無のコンストラクタが必要だと。そういえば、XMLにmarshalする時もそれ必要だったな。。。。。てか、最初XMLに自力でシリアライズしようとして引数無コンストラクタを作ったのをさっきリファクタしようと思って消してしまってたわ。