clearReferences系のエラーログ、その2

clearReferencesJdbcは Seasar2 の DriverManagerUtil#deregisterAllDrivers() で無事に削除できた。でも、まだ、clearReferencesThreadsとclearThreadLocalMapがでますね…。clearReferencesThreadsの方は終了するときにsleepをしたりすると、でなくなったりするので、スレッドの終了待ちをすれば良いのかも。clearThreadLocalMapは自分でnullにしないといかんのか? この問題って、ぐぐっても Jackrabbit くらいしか引っかからんのだけど、まだ Tomcat 6.0.24 ってあまりつかわれていないのだろうか…。

10/02/10 6:10:18 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
致命的: A web application appears to have started a thread named [Seasar2-TimeoutManager]
but has failed to stop it. This is very likely to create a memory leak.
2010/02/10 6:10:18 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
致命的: A web application appears to have started a thread named [H2 Log Writer FESS]
but has failed to stop it. This is very likely to create a memory leak.
2010/02/10 6:10:18 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
致命的: A web application appears to have started a thread named [chronos-pool-1-daemonthread-1]
but has failed to stop it. This is very likely to create a memory leak.
2010/02/10 6:10:18 org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
致命的: A web application created a ThreadLocal with key of type [org.seasar.framework.
container.factory.S2ContainerFactory$1] (value [org.seasar.framework.container.factory.
S2ContainerFactory$1@62b21d14]) and a value of type [java.util.LinkedHashSet] (value )
but failed to remove it when the web application was stopped. To prevent a memory leak, the ThreadLocal has been forcibly removed.
2010/02/10 6:10:18 org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
致命的: A web application created a ThreadLocal with key of type [org.seasar.framework.container.external.servlet.HttpServletExternalContext.ImmutableMapThreadLocal] (value [org.seasar.framework.container.external.servlet.HttpServletExternalContext$ImmutableMapThreadLocal@68634baf])
and a value of type [java.util.Collections.EmptyMap] (value [{}]) but failed to remove it when the web
application was stopped. To prevent a memory leak, the ThreadLocal has been forcibly removed.
2010/02/10 6:10:18 org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
致命的: A web application created a ThreadLocal with key of type [org.seasar.framework.container.external.servlet.HttpServletExternalContext.ImmutableMapThreadLocal] (value [org.seasar.framework.container.external.servlet.HttpServletExternalContext$ImmutableMapThreadLocal@29ba92bb])
and a value of type [java.util.Collections.EmptyMap] (value [{}]) but failed to remove it when the web
application was stopped. To prevent a memory leak, the ThreadLocal has been forcibly removed.
2010/02/10 6:10:18 org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
致命的: A web application created a ThreadLocal with key of type [org.seasar.framework.container.external.servlet.HttpServletExternalContext.MutableMapThreadLocal]
(value [org.seasar.framework.container.external.servlet.HttpServletExternalContext$MutableMapThreadLocal@17f74864])
and a value of type [java.util.HashMap] (value [{}]) but failed to remove it when the web application was stopped.
To prevent a memory leak, the ThreadLocal has been forcibly removed.
2010/02/10 6:10:18 org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
致命的: A web application created a ThreadLocal with key of type [org.seasar.framework.container.external.servlet.HttpServletExternalContext.ImmutableMapThreadLocal] (value [org.seasar.framework.container.external.servlet.HttpServletExternalContext$ImmutableMapThreadLocal@6bb1a986])
and a value of type [java.util.Collections.EmptyMap] (value [{}]) but failed to remove it when the web application
was stopped. To prevent a memory leak, the ThreadLocal has been forcibly removed.
2010/02/10 6:10:18 org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
致命的: A web application created a ThreadLocal with key of type [org.seasar.framework.container.external.servlet.HttpServletExternalContext.ImmutableMapThreadLocal] (value [org.seasar.framework.container.external.servlet.HttpServletExternalContext$ImmutableMapThreadLocal@5cf0d3a6])
and a value of type [java.util.Collections.EmptyMap] (value [{}]) but failed to remove it when the web application
was stopped. To prevent a memory leak, the ThreadLocal has been forcibly removed.
2010/02/10 6:10:18 org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
致命的: A web application created a ThreadLocal with key of type [org.seasar.framework.container.external.servlet.HttpServletExternalContext.MutableMapThreadLocal] (value [org.seasar.framework.container.external.servlet.HttpServletExternalContext$MutableMapThreadLocal@46d766f5])
and a value of type [java.util.HashMap] (value [{}]) but failed to remove it when the web application was stopped.
To prevent a memory leak, the ThreadLocal has been forcibly removed.
2010/02/10 6:10:18 org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
致命的: A web application created a ThreadLocal with key of type [org.seasar.framework.container.external.servlet.HttpServletExternalContext.ImmutableMapThreadLocal] (value [org.seasar.framework.container.external.servlet.HttpServletExternalContext$ImmutableMapThreadLocal@67a88328])
and a value of type [java.util.Collections.EmptyMap] (value [{}]) but failed to remove it when the web application
was stopped. To prevent a memory leak, the ThreadLocal has been forcibly removed.

Tomcat 6.0.24のclearReferences系のエラーログ

Tomcat 6.0.24では(22あたりから?)、clearReferenceまわりの処理が強化したのか、以下のようなエラーログがでるようになってしまった。これはどうすれば良いのかね。Tomcatのコードをよく読まんとわからん…。

2010/02/09 6:26:01 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
致命的: A web application registered the JBDC driver [org.h2.Driver] but failed to
unregister it when the web application was stopped. To prevent a memory leak, the
JDBC Driver has been forcibly unregistered.
2010/02/09 6:26:01 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
致命的: A web application registered the JBDC driver [org.h2.Driver] but failed to
unregister it when the web application was stopped. To prevent a memory leak, the
JDBC Driver has been forcibly unregistered.
2010/02/09 6:26:01 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
致命的: A web application appears to have started a thread named [Seasar2-TimeoutManager]
but has failed to stop it. This is very likely to create a memory leak.
2010/02/09 6:26:01 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
致命的: A web application appears to have started a thread named [H2 Log Writer FESS]
but has failed to stop it. This is very likely to create a memory leak.
...

実装クラスはpublicでない方が良いのか…

Twitter4Jでpublicなインターフェースがあって、その実装クラスがpublicでない感じなのだが、まぁ、これはこれで実装クラスを隠蔽して触らせない感じでライブラリを作る側からすると変更しやすいのでよくあるパターンの一つかと思う。でも、リフレクションをしたりするには実装クラスがpublicでないから、publicなインターフェースを使わないとアクセスできない。Seasar2 の Beans とかは実装クラスを使うので取れない感じに陥る。昔は綺麗な感じの設計が好きだったので前者の方だったのだけど、今は開発現場で便利に使える方が重要なので実装クラスはpublicでもいいんじゃない派になっている(publicフィールドにも結構抵抗があったけど、今じゃあれはあれで現場で便利だから拒否反応はなくなった)。S2のBeansで引数増やすとか、ゴニョゴニョと頑張るとかもあるかもしれないけど、そこでがんばるのも微妙な気がして…(Beansの中で実装クラスがpublicじゃなかったらインターフェースを取りにいってアクセスするとか?)。うーん、美しい設計(いまいち何と表現するのが良いか分からんけど)がいいのか、現場で便利なのがいいのか、どちらも間違ってはいないと思うしな。そんな私を悩ます問題は、ディスカッションの「TFJ-298 リフレクションで値が取れない」という話。いろんな考えがある気がしますが、他の方のご意見も興味ありますので時間がありましたらよろしくお願いします~。