Hi,

I am using the Velocity Engine for the first time and need some help on the
following issue. Thanks in advance.

I have a web application which uses Spring framework. To send the template
based emails through application, I have added following to my Spring
context xml file:

<bean id="javaMailSender"
class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="mail.abc.com <http://mail.akazaresearch.com>"/>
</bean>
<bean id="mailMessage" class="org.springframework.mail.SimpleMailMessage">
<property name="from" value="abc_ad...@abc.com<chin_ad...@akazaresearch.com>
"/>
   <property name="subject" value="Test email"/>
</bean>
<bean id="velocityEngine"
class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
 <property name="velocityProperties">
<props>
<prop key="resource.loader">class</prop>
 <prop key="class.resource.loader.class">
org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
             </prop>
             </props>
       </property>
</bean>
<bean id="mailManager"
class="com.akazaresearch.phenonet.server.main.email.MailManagerImpl">
<property name="javaMailSender" ref="javaMailSender"/>
        <property name="mailMessage" ref="mailMessage"/>
        <property name="velocityEngine" ref="velocityEngine"/>
</bean>

MailManagerImpl is a class I have written sendEmail code to.
When I deploy the war file of for web application to Tomcat 6 and try to
start the tomcat from command prompt, I get  ConcurrentModificationException
during the tomcat method call
org.apache.catalina.loader.WebappClassLoader.clearReferences(). I have
pasted the exception stack trace at the end.

I know the exception is thrown when Velocity Engine is initialized because
if I remove the "velocityEngine" property mapping from "mailManager" bean,
tomcat do not throw any exception during the initalization.

After searching on web, I found that the system property
"org.apache.catalina.loader. WebappClassLoader.ENABLE_CLEAR_REFERENCES" for
tomcat is set to true by default and which is why  Tomcat attempts to null
out any static or final fields from loaded classes when a web application is
stopped as a work around for apparent garbage collection bugs and
application coding errors. I read about disabling this property but it took
me to another set of tomcat exceptions. So probably this is of no use.
I tried to use the "resource.loader" value as file for Velocity Engine but I
got the same ConcurrentModificationException.
Could some one please let me know how can I overcome the problem.

Regards,
Pradnya

Exception stack trace:
SEVERE: Exception during cleanup after start failed
java.util.ConcurrentModificationException
        at java.util.HashMap$HashIterator.nextEntry(HashMap.java:841)
        at java.util.HashMap$EntryIterator.next(HashMap.java:883)
        at java.util.HashMap$EntryIterator.next(HashMap.java:881)
        at java.util.HashMap.putAllForCreate(HashMap.java:481)
        at java.util.HashMap.clone(HashMap.java:713)
        at
org.apache.catalina.loader.WebappClassLoader.clearReferences(WebappCl
assLoader.java:1621)
        at
org.apache.catalina.loader.WebappClassLoader.stop(WebappClassLoader.j
ava:1524)
        at
org.apache.catalina.loader.WebappLoader.stop(WebappLoader.java:707)
        at
org.apache.catalina.core.StandardContext.stop(StandardContext.java:45
57)
        at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4
387)
        at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:791)
        at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:77
1)
        at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)

        at
org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:830)

        at
org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:719
)
        at
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490
)
        at
org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
        at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
:311)
        at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
eSupport.java:117)
        at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)

        at
org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
        at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)

        at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443
)
        at
org.apache.catalina.core.StandardService.start(StandardService.java:5
16)
        at
org.apache.catalina.core.StandardServer.start(StandardServer.java:710
)

Reply via email to