Marcos Carraro
Marcos Carraro

Reputation: 136

Jetty error Primefaces war java.lang.ClassNotFoundException: javax.faces.webapp.FacesServlet

I can tray developer the minimal Jetty server, for running my application written in primefaces/java, the application compiled in file AtomicServerWeb.war

My code AtomicServer.java / AtomicServer.jar

 package atomicserver;

 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.webapp.WebAppContext;

 public class AtomicServer {

    public static void main(String[] args) throws Exception {

    //System.setProperty("org.eclipse.jetty.LEVEL", "DEBUG");
    Server server = new Server(8080);

    org.eclipse.jetty.webapp.Configuration.ClassList classlist = org.eclipse.jetty.webapp.Configuration.ClassList.setServerDefault(server);
    classlist.addAfter("org.eclipse.jetty.webapp.FragmentConfiguration", "org.eclipse.jetty.plus.webapp.EnvConfiguration", "org.eclipse.jetty.plus.webapp.PlusConfiguration");

    WebAppContext context = new WebAppContext();

    context.setWar("../../AtomicServerWeb/dist/AtomicServerWeb.war");
    context.setContextPath("/");
    context.setParentLoaderPriority(false);

    server.setHandler(context);

    server.start();
    server.join();
    }
}

Error log...

Y:\JavaSistemas\AtomicServer\dist>java -jar AtomicServer.jar
2015-10-28 13:58:54.371:INFO::main: Logging initialized @395ms
2015-10-28 13:58:55.046:INFO:oejs.Server:main: jetty-9.3.z-SNAPSHOT
2015-10-28 13:58:56.703:INFO:oejw.StandardDescriptorProcessor:main: NO JSP 
Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
2015-10-28 13:58:56.751:WARN:oejs.BaseHolder:main:
java.lang.ClassNotFoundException: javax.faces.webapp.FacesServlet

Obs. I also tried to run using the jetty-runner.jar and the mistake was this.

java -jar jetty-runner-8.1.9.v20130131.jar --port 9090 --log saida.log ../AtomicServerWeb/dist/AtomicServerWeb.war


2015-10-28 13:57:30.563:INFO:omjr.Runner:Runner
2015-10-28 13:57:30.564:WARN:omjr.Runner:No tx manager found
2015-10-28 13:57:30.753:INFO:omjr.Runner:Deploying file:/Y:/JavaSistemas/AtomicServerWeb/dist/AtomicServerWeb.war @ /
2015-10-28 13:57:31.257:INFO:oejs.Server:jetty-8.y.z-SNAPSHOT
2015-10-28 13:57:31.399:INFO:oejw.WebInfConfiguration:Extract jar:file:/Y:/JavaSistemas/AtomicServerWeb/dist/AtomicServerWeb.war!/ to C:\Users\marcos.ti.DALMOBILE\AppData\Local\Temp\jetty-0.0.0.0-9090-AtomicServerWeb.war-_-any-\webapp
2015-10-28 13:57:33.287:INFO:oejpw.PlusConfiguration:No Transaction manager found - if your webapp requires one, please configure one.
2015-10-28 13:57:35.563:WARN:oejs.Holder:
java.lang.ClassNotFoundException: javax.faces.webapp.FacesServlet

Obs2:

On my netbeans this application running using GlassFish, and I don't have problens..

Any idea?

Upvotes: 0

Views: 836

Answers (1)

Lorenz Pfisterer
Lorenz Pfisterer

Reputation: 873

You need to add following dependencies:

  • jsf-api.jar
  • jsf-impl.jar

The difference between Glassfish and Jetty is, that Glassfish is an java ee application server, which already has these dependencies. Jetty is not am application server, just a web server like tomcat, so you need to add all the needed dependencies.

If you use maven you can add the dependencies as follows:

For Mojarra Implementation of Jsf

    <!-- JSF -->
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-api</artifactId>
        <version>${jsf.version}</version>
    </dependency>
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-impl</artifactId>
        <version>${jsf.version}</version>
    </dependency>

Edit

To solve NoCLassDefFound ExpressionFactory you need to add following jar:

  • el-impl

    <dependency>
        <groupId>org.glassfish.web</groupId>
        <artifactId>el-impl</artifactId>
    <version>${el.version}</version>
    

Upvotes: 1

Related Questions