webtier@glassfish.java.net

Embedded Jetty with MyFaces

From: <webtier_at_javadesktop.org>
Date: Fri, 06 Nov 2009 01:19:04 PST

Hi there,

im having some trouble getting jetty to run with myfaces.
The problem that i am facing is fact that i would like to run some unit tests.

First some facts about my project
- MyFaces v1.2.7
- Jetty 6.1.9

My project is a maven project, so i have installed the maven-jetty-plugin to run jetty from the console. This works fine, so the JUnit tests (in this case i use HtmlUnit because of a web-project) run correctly with no errors.

I would like to run these tests out of eclipse (contextmenu -> debug as -> junit test) also. So i have an embedded code to run a jetty server from javasource.

[code]
public class TestServer
{
        private static Server _server;
        
        public static void startServer() throws Exception
        {
                if(_server == null)
                {
                    _server = new Server(8888);
                    WebAppContext webapp = new WebAppContext(_server, "target/yp-webapp-1.3.0-SNAPSHOT", "/yp-webapp");
                    ServletHolder facesServlet = new ServletHolder(new FacesServlet());
                    facesServlet.setInitOrder(1);
                    webapp.addServlet(facesServlet, "*.jsf");
                    _server.addHandler(webapp);
                    webapp.getServer().start();
                }
        }
}

[/code]

Before starting the tests, this class starts the server with some options.
But when it comes to [i]webapp.getServer().start();[/i] the following error appears:

[code]
java.lang.IllegalStateException: No Factories configured for this Application.
This happens if the faces-initialization does not work at all - make sure that you properly include
all configuration settings necessary for a basic faces application
and that all the necessary libs are included. Also check the logging output of your
web application and your container for any exceptions!
If you did that and find nothing, the mistake might be due to the fact that you use some
special web-containers which do not support registering context-listeners via TLD files
and a context listener is not setup in your web.xml.
A typical config looks like this;
<listener>
  <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
[/code]

Could there be some different Classpath values or something like that?
Ive tried many thing.

i hope someone knows a solution
regards.
[Message sent by forum member 'cintex' (a.froemer_at_gmx.net)]

http://forums.java.net/jive/thread.jspa?messageID=370813