0 Replies Latest reply on Nov 9, 2013 8:37 AM by alexey plotnikov

    Arquillian and Seam 2.3.1.Final: Unable to invalidate Seam session

    alexey plotnikov Newbie

      Hi all i read this documentation Seam - Contextual Components.

      And i wrote next test:

      @RunWith(Arquillian.class)
      public class RootTest extends JUnitSeamTest {
      
          @Deployment
          @OverProtocol("Servlet 3.0")
          public static Archive<?> createDeployment() {
              WebArchive web = ShrinkWrap.create(ZipImporter.class, "project.war").
                      importFrom(new File("[FULL PATH TO project.war]")).
                      as(WebArchive.class).
                      addClasses(RootTest.class);
      
              web.delete("/WEB-INF/web.xml");
              web.addAsWebInfResource("mock-web.xml", "web.xml");
      
              return web;
          }
      
          @Before
          public void before() {
              Lifecycle.beginCall();
          }
      
          @After
          public void after(){
              Lifecycle.endCall();
          }
      
          protected void setValue(String valueExpression, Object value) {
              Expressions.instance().createValueExpression(valueExpression).setValue(value);
          }
      
          @Test
          public void testLogin() throws Exception {
              new FacesRequest("/login.xhtml") {
                  @Override
                  protected void processValidations() throws Exception {
                      validateValue("#{identity.username}", "1ovthafew");
                      validateValue("#{identity.password}", "Gavin King");
                      assert !isValidationFailure();
                  }
      
                  @Override
                  protected void updateModelValues() throws Exception {
                      setValue("#{identity.username}", "1ovthafew");
                      setValue("#{identity.password}", "Gavin King");
                  }
      
      
                  @Override
                  protected void invokeApplication() {
                      assert invokeMethod("#{identty.login}").equals("/main_page.xhtml");
                      setOutcome("/main_page.xhtml");
                  }
      
      
                  @Override
                  protected void afterRequest() {
                      assert isInvokeApplicationComplete();
                      assert !isRenderResponseBegun();
                  }
      
              }.run();
          }
      
      }
      
      

      mock-web.xml same as web.xml, but i replaced listener-class to "org.jboss.seam.mock.MockSeamListener"(was "org.jboss.seam.servlet.SeamListener").

      Then i start test, i get next error:

      java.lang.IllegalStateException: Error launching test at http://localhost:8080/server/ArquillianServletRunner?outputMode=serializedObject&className=RootTest&methodName=testLogin&cmd=event. Got 500 (Internal Server Error)
        at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.execute(ServletMethodExecutor.java:237)
        at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.access$000(ServletMethodExecutor.java:43)
        at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor$1.run(ServletMethodExecutor.java:99)
        at java.util.TimerThread.mainLoop(Timer.java:512)
        at java.util.TimerThread.run(Timer.java:462)
      
      

      in server log(glassfish v3.1.2 - managed) i see:

      [#|2013-11-09T14:50:28.347+0800|WARNING|oracle-glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=19;_ThreadName=Thread-5;|StandardWrapperValve[ArquillianServletRunner]: PWC1406: Servlet.service() for servlet ArquillianServletRunner threw exception
      java.lang.IllegalStateException: Unable to invalidate Seam session.
        at org.jboss.jsfunit.seam.SeamUtil.invalidateSeamSession(SeamUtil.java:117)
        at org.jboss.jsfunit.arquillian.container.JSFUnitCleanupTestTreadFilter.cleanUp(JSFUnitCleanupTestTreadFilter.java:61)
        at org.jboss.jsfunit.arquillian.container.JSFUnitCleanupTestTreadFilter.doFilter(JSFUnitCleanupTestTreadFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
        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:860)
        at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
        at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
        at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
        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:680)
      Caused by: java.lang.NullPointerException
        at org.jboss.jsfunit.seam.SeamUtil.invalidateSeamSession(SeamUtil.java:112)
        ... 27 more
      |#]