1
votes

Im trying to setup a new jsf 2 project on my tomcat 7, and i'm encountering this error upon accessing my webapp for the first time.

Any idea what the cause is ?

SEVERE: Servlet.service() for servlet [facesServlet] in context with path [/primebert] threw exception
java.lang.UnsupportedOperationException
        at javax.faces.application.Application.getResourceHandler(Application.java:287)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:404)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:306)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:383)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:288)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)
localhost.2011-03-17.log lines 244-286/286 (END) 

Here's my web.xml :

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

    <display-name>PrimeBert</display-name>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>

    <!-- location of log4j config file -->
    <context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>/WEB-INF/log4j.xml</param-value>
    </context-param>

    <!-- applies log4j configuration -->
    <listener>
        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
    </listener>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <listener>
        <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
    </listener>

    <servlet>
        <servlet-name>facesServlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>facesServlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
        <welcome-file>faces/index.xhtml</welcome-file>
    </welcome-file-list>
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <session-config>
        <session-timeout>-1</session-timeout>
    </session-config>

    <context-param>
        <param-name>facelets.FACELETS_SKIP_COMMENTS</param-name>
        <param-value>true</param-value>
    </context-param>

</web-app>

My faces-config.xml


http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" version="2.0">

<application>
    <locale-config>
        <default-locale>in</default-locale>
        <supported-locale>en</supported-locale>
    </locale-config>
    <resource-bundle>
        <base-name>my.package.messages</base-name>
        <var>msgs</var>
    </resource-bundle>
    <resource-bundle>
        <base-name>my.package.errors</base-name>
        <var>errs</var>
    </resource-bundle>
    <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>

<factory>
    <exception-handler-factory>my.package.BusinessExceptionHandlerFactory</exception-handler-factory>
</factory>


And here's my maven dependencies :


<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.1</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>javax.inject</groupId>
        <artifactId>javax.inject</artifactId>
        <version>1</version>
    </dependency>

    <!-- spring -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${org.springframework-version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${org.springframework-version}</version>
    </dependency>

    <!-- Persistence -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>${org.hibernate-version}</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>${org.hibernate-version}</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>javax.transaction</groupId>
        <artifactId>com.springsource.javax.transaction</artifactId>
        <version>1.1.0</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>9.0-801.jdbc4</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>

    <!-- logging -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.5.6</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>com.springsource.slf4j.log4j</artifactId>
        <version>1.5.6</version>
    </dependency>

    <!-- jsf api -->
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-api</artifactId>
        <version>2.1.0-b11</version>
    </dependency>

    <!-- primefaces -->
    <dependency>
        <groupId>org.primefaces</groupId>
        <artifactId>primefaces</artifactId>
        <version>2.2.1</version>
    </dependency>

    <dependency>
        <groupId>net.sf.dozer</groupId>
        <artifactId>dozer</artifactId>
        <version>5.3.1</version>
    </dependency>

    <dependency>
        <groupId>ant</groupId>
        <artifactId>ant-apache-log4j</artifactId>
        <version>1.6.5</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>javax.faces</groupId>
        <artifactId>jsf-impl</artifactId>
        <version>1.2</version>
        <type>jar</type>
        <classifier>NIGHTLY_20060227</classifier>
    </dependency>
    <dependency>
        <groupId>commons-digester</groupId>
        <artifactId>commons-digester</artifactId>
        <version>2.1</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
</dependencies>
1

1 Answers

1
votes

Found the cause of this problem. It's a dependency problem.

Before it was :

<dependency>
    <groupId>com.sun.faces</groupId>
    <artifactId>jsf-api</artifactId>
    <version>2.1.0-b11</version>
</dependency>
<dependency>
    <groupId>javax.faces</groupId>
    <artifactId>jsf-impl</artifactId>
    <version>1.2</version>
    <type>jar</type>
    <classifier>NIGHTLY_20060227</classifier>
</dependency>

It seems like the problem stems from me combining com.sun.faces and javax.faces artifacts.

The problem is solved with replacing the above with this :

<dependency>
    <groupId>javax.faces</groupId>
    <artifactId>jsf-api</artifactId>
    <version>2.0.3</version>
    <type>jar</type>
    <scope>compile</scope>
</dependency>
<dependency>
    <groupId>javax.faces</groupId>
    <artifactId>jsf-impl</artifactId>
    <version>2.0.3</version>
    <type>jar</type>
    <classifier>NIGHTLY_20060227</classifier>
    <scope>compile</scope>
</dependency>

And of course, dont forget to restart the tomcat :-)


UPDATE

Still problematic with the above's settings. The correct one is located at here, and works fine !