title: Glassfish and JSF: Singleton not set for WebappClassLoader
body: <p>I've done something that caused this error:</p>
  
  <pre><code>[#|2013-08-15T00:29:32.020+0600|WARNING|glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=91;_ThreadName=Thread-2;|StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
  java.lang.IllegalStateException: Singleton not set for WebappClassLoader (delegate=true; repositories=WEB-INF/classes/)
      at org.glassfish.weld.ACLSingletonProvider$ACLSingleton.get(ACLSingletonProvider.java:110)
      at org.jboss.weld.Container.instance(Container.java:54)
      at org.jboss.weld.jsf.WeldPhaseListener.instance(WeldPhaseListener.java:161)
      at org.jboss.weld.jsf.WeldPhaseListener.activateConversations(WeldPhaseListener.java:98)
      at org.jboss.weld.jsf.WeldPhaseListener.beforePhase(WeldPhaseListener.java:85)
      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:116)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
      at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
      at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
      at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
      at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
      at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
      at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
      at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
      at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
      at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
      at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
      at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
      at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
      at java.lang.Thread.run(Thread.java:722)
  </code></pre>
  
  <p>'Something' may be creating new Faces config file or adding new framework in IntelliJ IDEA IU-129.549 (I don't remember what exactly did I do). Without a success in a troubleshooting, I dropped Glassfish (v. 3.1.2) directory and recreated it, created new project including some frameworks (JSF, CDI, EJB, RESTful, application server and database classes). Created simple login and welcome pages (using Facelets, not JSP) and ran the application.</p>
  
  <p>At first, auto-generated artifact "...:ejb exploded" hasn't been deployed (<em>Invalid ejb jar: it contains zero ejb</em>), at second, this error hasn't been gone, even after the recreating Glassfish directory and project! When I open <strong>ht‮‭tp://localhost:8080/<em>%projectname%</em>/faces/</strong>, I see a 500 error page with given above full trace. What's wrong? Also there were some problems with IDEA's JSF plugin, but now the IDE doesn't show me any errors.</p>