You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Michael Heinen <mh...@recommind.com> on 2007/02/28 19:53:18 UTC

invoke JSP page from servlet - IllegalArgumentException

I want to forward a request from a servlet to a JSF page but I don't get
it working.

I read the article InvokingJsfPagesWithStandardUrls in the WIKI
(http://wiki.apache.org/myfaces/InvokingJsfPagesWithStandardUrls?highlig
ht=%28link%29%7C%28jsf%29)

but I get always following Exception:

java.lang.IllegalArgumentException: could not find pathMapping for
servletPath = /servlet/trustedlogin requestPathInfo = null

                at
org.apache.myfaces.tomahawk.application.jsp.JspTilesViewHandlerImpl.getS
ervletMapping(JspTilesViewHandlerImpl.java:288)

                at
org.apache.myfaces.tomahawk.application.jsp.JspTilesViewHandlerImpl.rend
erView(JspTilesViewHandlerImpl.java:120)

                at
org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.
java:101)

                at
org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.j
ava:221)

                at
org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:384
)

                ...

 

There must be something wrong with my mappings, or ?

 

Web.xml snippets:

<context-param>

  <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>

 
<param-value>org.apache.myfaces.tomahawk.application.jsp.JspTilesViewHan
dlerImpl</param-value>

</context-param>

 

  <servlet-mapping>

    <servlet-name>Faces Servlet</servlet-name>

    <url-pattern>/faces/*</url-pattern>

  </servlet-mapping>

  

  <servlet-mapping>

    <servlet-name>TrustedLoginServlet</servlet-name><!-- The
NonFacesRequestServlet-->

    <url-pattern>/servlet/trustedlogin</url-pattern>

  </servlet-mapping> 

 

snippets in faces config:

<navigation-rule>

  <from-view-id>*</from-view-id>

  <navigation-case>

    <from-outcome>success</from-outcome>

    <to-view-id>/startpage.jsp</to-view-id>

  </navigation-case>

</navigation-rule>

 

Servlet:

  protected void forward(HttpServletRequest request, HttpServletResponse
response, String outcome,

      String comeFrom)

  {

    LifecycleFactory lFactory = (LifecycleFactory)
FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);

    Lifecycle lifecycle =
lFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);

    FacesContextFactory fcFactory = (FacesContextFactory) FactoryFinder

        .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);

    FacesContext facesContext =
fcFactory.getFacesContext(getServletContext(), request, response,
lifecycle);

    Application application = facesContext.getApplication();

    ViewHandler viewHandler = application.getViewHandler();

    

    if (comeFrom == null)

    {

      comeFrom = "";

    }

    UIViewRoot view = viewHandler.createView(facesContext, comeFrom);

    facesContext.setViewRoot(view);

 

    NavigationHandler navigationHandler =
application.getNavigationHandler();

    navigationHandler.handleNavigation(facesContext, null, "success");

    lifecycle.render(facesContext);

  }

 

I use:

myFacesCore 1.1.4          

tomahawk snapshot 1.1.4

tiles

a4j 1.0.6

 

Any help is appreciated,

Michael


Re: invoke JSP page from servlet - IllegalArgumentException

Posted by Volker Weber <v....@inexso.de>.
Hi,

i don't know if it makes a difference, but the code from the wiki is
suposed to be in the service() method of the servlet. As it is in
http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/servlet/NonFacesRequestServlet.java?view=markup

Regards,
  Volker

2007/2/28, Michael Heinen <mh...@recommind.com>:
>
>
>
>
> I want to forward a request from a servlet to a JSF page but I don't get it
> working.
>
> I read the article InvokingJsfPagesWithStandardUrls in the
> WIKI
> (http://wiki.apache.org/myfaces/InvokingJsfPagesWithStandardUrls?highlight=%28link%29%7C%28jsf%29)
>
> but I get always following Exception:
>
> java.lang.IllegalArgumentException: could not find
> pathMapping for servletPath = /servlet/trustedlogin requestPathInfo = null
>
>                 at
> org.apache.myfaces.tomahawk.application.jsp.JspTilesViewHandlerImpl.getServletMapping(JspTilesViewHandlerImpl.java:288)
>
>                 at
> org.apache.myfaces.tomahawk.application.jsp.JspTilesViewHandlerImpl.renderView(JspTilesViewHandlerImpl.java:120)
>
>                 at
> org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:101)
>
>                 at
> org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:221)
>
>                 at
> org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:384)
>
>                 ...
>
>
>
> There must be something wrong with my mappings, or ?
>
>
>
> Web.xml snippets:
>
> <context-param>
>
>   <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
>
>
> <param-value>org.apache.myfaces.tomahawk.application.jsp.JspTilesViewHandlerImpl</param-value>
>
> </context-param>
>
>
>
>   <servlet-mapping>
>
>     <servlet-name>Faces Servlet</servlet-name>
>
>     <url-pattern>/faces/*</url-pattern>
>
>   </servlet-mapping>
>
>
>
>   <servlet-mapping>
>
>     <servlet-name>TrustedLoginServlet</servlet-name><!--
> The NonFacesRequestServlet-->
>
>     <url-pattern>/servlet/trustedlogin</url-pattern>
>
>   </servlet-mapping>
>
>
>
> snippets in faces config:
>
> <navigation-rule>
>
>   <from-view-id>*</from-view-id>
>
>   <navigation-case>
>
>     <from-outcome>success</from-outcome>
>
>     <to-view-id>/startpage.jsp</to-view-id>
>
>   </navigation-case>
>
> </navigation-rule>
>
>
>
> Servlet:
>
>   protected void forward(HttpServletRequest request, HttpServletResponse
> response, String outcome,
>
>       String comeFrom)
>
>   {
>
>     LifecycleFactory lFactory = (LifecycleFactory)
> FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
>
>     Lifecycle lifecycle =
> lFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
>
>     FacesContextFactory fcFactory = (FacesContextFactory) FactoryFinder
>
>         .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
>
>     FacesContext facesContext =
> fcFactory.getFacesContext(getServletContext(), request, response,
> lifecycle);
>
>     Application application = facesContext.getApplication();
>
>     ViewHandler viewHandler = application.getViewHandler();
>
>
>
>     if (comeFrom == null)
>
>     {
>
>       comeFrom = "";
>
>     }
>
>     UIViewRoot view = viewHandler.createView(facesContext, comeFrom);
>
>     facesContext.setViewRoot(view);
>
>
>
>     NavigationHandler navigationHandler =
> application.getNavigationHandler();
>
>     navigationHandler.handleNavigation(facesContext, null,
> "success");
>
>     lifecycle.render(facesContext);
>
>   }
>
>
>
> I use:
>
> myFacesCore 1.1.4
>
> tomahawk snapshot 1.1.4
>
> tiles
>
> a4j 1.0.6
>
>
>
> Any help is appreciated,
>
> Michael