tags:

views:

1099

answers:

2

Hello

I've a JSF app deploying from Eclipse Ganymede through Tomcat 6. The latter suggests JSP 2.0. I'm using Sun RI JSF implementation and RichFaces 3.3.2SR1.

My index.jsp file on request from the browser causes this error to the console:

05-Mar-2010 12:04:41 org.apache.catalina.core.ApplicationDispatcher invoke SEVERE: Servlet.service() for servlet jsp threw exception org.apache.jasper.JasperException: /index.jsp(35,41) #{..} is not allowed in template text ...

OK, I've seen various other posts on this subject including incompatibilities of versions of the various jars/taglibs/syntaxes etc.

The index.jsp is called using http://localhost:8989/myapp/index.jsf (or .jsp - gives the same error), and contains

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"&gt;

which should be alright as facelets is in Mojarra 2.0.2FCS which I'm using. I seem to have to use the above syntax rather than eg. <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%> as the facelets URI causes Eclipse to say Cannot find the tag library descriptor for "http://java.sun.com/jsf/facelets".

Is my problem to do with the way I'm listing these tags?

My Ant build file refers to these Tomcat jars:

    <fileset dir="${cliTomcatlib}">
        <include name="servlet-api.jar" />
        <include name="jsp-api.jar" />
    </fileset>

so I'm stumped as to how I can get round this error. It feels like it would be a simple fix but as I'm using latest jars that should be compatible with JSP 2.0, I'm wondering why I'm getting this error. JSF

EDIT In response to BalusC's wisdom, I corrected two references to external jsp files and renamed all .jsp to .xhtml. I remembered to also update my faces-config.xml.

Redeploying now errors with a large and repeating error when the index.xhtml is requested like this:

05-Mar-2010 13:29:26 org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet Faces Servlet threw exception
java.lang.StackOverflowError
    at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:824)
    at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:216)
    at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:544)
...
    at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:216)
    at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:544)
    at com.sun.faces.context.ExternalContextImpl.getSession(ExternalContextImpl.java:151)
    at javax.faces.application.ViewHandler.calculateCharacterEncoding(ViewHandler.java:242)
    at javax.faces.application.ViewHandler.initView(ViewHandler.java:458)
    at com.sun.faces.application.view.MultiViewHandler.initView(MultiViewHandler.java:106)
    at org.ajax4jsf.application.ViewHandlerWrapper.initView(ViewHandlerWrapper.java:128)
    at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:109)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)

which I admit isn't very illuminatory other than the first few lines of the stack trace are repeated so many times I had to change the console buffer on Eclipse. I'd be overflowing with gratitude if anyone has seen this before.

Mark

A: 

Add JSF impl jars to Tomcat's lib or your app lib and try again.
See this for more.

Padmarag
Tomcat doesn't ship with any JSF impl (unless the OP unnecessarily put them there, indeed).
BalusC
Thanks for pointing out. I mostly work with GlassFish and JBoss.
Padmarag
+2  A: 
org.apache.jasper.JasperException: /index.jsp(35,41) #{..} is not allowed in template text 

Unified EL is indeed not allowed in template text in JSP. It's only allowed in Facelets.

The index.jsp is called using http://localhost:8989/myapp/index.jsf (or .jsp - gives the same error) and contains

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
     xmlns:ui="http://java.sun.com/jsf/facelets"

You're mixing up JSP with Facelets. You can and should not to that. Those are two distinct view technologies. Use the one or other. JSP is for the <%@taglib %> stuff and Facelets is XHTML oriented with <html xmlns> and <ui:xxx> stuff. For JSF 2.0 you're supposed to use Facelets. Rename all files from *.jsp to *.xhtml and replace and get rid of any <% %> and <jsp:xxx> stuff.

To learn more about Facelets, start here in the Java EE 6 tutorial part II chapter 5. If you'd like to fall back to the ancient JSP instead of Facelets for JSF 2.0, then you'll need to reconfigure the view handler in JSF.

Apart from the problem, Tomcat 6.0 is by the way JSP 2.1, not JSP 2.0.

Update: the StackOverflowError on getSession() indicates an infinite recursion in the servlet/filter mappings. How is your FacesServlet mapped? It should be mapped to listen on an url-pattern of *.jsf, not *.xhtml. Otherwise it will call itself recursively. Please consult/refer the JSF 2.0 books/tutorials/documentation closely how to configure it properly.

BalusC
BalusC, see my question update. Thanks for your help on this one.
Mark Lewis
The key words in this answer are 'consult', 'documentation', 'configure' and 'properly'. Thanks goes to BalusC for the slap.
Mark Lewis