歩行訓練

おいっちにー!

Spring boot で AbstractHttpSessionApplicationInitializer とか使うと tomcat で死ぬ

リファレンスを斜め読みすると死ぬ。

 

リファレンスはここ。

Spring Session

 

ここを斜め読みすると、2つファイルを作れば良い、という空気を感じてしまう。

  1. Config.java
  2. Initializer.java

で、実際作ってみると、Spring Application で起動する場合は何も起こらない。がTomcatで起動しようとすると

重大: One or more listeners failed to start. Full details will be found in the appropriate container log file
10 18, 2015 6:37:49 午後 org.apache.catalina.core.StandardContext startInternal
重大: 以前のエラーのためにコンテキストの起動が失敗しました [/hoge]

localhostの方は

重大: クラス org.springframework.web.context.ContextLoaderListener のリスナインスタンスにコンテキスト初期化イベントを送信中の例外です
java.lang.IllegalStateException: Cannot initialize context because there is already a root application context present - check whether you have multiple
ContextLoader* definitions in your web.xml!

 とか言われ路頭に迷ってしまう。

 

リファレンスをよく見ると、Spring Bootは別のリンクがあって

Spring Session - Spring Boot

こっちはもうほんと書く量がなくて

github.com

このリンクの量だけで済む。1ファイルだけ。

この少なさは悩んだ時間に対して、かなりダメージが大きい。書き換えたらTomcat上で動いた。今度からはきちんとリファレンスを読もう・・・