java代码如下
import java.util.HashMap;
import java.util.Map;
import javax.faces.webapp.FacesServlet;
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.bio.SocketConnector;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.DefaultServlet;
import org.mortbay.jetty.servlet.ServletHolder;
import org.springframework.web.context.ContextLoaderListener;
import com.sun.faces.config.ConfigureListener;
public class JettyStart {
public static void main(String arg[]) {
Server server = new Server();
Connector connector = new SocketConnector();
connector.setPort(80);
server.addConnector(connector);
Map<String, String> initParams = new HashMap<String, String>();
initParams.put("contextConfigLocation", "/WEB-INF/web-application-config.xml");
initParams.put("javax.faces.DEFAULT_SUFFIX", ".xhtml");
initParams.put("facelets.DEVELOPMENT", "true");
initParams.put("facelets.REFRESH_PERIOD", "1");
initParams.put("com.sun.faces.expressionFactory", "org.jboss.el.ExpressionFactoryImpl");
ContextLoaderListener contextLoaderListener = new ContextLoaderListener();
ConfigureListener configureListener = new ConfigureListener();
Context context = new Context(server, "/jsf", Context.SESSIONS);
context.setInitParams(initParams);
context
.setResourceBase("E:/sources/spring/spring-webflow-2.0.5.RELEASE/projects/spring-webflow-samples/jsf-booking/src/main/webapp");
context.addEventListener(contextLoaderListener);
//没有这个监听的话 就会报错Application was not properly initialized at startu
context.addEventListener(configureListener);
ServletHolder holder = new ServletHolder(new FacesServlet());
context.addServlet(holder, "*.faces");
holder = new ServletHolder(new DefaultServlet());
context.addServlet(holder, "*.html");
try {
server.start();
server.join();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
以上ConfigureListener configureListener = new ConfigureListener();这个监听是必须的,ConfigureListener 是jboss和spring对jsf的一个实现,在myface中实现为StartupServletContextListener这个类。
如果不使用jetty手动加载的话,在web.xml中定义为
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
在没有添加ConfigureListener 监听的时候就会报下面的错误:
2009-05-05 23:28:37.062:/jsf:WARN: unavailable
java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.context.FacesContextFactory
at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:725)
at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:239)
at javax.faces.webapp.FacesServlet.init(FacesServlet.java:164)
at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:431)
at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:263)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:667)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.jetty.Server.doStart(Server.java:222)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at JettyStart.main(JettyStart.java:53)
2009-05-05 23:28:37.078::INFO: Started SocketConnector@0.0.0.0:80
分享到:
相关推荐
(DBX Error: Driver could not be properly initialized. Client library may be missing, not installed properly, ...),我找到了合适的libmysql.dll和dbxmys.dll组合,把下面这个libmysql.dll拷贝到XE的bin目录...
https用到的两个dll 是win64下的
在64位机器上使用plSQL连接Oracle的问题(SQLNet not properly installed)
swt资源释放问题,详细介绍swt如何释放屏幕资源
Oracle 回收站功能,彻底删除表ORA-00933:SQL command not properly ended,由于删除触发器引起的。数据交换不能再建触发器。
visualroute 2010 在使用eclvr14c进行破解时,提示"VisualRoute is not installed properly ",经本人多次跟踪实践发现问题在缺少文件上: 检查安装完后在C:\Documents and Settings\Administrator\下是否有mswin32v16....
resin-pro-3.1.3配置ssl ssleay32.dll ... com.caucho.config.ConfigException: SSL JNI was not properly initialized. Make sure the resinssl library is properly created and the SSL libraries
我们的日常中使用python写程序时累积些常见的报错,熟悉报错种类能快速解决方法
解决浏览器出现Ming-WebReport viewer has not been installed properly.的问题,按压缩包步骤操作!保证能解决问题!!!
由于公司业务并发比较高需要高可用使用LVS keeplived。在linux系统centos6.5版本中安装keeplived时,需要... OpenSSL is not properly installed on your system. !!! !!! Can not include OpenSSL headers files. !!!
Launch and wait application to end (8KB)
DLL: For the MPC560xx devices, the ECC SRAM was not initialized after connect. Fixed. DLL: Hilscher NetX90 flash bank size, fixed. DLL: Infineon TLE98xx: Some J-Link LITEs could not connect establish ...
+ The help file was not terminated when CurveExpert was. Fixed. + The Window and Help menus were moved to more conventional positions on the menu bar. Nov. 4, 1995, v. 1.10: ================...
Wireless Application Protocol (WAP) 15 Proprietary Mobile Platforms 17 The Open Handset Alliance 18 Google Goes Wireless 18 Forming the Open Handset Alliance 19 Manufacturers: Designing Android ...
DBX Error: Driver could not be properly initialized. Client library may be missing, not installed properly, of the wrong version, or the driver maybe be missing from the system path...
Dual-GPU cards such as the 7990 will not work properly at higher pixel clocks. Compatibility: Version 1.4.12 is compatible with Catalyst 11.9 to Adrenalin 22.4.1. It can be used with future versions ...
To make sure you have confidence at every stage in the process, the book also shows you how to release your app to the Play store to make sure your maximising your efforts to create a popular Android ...
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.6.0_10\bin;C:\Program ...
解决浏览器报表插件安装问题。Ming-WebReport viewer has not been installed properly.
Stride is not properly defined yet, default to 0x10 for Axon.