java.lang.ClassNotFoundException: javax.faces.webapp.FacesServlet, tomcat doesn't see javaee-api-7.0-b83.jar
Asked Answered
P

4

5

I am trying to run sample guessnumber-jsf from Java EE tutorial. It is here: https://svn.java.net/svn/javaeetutorial~svn

There is no dependencies in pom.xml. So output file has no .jar file. When I try to put javaee-api-7.0-b83.jar inside tomcat/lib or WEB-INF/lib/javaee-api-7.0-b83.jar, nothing changes.

When I try to open

localhost:8080/guessnumber-jsf/faces/greeting.xhtml

I get ClassNotFoundException. Where can I get list of jars that I need for faces tutorial? How can I connect them?

Probst answered 14/4, 2013 at 18:50 Comment(1)
Why did you feel the need to use the term "J2EE", while the tutorial and even the URL clearly says "Java EE"?Seth
S
4

You can't put that Java EE jar in Tomcat and expect it to magically morph into a Java EE server.

That particular jar only contains the APIs to link against (eg "headers" in C/C++ terminology). It does not contain any implementation.

The easiest thing to do is to dish Tomcat and download TomEE instead. Optionally download GlassFish.

These will all already contain all the functionality you need and nothing will have to be put into WEB-INF/lib. (if using Maven put the Java EE 6 GAV as a dependency with scope provided in your pom).

Seth answered 15/4, 2013 at 9:17 Comment(1)
how can i add j2ee 6 gav dependency? Can you please be little more specific? ThanxProbst
S
4

If you are using a Maven project you can fix this error by adding the following dependency:

<dependency>
    <groupId>org.glassfish</groupId>
    <artifactId>javax.faces</artifactId>
    <version>2.2.7</version>
</dependency>
Sabina answered 19/9, 2014 at 5:46 Comment(0)
D
1

Adding to the answer of Mike Braun, the Java EE 6 GAV for the web profile is:

<dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-web-api</artifactId>
    <version>6</version>
    <scope>provided</scope>
</dependency>

Specifically note the scope: "provided". This means your Maven project will link against this, but it expects your runtime to have the implementations. For TomEE, GlassFish, JBoss AS 7.x, etc this is indeed the case.

Doubleton answered 16/4, 2013 at 7:2 Comment(0)
M
0

In your classpath (.classpath) make sure you have entry like

<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
Maurizio answered 21/7, 2013 at 10:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.