LoginSignup
0
0

More than 5 years have passed since last update.

JSON に変換できないエラーの原因の一つにハマった

Posted at

事象

JAX-RS のフィルターでエラー終了しようとして

Stack Dump = org.codehaus.jackson.map.JsonMappingException: Problem introspecting bean properties: type mismatch between read and write methods (through reference chain: hoge.bar.Foo["result"])

という例外が発生した。

どうやら entity に指定した hoge.bar.Foo について問題があるらしい。
"read and write methods" は hoge.bar.Foo の result フィールドを処理中に読み書きのメソッド、つまり getter と setter を指していることが、スタックトレースの情報から、ブレークポイントを仕掛けた java.beans.PorpertyDescriptor の処理をデバッグモードで見てわかった。

結局 result というフィールドに設定したオブジェクトには、ある一つのフィールドに対して、getter が一つ、setter が二つあって、 setter のうちの一つは getter とは型が合わないものであったので、それがダメだと怒られていたという状態。

hoge.bar.Foo 内で read/write で不整合なんてないので、暫くの間迷走してしまった。

要注意

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0