Search code examples
javarestjava-8tomcat8spark-java

RESTful service using Spark web framework on Tomcat


I want to create a restful api in Java 8 using Spark web framework version 2.6.0, JSF 2.2, Jstl 1.2 and I want to deploy it on Tomcat server 8.5.9. I have this configuration in my web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
    <filter>        
        <filter-name>SparkFilter</filter-name>
        <filter-class>spark.servlet.SparkFilter</filter-class>
        <init-param>
            <param-name>applicationClass</param-name>
            <param-value>ec.apicorreo.filtro.InicioSpark</param-value>            
        </init-param>       
    </filter>
    <filter-mapping>         
        <filter-name>SparkFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Production</param-value>
    </context-param>
    <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>*.xhtml</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
        <welcome-file>index.xhtml</welcome-file>
    </welcome-file-list>
...
...
 </web-app>

But I have this exception: javax.servlet.ServletException: Servlet execution threw an exception. And the root cause: java.lang.StackOverflowError javax.servlet.http.HttpServletResponseWrapper.setStatus(HttpServletResponseWrapper.java:201) com.sun.faces.application.ViewHandlerResponseWrapper.setStatus(ViewHandlerResponseWrapper.java:88). I don´t know what I am missing.


Solution

  • I decided to remove JSF and the problem was solved and I'm going to use views and templates from spark http://sparkjava.com/documentation.html#views-and-templates