When dozer (5.0) is used in a web container (tomcat 6) the autoregistered JMX bean causes a memory leak on reload. While the JMX bean is still registered after application shutdown, there is a reference between the bean and the webapp classloader. This reference keeps the webapp classloader from being garbage collected. So with autoregistered JMX bean after a couple of redeployments of a WAR in tomcat, an out of memory error will be caused by this memory leak.
Simple workaround is to disable the JMX bean with the dozer config property.
I use dozer in a webapp with spring, configured, as mentioned in the docs, as spring singleton.
A solution to the problem without disabling the JMX bean could be the following:
- org.dozer.DozerBeanMapper could implement springs DisposableBean interface and clean up the bean at shutdown. To prevent any dependency to spring dozer could just have a shutdown / destroy method, that could be explicitly configured in spring as shutdown method with <... destroy-method=""/>.
- A finalizer to the central org.dozer.DozerBeanMapper to unregister the bean may be another, not so preferrable way to solve this.
Log in to post a comment.