3 Replies Latest reply on Nov 26, 2007 3:13 PM by Levent Aksu

    NPE while trying to new a FacesRequest

    Levent Aksu Newbie

      Hi,
      I have my test build as close to the hibernate2 example as possible. I have a test of test environment like the following:

      import org.jboss.seam.mock.BaseSeamTest.ComponentTest;
      import org.jboss.seam.mock.SeamTest;
      import org.jboss.seam.mock.SeamTest.FacesRequest;
      import org.testng.annotations.Test;
      
      public class TestIntact extends SeamTest {
      
       @Test
       public void testIntact(){
       assert true;
       }
      
      
       @Test
       public void componentTestIntact() throws Exception{
       new ComponentTest(){
       @Override
       protected void testComponents() throws Exception{
       assert true;
       }
       }.run();
       }
      
       @Test
       public void facesTestIntact() throws Exception {
       System.out.println("Faces Intact Test");
      
       new FacesRequest() {
       @Override
       protected void invokeApplication() throws Exception {
       assert true;
       }
       }.run();
      }
      


      All it does is asserting the true however facesTestIntact() fails with the following stack trace:

      [testng] PASSED: testComponentTestIntact
       [testng] PASSED: testIntact
       [testng] FAILED: TestIntact.facesTestIntact()
       [testng] java.lang.NullPointerException
       [testng] at org.jboss.seam.mock.BaseSeamTest$Request.run(BaseSeamTest.java:514)
       [testng] at TestIntact.facesTestIntact(TestIntact.java:30)
       [testng] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       [testng] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       [testng] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       [testng] at java.lang.reflect.Method.invoke(Method.java:585)
       [testng] at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:529)
       [testng] at org.testng.internal.Invoker.invokeMethod(Invoker.java:398)
       [testng] at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:625)
       [testng] at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:88)
       [testng] at org.testng.TestRunner.privateRun(TestRunner.java:614)
       [testng] at org.testng.TestRunner.run(TestRunner.java:505)
       [testng] at org.testng.SuiteRunner.privateRun(SuiteRunner.java:221)
       [testng] at org.testng.SuiteRunner.run(SuiteRunner.java:147)
       [testng] at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:576)
       [testng] at org.testng.TestNG.runSuitesLocally(TestNG.java:539)
       [testng] at org.testng.TestNG.run(TestNG.java:316)
       [testng] at org.testng.TestNG.privateMain(TestNG.java:666)
       [testng] at org.testng.TestNG.main(TestNG.java:608)
      


      I use Java 5 SDK and Seam 2.0.0 GA.
      I cannot tell what could be wrong.

        • 1. Re: NPE while trying to new a FacesRequest
          Pete Muir Master

          You'll need to use your debugger to find out what is null at that point. Post that back, and we'll have a better idea of where the problem is originating from.

          • 2. Re: NPE while trying to new a FacesRequest
            Levent Aksu Newbie

            I have set-up the debugging and it took me some time to figure out putting debugging, testng and netbeans together. I now start the testng session in command-line style (as opposed to testng ant task) and attach the netbeans debugger on to it.

            Here is where I lose track:

            BaseSeamTest.java:
            
             public String run() throws Exception
             {
             try
             {
             init();
             beforeRequest();
             setStandardJspVariables();
             seamFilter.doFilter(request, response, new FilterChain() { //(A)
             public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException
             {
             try
             {
             if ( emulateJsfLifecycle() )
             {
             saveConversationViewRoot();
             }
             }
             catch (Exception e)
             {
             onException(e);
             throw new ServletException(e);
             }
             }
             } );
             seamFilter.destroy();
             afterRequest();
             return conversationId;
             }
             finally
             { //(B)
             if (Contexts.isEventContextActive())
             {
             FacesLifecycle.endRequest(externalContext);
             }
             }
            
             }



            At (A) request and response objects are not null. The breakpoints in doFilter method are never visited. When it tries to execute line (A)
            it jumps directly to finally block at (B). What else would you like me to check?


            • 3. Re: NPE while trying to new a FacesRequest
              Levent Aksu Newbie

              I guess testng jar from testng site is causing all the trouble. trying with the jar from seam 2 dist