3 Replies Latest reply on Nov 2, 2012 6:36 AM by TC Nguyen

    Cannot create a session after the response has been committed SEAM 3 jboss 7

    ramkumarps Newbie

      here is the Dependancies im using for my Project.

      <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <maven.compiler.source>1.7</maven.compiler.source>
      <maven.compiler.target>1.7</maven.compiler.target>
      <org.richfaces.bom.version>4.2.2.Final</org.richfaces.bom.version>
      <seam.version>3.1.0.Final</seam.version>
      <version.jbossas7>7.0.2.Final</version.jbossas7>
      <drools-version>5.3.0.Final</drools-version>
      <drools-api-version>5.2.0-SNAPSHOT<drools-api-version>
      </properties>
      
      

       

      i created a the Basic Seam Security Authenticator as below

       

       

      import java.io.Serializable;
      import javax.faces.application.FacesMessage;
      import javax.faces.context.FacesContext;
      import javax.inject.Inject;
      import org.jboss.seam.security.BaseAuthenticator;
      import org.jboss.seam.security.Credentials;
      import org.jboss.seam.security.Identity;
      import org.picketlink.idm.impl.api.PasswordCredential;
      import org.picketlink.idm.impl.api.model.SimpleUser;
      
      public class Authenticator extends BaseAuthenticator implements org.jboss.seam.security.Authenticator, Serializable {
       private static final long serialVersionUID = 6330848764697614851L;
       @Inject Identity identity;
       @Inject Credentials credentials;
       @Override
       public void authenticate() {
        if ("demo".equals(credentials.getUsername()) && credentials.getCredential() instanceof PasswordCredential && "demo".equals(((PasswordCredential) credentials.getCredential()).getValue())) {
         setStatus(AuthenticationStatus.SUCCESS);
         setUser(new SimpleUser("demo"));
        } else {
         setStatus(AuthenticationStatus.FAILURE);
         FacesContext.getCurrentInstance().addMessage("loginErr",new FacesMessage(FacesMessage.SEVERITY_ERROR, "Invalid Password or Username", "Invalid Password or Username"));
        }
       }
      }
      

       

      Here is my login Snippet looks like

       

       

      <h:commandButton value="Login" title="Log Me In!"  action="#{identity.login}"/>
      

       

       

      when ever i hit the login Button it authenticat with the basicauthenticator, and loged in then immediatly logged out with the below Error Trace.

       

       

      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
      at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_03]
      Caused by: javax.servlet.ServletException: Cannot create a session after the response has been committed
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:606) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
      at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
      at org.jboss.solder.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:65) [solder-impl-3.1.0.Final.jar:3.1.0.Final]
      ... 19 more
      Caused by: java.lang.IllegalStateException: Cannot create a session after the response has been committed
      at org.apache.catalina.connector.Request.doGetSession(Request.java:2636) [jbossweb-7.0.13.Final.jar:]
      at org.apache.catalina.connector.Request.getSession(Request.java:2375) [jbossweb-7.0.13.Final.jar:]
      at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:841) [jbossweb-7.0.13.Final.jar:]
      at com.sun.faces.context.SessionMap.getSession(SessionMap.java:235) [jsf-impl-2.1.7-jbossorg-2.jar:]
      at com.sun.faces.context.SessionMap.put(SessionMap.java:126) [jsf-impl-2.1.7-jbossorg-2.jar:]
      at com.sun.faces.context.SessionMap.put(SessionMap.java:61) [jsf-impl-2.1.7-jbossorg-2.jar:]
      at org.jboss.seam.faces.context.RenderScopedContext.getRenderContextMap(RenderScopedContext.java:252) [seam-faces-3.1.0.Final.jar:3.1.0.Final]
      at org.jboss.seam.faces.context.RenderScopedContext.afterPhase(RenderScopedContext.java:145) [seam-faces-3.1.0.Final.jar:3.1.0.Final]
      at org.jboss.seam.faces.context.RenderScopedContext$Proxy$_$$_WeldClientProxy.afterPhase(RenderScopedContext$Proxy$_$$_WeldClientProxy.java) [seam-fa
      ces-3.1.0.Final.jar:3.1.0.Final]
      at org.jboss.seam.faces.event.DelegatingPhaseListener.afterPhase(DelegatingPhaseListener.java:51) [seam-faces-3.1.0.Final.jar:3.1.0.Final]
      at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:189) [jsf-impl-2.1.7-jbossorg-2.jar:]
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:107) [jsf-impl-2.1.7-jbossorg-2.jar:]
      at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) [jsf-impl-2.1.7-jbossorg-2.jar:]
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]
      ... 25 more
      

       

      any one there with the same issue ? Please Advice me what could be wrong with my Code

      thanks