I've been using Weld with EclipsLink on Tomcat 7.0.19 and Mojarra 2.1.2 for quite a while now to develop my app and everything seemed to work all right until recently. I started getting this exception, not even sure why and what exactly triggers it:
30-Aug-2011 16:39:21 org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path  threw exception [Must call associate() before calling activate()] with root cause java.lang.IllegalStateException: Must call associate() before calling activate() at org.jboss.weld.context.AbstractConversationContext.activate(AbstractConversationContext.java:277) at org.jboss.weld.jsf.WeldPhaseListener.activateConversations(WeldPhaseListener.java:114) at org.jboss.weld.jsf.WeldPhaseListener.beforePhase(WeldPhaseListener.java:88) at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:228) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:99) at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:111) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:508) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619)
I'd originally used Weld 1.0.1 Final, and now using the latest 1.1.2 Final, but still getting the same exception. I also keep the weld-servlet.jar in my TOMCAT-HOME/lib to be used by all apps.
I originally noticed this behavior when running two apps, both using Weld's CDI on a live server. What happened was that when one app was running everything was fine. But the moment the second app was deployed, upon any request sent to the first one (the already running one), the above would come up crop up. In essence I wasn't (and still am not) able to run two applications at the same time because of this. But there's more. I have only recently begun getting exactly same trace while developing and testing on my local testing server. The scenario is basically that a user logs in and has an option to display a list of his/her earlier saved data that is loaded into a table. What I noticed is that the moment the page with that table is requested the above exception comes up.
I've been breaking my head over this because, I am sure I have not introduced any changes in configuration files or anything that could trigger it elsewhere .. it mystifies me mainly because it only started occurring lately. The only reason I can think of is that maybe I have inadvertently introduced some dependencies between my persistence layer, or any other layer of the application that may be involved in this, that triggers it. But the thought of this makes things even worse because the above error gives me no idea whatsoever as to where to look for the answer.
Perhaps someone has encountered this before and can shed me some light on it ?
I wondered if there is a solution for this problem. I'm running on Tomcat 6. This issue should hae been fixed for Tomcat 7 (see: https://issues.apache.org/bugzilla/show_bug.cgi?id=50789) .
Since I have to stick to Tomcat 6 I wondered if there is a workaround for this issue?
I Had the same issue but on JBoss7.1.1.Final. The way I got it to work was to remove everything from the beans.xml file in my EJB project ( in the OtherSources: src/main/resourse/META-INF folder) , save it and rebuild the project ( Maven project)
Not a neat resolution but it was the only way it would work