Tapestry
  1. Tapestry
  2. TAPESTRY-1338

ApplicationStateObjects not properly instantiated when using PageTester

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.0.3
    • Fix Version/s: 5.0.4
    • Component/s: tapestry-core
    • Labels:
      None
    • Environment:
      OSX, java 1.5, tapestry 5.0.3

      Description

      When using PageTester with pages which contain injected application state objects, the application state objects aren't instantiated. The problem seems to lie at the level of trying to store the ASO into the session (NPE thrown when trying access the session). For test cases, see the attached jar in tapestry-1337.

      Stack Trace:

      org.apache.tapestry.ioc.internal.util.TapestryException [at classpath:org/tapestrycomponents/tassel/pages/ASOTestPage.html, line 3, column 31]
      at org.apache.tapestry.internal.bindings.PropBinding.get(PropBinding.java:58)
      at org.apache.tapestry.internal.structure.ExpansionPageElement.render(ExpansionPageElement.java:47)
      at org.apache.tapestry.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:57)
      at org.apache.tapestry.internal.services.PageMarkupRendererImpl.renderPageMarkup(PageMarkupRendererImpl.java:40)
      at $PageMarkupRenderer_11137ebe6dd.renderPageMarkup($PageMarkupRenderer_11137ebe6dd.java)
      at org.apache.tapestry.test.pagelevel.PageLinkInvoker$1.renderPage(PageLinkInvoker.java:65)
      at org.apache.tapestry.internal.services.PageLinkHandlerImpl.handle(PageLinkHandlerImpl.java:89)
      at $PageLinkHandler_11137ebe6dc.handle($PageLinkHandler_11137ebe6dc.java)
      at org.apache.tapestry.test.pagelevel.PageLinkInvoker.invoke(PageLinkInvoker.java:60)
      at org.apache.tapestry.test.pagelevel.PageTester.invoke(PageTester.java:219)
      at org.apache.tapestry.test.pagelevel.PageTester.renderPage(PageTester.java:184)
      at org.tapestrycomponents.tassel.pages.TestPageTester.testRenderPageWithASO(TestPageTester.java:23)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at junit.framework.TestCase.runTest(TestCase.java:154)
      at junit.framework.TestCase.runBare(TestCase.java:127)
      at junit.framework.TestResult$1.protect(TestResult.java:106)
      at junit.framework.TestResult.runProtected(TestResult.java:124)
      at junit.framework.TestResult.run(TestResult.java:109)
      at junit.framework.TestCase.run(TestCase.java:118)
      at junit.framework.TestSuite.runTest(TestSuite.java:208)
      at junit.framework.TestSuite.run(TestSuite.java:203)
      at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
      Caused by: java.lang.NullPointerException
      at $Request_11137ebe6f5.getSession($Request_11137ebe6f5.java)
      at $Request_11137ebe6c1.getSession($Request_11137ebe6c1.java)
      at org.apache.tapestry.internal.services.SessionApplicationStatePersistenceStrategy.getSession(SessionApplicationStatePersistenceStrategy.java:41)
      at org.apache.tapestry.internal.services.SessionApplicationStatePersistenceStrategy.get(SessionApplicationStatePersistenceStrategy.java:47)
      at org.apache.tapestry.internal.services.ApplicationStateManagerImpl$ApplicationStateAdapter.getOrCreate(ApplicationStateManagerImpl.java:49)
      at org.apache.tapestry.internal.services.ApplicationStateManagerImpl.get(ApplicationStateManagerImpl.java:131)
      at $ApplicationStateManager_11137ebe6ac.get($ApplicationStateManager_11137ebe6ac.java)
      at org.tapestrycomponents.tassel.pages.ASOTestPage._$read_aso(ASOTestPage.java)
      at org.tapestrycomponents.tassel.pages.ASOTestPage.getFooString(ASOTestPage.java:16)
      at $PropertyConduit_11137ebe6ee.get($PropertyConduit_11137ebe6ee.java)
      at org.apache.tapestry.internal.bindings.PropBinding.get(PropBinding.java:54)
      ... 29 more

        Activity

        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12569197 ] jira [ 12590452 ]
        Mark Thomas made changes -
        Workflow jira [ 12399211 ] Default workflow, editable Closed status [ 12569197 ]
        Kent Tong made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Hide
        Robert Zeigler added a comment -

        Yup, it was user error. The ASO was in the package for pages, causing the ClassCastException. The fix is verified. Thanks for an awesome testing utility!

        Show
        Robert Zeigler added a comment - Yup, it was user error. The ASO was in the package for pages, causing the ClassCastException. The fix is verified. Thanks for an awesome testing utility!
        Hide
        Robert Zeigler added a comment -

        So, I've written a variety of tests around some of my existing pages, which all pass. But this very simple test case is still failing, even though the test based on this one which is now in tapestry-core passes! I'm starting to think "user error", but I haven't nailed it down yet.

        Show
        Robert Zeigler added a comment - So, I've written a variety of tests around some of my existing pages, which all pass. But this very simple test case is still failing, even though the test based on this one which is now in tapestry-core passes! I'm starting to think "user error", but I haven't nailed it down yet.
        Hide
        Robert Zeigler added a comment -

        Mixed results on this one. My original test that showed the bug is passing fine. The test case I wrote and submitted here is failing with a ClassCastException:

        org.apache.tapestry.ioc.internal.util.TapestryException: org.tapestrycomponents.tassel.pages.SimpleASO [at classpath:org/tapestrycomponents/tassel/pages/ASOTestPage.html, line 3, column 33]
        at org.apache.tapestry.internal.bindings.PropBinding.get(PropBinding.java:58)
        at org.apache.tapestry.internal.structure.ExpansionPageElement.render(ExpansionPageElement.java:47)
        at org.apache.tapestry.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:57)
        at org.apache.tapestry.internal.services.PageMarkupRendererImpl.renderPageMarkup(PageMarkupRendererImpl.java:40)
        at $PageMarkupRenderer_1116b4a3748.renderPageMarkup($PageMarkupRenderer_1116b4a3748.java)
        at org.apache.tapestry.test.pagelevel.PageLinkInvoker$1.renderPage(PageLinkInvoker.java:66)
        at org.apache.tapestry.internal.services.PageLinkHandlerImpl.handle(PageLinkHandlerImpl.java:89)
        at $PageLinkHandler_1116b4a3747.handle($PageLinkHandler_1116b4a3747.java)
        at org.apache.tapestry.test.pagelevel.PageLinkInvoker.invoke(PageLinkInvoker.java:61)
        at org.apache.tapestry.test.pagelevel.PageTester.invoke(PageTester.java:211)
        at org.apache.tapestry.test.pagelevel.PageTester.renderPage(PageTester.java:179)
        at org.tapestrycomponents.tassel.pages.TestPageTester.testRenderPageWithASO(TestPageTester.java:25)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:645)
        at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:479)
        at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:715)
        at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
        at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
        at org.testng.TestRunner.runWorkers(TestRunner.java:673)
        at org.testng.TestRunner.privateRun(TestRunner.java:620)
        at org.testng.TestRunner.run(TestRunner.java:480)
        at org.testng.SuiteRunner.runTest(SuiteRunner.java:278)
        at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:273)
        at org.testng.SuiteRunner.privateRun(SuiteRunner.java:253)
        at org.testng.SuiteRunner.run(SuiteRunner.java:168)
        at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:987)
        at org.testng.TestNG.runSuitesLocally(TestNG.java:951)
        at org.testng.TestNG.run(TestNG.java:719)
        at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:73)
        at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:122)
        Caused by: java.lang.ClassCastException: org.tapestrycomponents.tassel.pages.SimpleASO
        at org.tapestrycomponents.tassel.pages.ASOTestPage._$read_aso(ASOTestPage.java)
        at org.tapestrycomponents.tassel.pages.ASOTestPage.getFooString(ASOTestPage.java:16)
        at $PropertyConduit_1116b4a3759.get($PropertyConduit_1116b4a3759.java)
        at org.apache.tapestry.internal.bindings.PropBinding.get(PropBinding.java:54)
        ... 32 more

        The code in question is a simple injection:

        @ApplicationState
        private SimpleASO _aso;

        public String getFooString()

        { return _aso.getFoo(); }

        If I add:

        _aso = new SimpleASO();

        above the return _aso.getFoo() line, the test passes fine.

        Still exploring this one.

        Show
        Robert Zeigler added a comment - Mixed results on this one. My original test that showed the bug is passing fine. The test case I wrote and submitted here is failing with a ClassCastException: org.apache.tapestry.ioc.internal.util.TapestryException: org.tapestrycomponents.tassel.pages.SimpleASO [at classpath:org/tapestrycomponents/tassel/pages/ASOTestPage.html, line 3, column 33] at org.apache.tapestry.internal.bindings.PropBinding.get(PropBinding.java:58) at org.apache.tapestry.internal.structure.ExpansionPageElement.render(ExpansionPageElement.java:47) at org.apache.tapestry.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:57) at org.apache.tapestry.internal.services.PageMarkupRendererImpl.renderPageMarkup(PageMarkupRendererImpl.java:40) at $PageMarkupRenderer_1116b4a3748.renderPageMarkup($PageMarkupRenderer_1116b4a3748.java) at org.apache.tapestry.test.pagelevel.PageLinkInvoker$1.renderPage(PageLinkInvoker.java:66) at org.apache.tapestry.internal.services.PageLinkHandlerImpl.handle(PageLinkHandlerImpl.java:89) at $PageLinkHandler_1116b4a3747.handle($PageLinkHandler_1116b4a3747.java) at org.apache.tapestry.test.pagelevel.PageLinkInvoker.invoke(PageLinkInvoker.java:61) at org.apache.tapestry.test.pagelevel.PageTester.invoke(PageTester.java:211) at org.apache.tapestry.test.pagelevel.PageTester.renderPage(PageTester.java:179) at org.tapestrycomponents.tassel.pages.TestPageTester.testRenderPageWithASO(TestPageTester.java:25) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:645) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:479) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:715) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109) at org.testng.TestRunner.runWorkers(TestRunner.java:673) at org.testng.TestRunner.privateRun(TestRunner.java:620) at org.testng.TestRunner.run(TestRunner.java:480) at org.testng.SuiteRunner.runTest(SuiteRunner.java:278) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:273) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:253) at org.testng.SuiteRunner.run(SuiteRunner.java:168) at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:987) at org.testng.TestNG.runSuitesLocally(TestNG.java:951) at org.testng.TestNG.run(TestNG.java:719) at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:73) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:122) Caused by: java.lang.ClassCastException: org.tapestrycomponents.tassel.pages.SimpleASO at org.tapestrycomponents.tassel.pages.ASOTestPage._$read_aso(ASOTestPage.java) at org.tapestrycomponents.tassel.pages.ASOTestPage.getFooString(ASOTestPage.java:16) at $PropertyConduit_1116b4a3759.get($PropertyConduit_1116b4a3759.java) at org.apache.tapestry.internal.bindings.PropBinding.get(PropBinding.java:54) ... 32 more The code in question is a simple injection: @ApplicationState private SimpleASO _aso; public String getFooString() { return _aso.getFoo(); } If I add: _aso = new SimpleASO(); above the return _aso.getFoo() line, the test passes fine. Still exploring this one.
        Kent Tong made changes -
        Fix Version/s 5.0.4 [ 12312381 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Hide
        Kent Tong added a comment -

        Fixed in snapshot. Please verify.

        Show
        Kent Tong added a comment - Fixed in snapshot. Please verify.
        Kent Tong made changes -
        Assignee Kent Tong [ freemant ]
        Robert Zeigler made changes -
        Field Original Value New Value
        Component/s tapestry-core [ 12311285 ]
        Robert Zeigler created issue -

          People

          • Assignee:
            Kent Tong
            Reporter:
            Robert Zeigler
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development