我输入地址:http://localhost/ctc-emassh (其中ctc-emassh是项目名称,这是一个基于ssh框架开发的程序)
Problem accessing /ctc-emassh. Reason:
Service Unavailable
Powered by Jetty://
但是我写一个简单的servlet应用:login程序,程序正常执行。
//嵌入的jetty web容器程序
public class JettyWebContainer {
public Server server;
@Inject
ILog logger;
@Inject
ResourceLocator rs;
private ContextHandlerCollection handlers = new ContextHandlerCollection();
public WebAppContext newAppContext(File file) {
String appname = file.getName();
String dir = file.getAbsolutePath();
final WebAppContext context = new WebAppContext();
context.setDescriptor(dir + "/WEB-INF/web.xml");
context.setResourceBase(dir);
context.setContextPath("/" + appname);
context.setParentLoaderPriority(true);//是否与java2兼容
return context;
}
private static File[] loadAppList(File appDir) {
return appDir.listFiles(new FileFilter() {
public boolean accept(File pathname) {
return pathname.isDirectory();
}
});
}
@Start
public void start() throws Exception {
int port = 80;
logger.info("port:" + port);
server = new Server(port);
for (File appf : loadAppList(rs.getFile("webapp"))) {
addHandler(newAppContext(appf));
}
server.setHandler(handlers);
try {
server.start();
logger.info("server start ok!");
} catch (Exception e) {
logger.error(e, "server start failed!");
throw e;
}
}
@Stop
public void stop() throws Exception {
try {
server.stop();
logger.info("stop JettyWebContainer ok!");
} catch (Exception e) {
logger.error(e, "未成功关闭server");
throw e;
}
}
public void addHandler(Handler handler) {
logger.info("JettyWebContainer add handler %s", handler);
handlers.addHandler(handler);
}
public void removeHandler(Handler handler) {
logger.info("JettyWebContainer remove handler %s", handler);
handlers.removeHandler(handler);
}
}
小弟,遇到这问题迟迟不能解决,待解决!