You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Matt Cooper (JIRA)" <de...@myfaces.apache.org> on 2009/06/16 01:56:07 UTC

[jira] Created: (TRINIDAD-1506) ClassCastException during surefire tests when calling ExternalContextUtils.getServletContextPath()

ClassCastException during surefire tests when calling ExternalContextUtils.getServletContextPath()
--------------------------------------------------------------------------------------------------

                 Key: TRINIDAD-1506
                 URL: https://issues.apache.org/jira/browse/TRINIDAD-1506
             Project: MyFaces Trinidad
          Issue Type: Bug
    Affects Versions:  1.2.11-core
            Reporter: Matt Cooper
            Priority: Minor


If you have a renderer that makes a call like this:

ExternalContextUtils.getServletContextPath(context.getExternalContext());

Then, when running a surefire test for a component that uses such a renderer, a ClassCastException will be thrown where some underlying code is expecting a javax.servlet.ServletContext however, a org.apache.myfaces.trinidadinternal.renderkit.MApplication is provided instead.  Perhaps MApplication needs to implement/extend ServletContext or otherwise ExternalContextUtils.getServletContextPath() needs to return a dummy value when running surefire tests.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (TRINIDAD-1506) ClassCastException during surefire tests when calling ExternalContextUtils.getServletContextPath()

Posted by "Matt Cooper (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/TRINIDAD-1506?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12720166#action_12720166 ] 

Matt Cooper commented on TRINIDAD-1506:
---------------------------------------

Sure, here's a sample stack trace for this issue:

java.lang.ClassCastException: org.apache.myfaces.trinidadinternal.renderkit.MApplication cannot be cast to javax.servlet.ServletContext
	at org.apache.myfaces.trinidad.util.ExternalContextUtils.getServletContextPath(ExternalContextUtils.java:193)
	at custom.MyRenderer._someMethodThatCallsGetServletContextPathOnExternalContextUtils(MyRenderer.java:1110)
	at custom.MyRenderer.encodeAll(MyRenderer.java:69)
	at org.apache.myfaces.trinidad.render.CoreRenderer.encodeEnd(CoreRenderer.java:335)
	at org.apache.myfaces.trinidad.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:751)
	at org.apache.myfaces.trinidad.render.RenderUtils.encodeRecursive(RenderUtils.java:70)
	at org.apache.myfaces.trinidad.render.RenderUtils.encodeRecursive(RenderUtils.java:65)
	at org.apache.myfaces.trinidadinternal.renderkit.RenderUtils.encodeRecursive(RenderUtils.java:47)
	at org.apache.myfaces.trinidadinternal.renderkit.RenderKitTestCase$BaseTest.renderRoot(RenderKitTestCase.java:213)
	at custom.MyRenderKitTest$ClientComponentTest.runTest(MyRenderKitTest.java:282)
	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 org.apache.myfaces.trinidadinternal.renderkit.RenderKitTestCase$BaseTest.run(RenderKitTestCase.java:143)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at org.apache.myfaces.trinidadinternal.renderkit.RenderKitTestCase.run(RenderKitTestCase.java:92)
	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:597)
	at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:213)
	at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:138)
	at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:125)
	at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
	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:597)
	at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:290)
	at org.apache.maven.surefire.booter.SurefireBooter.run(SurefireBooter.java:198)
	at org.apache.maven.plugin.surefire.SurefirePlugin.execute(SurefirePlugin.java:398)
	at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)
	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:499)
	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:478)
	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330)
	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:291)
	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
	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:597)
	at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
	at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
	at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
	at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

> ClassCastException during surefire tests when calling ExternalContextUtils.getServletContextPath()
> --------------------------------------------------------------------------------------------------
>
>                 Key: TRINIDAD-1506
>                 URL: https://issues.apache.org/jira/browse/TRINIDAD-1506
>             Project: MyFaces Trinidad
>          Issue Type: Bug
>    Affects Versions:  1.2.11-core
>            Reporter: Matt Cooper
>            Priority: Minor
>
> If you have a renderer that makes a call like this:
> ExternalContextUtils.getServletContextPath(context.getExternalContext());
> Then, when running a surefire test for a component that uses such a renderer, a ClassCastException will be thrown where some underlying code is expecting a javax.servlet.ServletContext however, a org.apache.myfaces.trinidadinternal.renderkit.MApplication is provided instead.  Perhaps MApplication needs to implement/extend ServletContext or otherwise ExternalContextUtils.getServletContextPath() needs to return a dummy value when running surefire tests.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (TRINIDAD-1506) ClassCastException during surefire tests when calling ExternalContextUtils.getServletContextPath()

Posted by "Andrew Robinson (JIRA)" <de...@myfaces.apache.org>.
     [ https://issues.apache.org/jira/browse/TRINIDAD-1506?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrew Robinson resolved TRINIDAD-1506.
---------------------------------------

       Resolution: Fixed
    Fix Version/s:  1.2.12-core

> ClassCastException during surefire tests when calling ExternalContextUtils.getServletContextPath()
> --------------------------------------------------------------------------------------------------
>
>                 Key: TRINIDAD-1506
>                 URL: https://issues.apache.org/jira/browse/TRINIDAD-1506
>             Project: MyFaces Trinidad
>          Issue Type: Bug
>    Affects Versions:  1.2.11-core
>            Reporter: Matt Cooper
>            Priority: Minor
>             Fix For:  1.2.12-core
>
>
> If you have a renderer that makes a call like this:
> ExternalContextUtils.getServletContextPath(context.getExternalContext());
> Then, when running a surefire test for a component that uses such a renderer, a ClassCastException will be thrown where some underlying code is expecting a javax.servlet.ServletContext however, a org.apache.myfaces.trinidadinternal.renderkit.MApplication is provided instead.  Perhaps MApplication needs to implement/extend ServletContext or otherwise ExternalContextUtils.getServletContextPath() needs to return a dummy value when running surefire tests.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (TRINIDAD-1506) ClassCastException during surefire tests when calling ExternalContextUtils.getServletContextPath()

Posted by "Andrew Robinson (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/TRINIDAD-1506?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12719910#action_12719910 ] 

Andrew Robinson commented on TRINIDAD-1506:
-------------------------------------------

Matt, do you have the stack trace of that exception by any chance?

> ClassCastException during surefire tests when calling ExternalContextUtils.getServletContextPath()
> --------------------------------------------------------------------------------------------------
>
>                 Key: TRINIDAD-1506
>                 URL: https://issues.apache.org/jira/browse/TRINIDAD-1506
>             Project: MyFaces Trinidad
>          Issue Type: Bug
>    Affects Versions:  1.2.11-core
>            Reporter: Matt Cooper
>            Priority: Minor
>
> If you have a renderer that makes a call like this:
> ExternalContextUtils.getServletContextPath(context.getExternalContext());
> Then, when running a surefire test for a component that uses such a renderer, a ClassCastException will be thrown where some underlying code is expecting a javax.servlet.ServletContext however, a org.apache.myfaces.trinidadinternal.renderkit.MApplication is provided instead.  Perhaps MApplication needs to implement/extend ServletContext or otherwise ExternalContextUtils.getServletContextPath() needs to return a dummy value when running surefire tests.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.