|
|
|
|
Embedded Jetty with MyFaces
Posted:
Nov 6, 2009 1:19 AM
|
|
|
Hi there,
im have 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.
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();
}
}
}
Before starting the tests, this class starts the server with some options. But when it comes to webapp.getServer().start(); the following error appears:
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>
Could there be some different Classpath values or something like that? Ive tried many thing.
i hope someone knows a solution regards.
Message was edited by: cintex
|
|
|
|
|
|
|
Re: [webtier] Embedded Jetty with MyFaces
Posted:
Nov 6, 2009 1:31 AM
in response to: cintex
|
|
|
hi, I am currently using myfaces 1.2 with embedded jetty without any problems.
WebAppContext configure context through web.xml, so why are you trying add facesServlet manualy?
I just add WebAppContext pointed on proper directory with standard webapp structure (WEB-INF, META-INF, ...).
In web.xml I normally initialize JSF...
Dne Pá 6. listopadu 2009 10:19:04 webtier@javadesktop.org napsal(a): > 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.
-- Martin Beránek ICZ a.s. mailto:martin.beranek@i.cz http://www.i.cz
--------------------------------------------------------------------- To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net For additional commands, e-mail: webtier-help@glassfish.dev.java.net
|
|
|
|
|
|
|
|
Re: [webtier] Embedded Jetty with MyFaces
Posted:
Nov 6, 2009 1:42 AM
in response to: Martin Beránek
|
|
|
hi,
i have that webapp structure. thats the point, somehow the web.xml does not take effekt.
does the embedded code automaticly load the web.xml? or do i have to load is manually?
|
|
|
|
|
|
|
|
Re: [webtier] Embedded Jetty with MyFaces
Posted:
Nov 6, 2009 1:56 AM
in response to: cintex
|
|
|
Dne Pá 6. listopadu 2009 10:42:57 webtier@javadesktop.org napsal(a): > hi, > > i have that webapp structure. > thats the point, somehow the web.xml does not take effekt. > > does the embedded code automaticly load the web.xml? or do i have to load is manually?
it should load it automatically. i am using it like this:
Server server = new Server(8080); WebAppContext webapp = new WebAppContext("web","/"); server.setHandler(webapp); server.start();
the "web" (in my and your case) is relative path, so do you have proper working directory?
> [Message sent by forum member 'cintex' (a.froemer@gmx.net)] > > http://forums.java.net/jive/thread.jspa?messageID=370818 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net > For additional commands, e-mail: webtier-help@glassfish.dev.java.net > >
-- Martin Beránek mailto:martin.beranek@i.cz http://www.i.cz
--------------------------------------------------------------------- To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net For additional commands, e-mail: webtier-help@glassfish.dev.java.net
|
|
|
|
|
|
|
|
Re: [webtier] Embedded Jetty with MyFaces
Posted:
Nov 6, 2009 2:10 AM
in response to: Martin Beránek
|
|
|
> it should load it automatically. i am using it like > this: > > Server server = new Server(8080); > WebAppContext webapp = new WebAppContext("web","/"); > server.setHandler(webapp); > server.start(); > > the "web" (in my and your case) is relative path, so > do you have proper working directory? >
my project structure looks as follows:
yp-webapp
src
main
java
resources
webapp
WEB-INF
...
target
so i would like to run the webapp from src/main/webapp on "testing state". But even if i create a package of my project the same issue appears. (No factories configured)
|
|
|
|
|
|
|
|
Re: [webtier] Embedded Jetty with MyFaces
Posted:
Nov 10, 2009 3:49 AM
in response to: cintex
|
|
|
somebody an idea? :/
|
|
|
|
|