I am using Tomcat 7 + weld-servlet-2.2.3 and this Context is already active error is frequently occuring in the website. I am using three filters: org.jboss.weld.servlet.ConversationFilter
and org.apache.catalina.filters.SetCharacterEncodingFilter
, and a custom filter.
HTTP Status 500 - WELD-000335: Context is already active
java.lang.IllegalStateException: WELD-000335: Context is already active
org.jboss.weld.context.AbstractConversationContext.activate(AbstractConversationContext.java:233)
org.jboss.weld.servlet.ConversationContextActivator.activate(ConversationContextActivator.java:110)
org.jboss.weld.servlet.ConversationContextActivator.activateConversationContext(ConversationContextActivator.java:93)
org.jboss.weld.servlet.ConversationContextActivator.startConversationContext(ConversationContextActivator.java:75)
org.jboss.weld.servlet.ConversationFilter.doFilter(ConversationFilter.java:68)
org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
com.themininghub.web.ActivityFilter.doFilter(ActivityFilter.java:51)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.53 logs.
Apache Tomcat/7.0.53
Please give me some pointers in the right direction.
This issue was because of Tomcat Native Connector. It took a long time for us to identify that by trial and error.
When the Tomcat Native Connector is installed, the threads weren't closed/reused properly, and that was why a previously used thread was still lingering around with the same context!