Unable to use myfaces without jsf-api.jar and jsf-impl.jar

I'm new to JSF and would like a few pointers to get started. After downloading the examples, I saw no reference to jsf-api.jar and jsf-impl.jar in WEB-INF/lib, which is what the myfaces website tutorial suggests. However, I'm unable to use myfaces-api-1.1.5.jar and myfaces-impl-1.1.5.jar in my web application without jsf-api.jar and jsf-impl.jar. I'm currently using Eclipse with Tomcat 5.5.x integrated into the development environment. When jsf-api.jar and jsf-impl.jar are not in my WEB-INF/lib, starting Tomcat would get me this error:

pr 24, 2007 7:23:27 PM org.apache.catalina.core.StandardContext listenerStart

SEVERE: Error configuring application listener of class com.sun.faces.config.ConfigureListener

java.lang.ClassNotFoundException: com.sun.faces.config.ConfigureListener

at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1355)

at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1201)

at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3711)

at org.apache.catalina.core.StandardContext.start(StandardContext.java:4211)

at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)

at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)

at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)

at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)

at org.apache.catalina.core.StandardService.start(StandardService.java:450)

at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)

at org.apache.catalina.startup.Catalina.start(Catalina.java:551)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)

at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)

With both of them in WEB-INF/lib, I don't get any problems. What do I need to do to make this work solely with myfaces libraries?

[2272 byte] By [bai13ysa] at [2007-11-27 2:14:23]
# 1
I most likely means:A. You have a reference to the ConfigureListener in your web.xmlor B. You need to delete everything under the work directory afteryou change JSF libraries
rlubkea at 2007-7-12 2:10:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

First, please take a look at my web.xml:

<?xml version="1.0"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"

version="2.4">

<context-param>

<param-name>javax.faces.CONFIG_FILES</param-name>

<param-value>

/WEB-INF/faces-config.xml

</param-value>

</context-param>

<context-param>

<param-name>javax.faces.STATE_SAVING_METHOD</param-name>

<param-value>client</param-value>

</context-param>

<context-param>

<param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>

<param-value>true</param-value>

</context-param>

<context-param>

<param-name>org.apache.myfaces.PRETTY_HTML</param-name>

<param-value>true</param-value>

</context-param>

<context-param>

<param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>

<param-value>false</param-value>

</context-param>

<context-param>

<param-name>org.apache.myfaces.AUTO_SCROLL</param-name>

<param-value>true</param-value>

</context-param>

<!-- Tiles -->

<context-param>

<param-name>tiles-definitions</param-name>

<param-value>/WEB-INF/tiles-def.xml</param-value>

</context-param>

<!-- Listener, that does all the startup work (configuration, init). -->

<listener>

<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>

</listener>

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

<!-- Welcome files -->

<welcome-file-list>

<welcome-file>index.jsp</welcome-file>

</welcome-file-list>

<filter>

<filter-name>MyFacesExtensionsFilter</filter-name>

<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>

<init-param>

<param-name>maxFileSize</param-name>

<param-value>10k</param-value>

<description>Set the size limit for uploaded files.

Format: 10 - 10 bytes

10k - 10 KB

10m - 10 MB

1g - 1 GB

</description>

</init-param>

</filter>

<filter-mapping>

<filter-name>MyFacesExtensionsFilter</filter-name>

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

</filter-mapping>

<filter-mapping>

<filter-name>MyFacesExtensionsFilter</filter-name>

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

</filter-mapping>

</web-app>

You can see that I only referenced one listener:

<listener><listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>

</listener>

Second, I tried deleting everything in the WEB-INF/lib directory and compile again. This time it gives the same ClassNotFoundException and asks me for the StartupServletContextListener, which is what it should look for. So I copied myfaces-api-1.1.5.jar and myfaces-impl-1.1.5.jar into the directory, and again it gave:

java.lang.ClassNotFoundException: com.sun.faces.config.ConfigureListener

Third, I checked my Tomcat common/lib directory to see if there are any references to JSF and I did not find any.

Fourth, I verified that my faces-config.xml file uses the 1.1 Config instead of the 1.0 Config:

<!DOCTYPE faces-config PUBLIC

"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"

"http://java.sun.com/dtd/web-facesconfig_1_1.dtd">

What should I do now?

bai13ysa at 2007-7-12 2:10:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

SOLVED!

As suspected, it was an Eclipse problem! I exported the project to a WAR and deployed it manually on Tomcat and it worked like a charm.

I'm thinking Eclipse has a default mechanism of searching for com.sun.faces.config.ConfigureListener ?

Anyone have any info on this issue?

bai13ysa at 2007-7-12 2:10:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
I have exactly the same experience. Is there any workaround for the Eclipse's default mechanism? It is not handy to test every version by full deploy to servlet container.
tolarva at 2007-7-12 2:10:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...