0
votes

I've tried all what saw on stackoverflow and other forums. It's not working.

It's properly running the jsp files, but not the new facelets for xhtml pages.

I've followed the Migration from jsf1.x to 2.x thread : Migrating from JSF 1.2 to JSF 2.0

Even filter was also working in simple jsp implementation, here I tried removing filter, it's still not working. Can't figure out the error even.

Error:

exception 

javax.servlet.ServletException
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:230)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)


root cause 

java.lang.StackOverflowError
    java.net.URLStreamHandler.parseURL(Unknown Source)
    java.net.URL.<init>(Unknown Source)
    java.net.URL.<init>(Unknown Source)
    org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory.resolveURL(DefaultFaceletFactory.java:314)
    org.apache.myfaces.view.facelets.impl.DefaultFacelet.getRelativePath(DefaultFacelet.java:470)
    org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:552)
    org.apache.myfaces.view.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:240)
    org.apache.myfaces.view.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:151)
    org.apache.myfaces.view.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:59)
    org.apache.myfaces.view.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:48)
    org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:521)
    org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:575)
    org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:553)
    org.apache.myfaces.view.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:240)
    org.apache.myfaces.view.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:151)
    org.apache.myfaces.view.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:59)
    org.apache.myfaces.view.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:48)
    org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:521)
    org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:575)
    org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:553)
    org.apache.myfaces.view.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:240)
    org.apache.myfaces.view.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:151)
    org.apache.myfaces.view.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:59)
    org.apache.myfaces.view.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:48)
    org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:521)
    org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:575)
    org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:553)
    org.apache.myfaces.view.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:240)
    org.apache.myfaces.view.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:151)
    org.apache.myfaces.view.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:59)
    org.apache.myfaces.view.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:48)
    org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:521)
    org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:575)
    org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:553)
    org.apache.myfaces.view.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:240)
    org.apache.myfaces.view.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:151)
    org.apache.myfaces.view.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:59)
    org.apache.myfaces.view.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:48)
    org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:521)
    org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:575)

web.xml

  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.faces</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>

</web-app>

home.xhtml

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html 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">

<body>
    <h:form>
    <center>

    <h:outputText value="#{loginMB.username}"></h:outputText>

    <h1>Welcome <h:outputText value="#{teamMB.teamHeadUsername}"></h:outputText></h1>
    <h:outputLink value="./login.jsf">Login as Team Admin</h:outputLink><br></br><br></br>
    <h:outputLink value="./registerteam.jsf" >Register your Team</h:outputLink><br></br><br></br>
    <h:outputLink value="./header.jsf">Header</h:outputLink><br></br><br></br>
    <h:outputLink value="./secure/dashboard.jsf">Dashboard</h:outputLink>

        </center>   
    </h:form>

</body>

<ui:composition template="">
    <ui:define name="header">
        Add your header here or delete to use the default
    </ui:define>
    <ui:define name="content">
        Add your content here or delete to use the default
    </ui:define>
    <ui:define name="footer">
        Add your footer here or delete to use the default
    </ui:define>
</ui:composition>
</html>
2
@BalusC , If you can please help me out. ThanksSachin

2 Answers

0
votes

Resolved it myself. Had to completely empty faces-config.xml file, which previously was filled with managedBeans.

And also in xhtml file ui:composition tag is deleted, I think this was the main issue.

0
votes

I had the same problem. Upon investigating, I found out that the problem as you mentioned was with the ui:composition tag. The reason it gave that error was that there was no template file defined. Once I defined one, it worked okay.