0 0

jetty HTTP ERROR: 5035

我输入地址: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);
}

}


  小弟,遇到这问题迟迟不能解决,待解决!

问题补充:
myali88 写道
你写一个嵌入式Jetty容器干嘛,你的ssh应用也是运行在嵌入式jetty容器里面的吗?既然“Service Unavailable ”,说明你的ssh应用有问题,启动过程可能就有错误了,把日志级别调高,看看启动过程有什么错误。



我在tomcat下运行ssh应用是没有问题的,但不知道为什么在Jetty下报这个错!

问题补充:
AngelAndAngel 写道
启动路径和tomcat是不同的 这个你得仔细检查一下


哦,确实启动的时候报错了!

2011-08-24 10:34:22.799:INFO::jetty-7.2.2.v20101205
2011-08-24 10:34:28.665:WARN::FAILED org.eclipse.jetty.security.ConstraintSecurityHandler@17ec9f7: java.lang.IllegalStateException: No LoginService for org.eclipse.jetty.security.authentication.BasicAuthenticator@3b1f38 in org.eclipse.jetty.security.ConstraintSecurityHandler@17ec9f7
2011-08-24 10:34:28.665:WARN::FAILED org.eclipse.jetty.server.session.SessionHandler@fd918a: java.lang.IllegalStateException: No LoginService for org.eclipse.jetty.security.authentication.BasicAuthenticator@3b1f38 in org.eclipse.jetty.security.ConstraintSecurityHandler@17ec9f7
2011-08-24 10:34:28.665:WARN::Failed startup of context o.e.j.w.WebAppContext{/,file:/E:/workspace/sms/WebRoot/}
java.lang.IllegalStateException: No LoginService for org.eclipse.jetty.security.authentication.BasicAuthenticator@3b1f38 in org.eclipse.jetty.security.ConstraintSecurityHandler@17ec9f7
at org.eclipse.jetty.security.authentication.LoginAuthenticator.setConfiguration(LoginAuthenticator.java:45)
at org.eclipse.jetty.security.SecurityHandler.doStart(SecurityHandler.java:335)
at org.eclipse.jetty.security.ConstraintSecurityHandler.doStart(ConstraintSecurityHandler.java:228)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:93)
at org.eclipse.jetty.server.handler.ScopedHandler.doStart(ScopedHandler.java:97)
at org.eclipse.jetty.server.session.SessionHandler.doStart(SessionHandler.java:114)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:93)
at org.eclipse.jetty.server.handler.ScopedHandler.doStart(ScopedHandler.java:97)
at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:630)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:228)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1181)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:584)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:496)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:93)
at org.eclipse.jetty.server.Server.doStart(Server.java:243)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at util.OneWebAppUnassembled.main(OneWebAppUnassembled.java:21)


现在无法定位是什么问题!



问题补充:
myali88 写道
FAILED org.eclipse.jetty.security.ConstraintSecurityHandler@17ec9f7: java.lang.IllegalStateException: No LoginService for 

问题在这里。你可以试试下面的代码:
Server server = new Server();
 
SocketConnector connector = new SocketConnector();
// Set some timeout options to make debugging easier.
connector.setMaxIdleTime(1000 * 60 * 60);
connector.setSoLingerTime(-1);
connector.setPort(PORT);
server.addConnector(connector);
 
WebAppContext webAppCtx = new WebAppContext();
webAppCtx.setServer(server);
webAppCtx.setContextPath("/");
webAppCtx.setWar("src/main/webapp");
 
HashLoginService dummyLoginService = new HashLoginService(
  "TEST-SECURITY-REALM");
webAppCtx.getSecurityHandler().setLoginService(dummyLoginService);
 
server.setHandler(webAppCtx);
 
try {
 server.start();
 System.in.read();
 server.stop();
 server.join();
} catch (Exception e) {
 e.printStackTrace();
 System.exit(100);
}



非常感谢!采用的你的程序问题解决了!

2011年8月23日 11:22

5个答案 按时间排序 按投票排序

0 0

采纳的答案

FAILED org.eclipse.jetty.security.ConstraintSecurityHandler@17ec9f7: java.lang.IllegalStateException: No LoginService for 

问题在这里。你可以试试下面的代码:
Server server = new Server();
 
SocketConnector connector = new SocketConnector();
// Set some timeout options to make debugging easier.
connector.setMaxIdleTime(1000 * 60 * 60);
connector.setSoLingerTime(-1);
connector.setPort(PORT);
server.addConnector(connector);
 
WebAppContext webAppCtx = new WebAppContext();
webAppCtx.setServer(server);
webAppCtx.setContextPath("/");
webAppCtx.setWar("src/main/webapp");
 
HashLoginService dummyLoginService = new HashLoginService(
  "TEST-SECURITY-REALM");
webAppCtx.getSecurityHandler().setLoginService(dummyLoginService);
 
server.setHandler(webAppCtx);
 
try {
 server.start();
 System.in.read();
 server.stop();
 server.join();
} catch (Exception e) {
 e.printStackTrace();
 System.exit(100);
}

2011年8月24日 10:53
0 0

我觉得应该你在启动的时候是不是调用了什么方法 是多次调用的。

比如在我曾经在jsp里面两次调用response.sendRedirct。
或则你调用了 response.getOutputStream()然后又调用response.getWriter(),也会出现这中情况 lz细心看一下。

2011年8月24日 10:43
0 0

启动路径和tomcat是不同的 这个你得仔细检查一下

2011年8月23日 16:09
0 0

引用
我在tomcat下运行ssh应用是没有问题的,但不知道为什么在Jetty下报这个错!

你调高日志级别,看看什么错误!

2011年8月23日 16:00
0 0

你写一个嵌入式Jetty容器干嘛,你的ssh应用也是运行在嵌入式jetty容器里面的吗?既然“Service Unavailable ”,说明你的ssh应用有问题,启动过程可能就有错误了,把日志级别调高,看看启动过程有什么错误。

2011年8月23日 12:25

相关推荐

    jetty-http-9.4.11.v20180605-API文档-中英对照版.zip

    赠送jar包:jetty-http-9.4.11.v20180605.jar; 赠送原API文档:jetty-http-9.4.11.v20180605-javadoc.jar; 赠送源代码:jetty-http-9.4.11.v20180605-sources.jar; 赠送Maven依赖信息文件:jetty-...

    javax.servlet-3.0.0.v201112011016-API文档-中文版.zip

    Maven坐标:org.eclipse.jetty.orbit:javax.servlet:3.0.0.v201112011016; 标签:eclipse、jetty、orbit、javax、servlet、中文文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”...

    javax.servlet-3.0.0.v201112011016-API文档-中英对照版.zip

    Maven坐标:org.eclipse.jetty.orbit:javax.servlet:3.0.0.v201112011016; 标签:eclipse、jetty、orbit、javax、servlet、中英对照文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html...

    jetty-sslengine-6.1.26-API文档-中文版.zip

    赠送jar包:jetty-sslengine-6.1.26.jar; 赠送原API文档:jetty-sslengine-6.1.26-javadoc.jar; 赠送源代码:jetty-sslengine-6.1.26-sources.jar; 赠送Maven依赖信息文件:jetty-sslengine-6.1.26.pom; 包含...

    jetty-client-9.4.11.v20180605-API文档-中文版.zip

    赠送jar包:jetty-client-9.4.11.v20180605.jar; 赠送原API文档:jetty-client-9.4.11.v20180605-javadoc.jar; 赠送源代码:jetty-client-9.4.11.v20180605-sources.jar; 赠送Maven依赖信息文件:jetty-client-...

    jetty-http-9.4.43.v20210629-API文档-中英对照版.zip

    赠送jar包:jetty-http-9.4.43.v20210629.jar; 赠送原API文档:jetty-http-9.4.43.v20210629-javadoc.jar; 赠送源代码:jetty-http-9.4.43.v20210629-sources.jar; 赠送Maven依赖信息文件:jetty-...

    jetty-security-9.3.19.v20170502-API文档-中文版.zip

    赠送jar包:jetty-security-9.3.19.v20170502.jar; 赠送原API文档:jetty-security-9.3.19.v20170502-javadoc.jar; 赠送源代码:jetty-security-9.3.19.v20170502-sources.jar; 赠送Maven依赖信息文件:jetty-...

    jetty8.1.rar 最新版本

    jetty8.1.rar 最 新 版 本

    jetty 9.4.9

    jetty 9.4.9, jetty 容器是轻便型容器,启动速度的确可以 ,附带有servlet-api.jar 和jsp-api.jar 两个jar包

    jetty-jsp-8.1.8.v20121106.jar

    jetty-jsp-8.1.8.v20121106.jar

    grails-jetty-example:使用Jetty而不是Tomcat的示例Grails 4 Web应用程序

    Grails Jetty示例应用程序这是一个使用Jetty而不是Tomcat的示例Grails Web应用程序。 为了运行该应用程序,请按照以下说明进行操作: 打开命令行,然后导航到项目目录/文件夹。 使用./gradlew bootWar任务构建WAR。 ...

    jetty-http-9.3.19.v20170502-API文档-中文版.zip

    赠送jar包:jetty-http-9.3.19.v20170502.jar; 赠送原API文档:jetty-http-9.3.19.v20170502-javadoc.jar; 赠送源代码:jetty-http-9.3.19.v20170502-sources.jar; 赠送Maven依赖信息文件:jetty-...

    jetty-io-9.4.43.v20210629-API文档-中英对照版.zip

    赠送jar包:jetty-io-9.4.43.v20210629.jar; 赠送原API文档:jetty-io-9.4.43.v20210629-javadoc.jar; 赠送源代码:jetty-io-9.4.43.v20210629-sources.jar; 赠送Maven依赖信息文件:jetty-io-9.4.43.v20210629....

    jetty-http-9.4.8.v20171121-API文档-中文版.zip

    赠送jar包:jetty-http-9.4.8.v20171121.jar; 赠送原API文档:jetty-http-9.4.8.v20171121-javadoc.jar; 赠送源代码:jetty-http-9.4.8.v20171121-sources.jar; 赠送Maven依赖信息文件:jetty-...

    jetty-http-9.4.43.v20210629-API文档-中文版.zip

    赠送jar包:jetty-http-9.4.43.v20210629.jar; 赠送原API文档:jetty-http-9.4.43.v20210629-javadoc.jar; 赠送源代码:jetty-http-9.4.43.v20210629-sources.jar; 赠送Maven依赖信息文件:jetty-...

    jetty-saml:Jetty 的最小 SAML 2.0 SP 实现

    它是一个最小的实现,除了 JVM 和 Jetty 之外没有任何外部依赖。 此扩展已使用 Windows Azure Active Directory ( ) 作为 Windows Azure 设置 创建 Azure 帐户。 注册帐户后,一个 Active Directory 实例将可用。 ...

    jetty-util-9.4.43.v20210629-API文档-中文版.zip

    赠送jar包:jetty-util-9.4.43.v20210629.jar; 赠送原API文档:jetty-util-9.4.43.v20210629-javadoc.jar; 赠送源代码:jetty-util-9.4.43.v20210629-sources.jar; 赠送Maven依赖信息文件:jetty-util-9.4.43.v...

    jetty-6.1.26-API文档-中英对照版.zip

    赠送jar包:jetty-6.1.26.jar; 赠送原API文档:jetty-6.1.26-javadoc.jar; 赠送源代码:jetty-6.1.26-sources.jar; 赠送Maven依赖信息文件:jetty-6.1.26.pom; 包含翻译后的API文档:jetty-6.1.26-javadoc-API...

    jetty-6.1.26-API文档-中文版.zip

    赠送jar包:jetty-6.1.26.jar; 赠送原API文档:jetty-6.1.26-javadoc.jar; 赠送源代码:jetty-6.1.26-sources.jar; 赠送Maven依赖信息文件:jetty-6.1.26.pom; 包含翻译后的API文档:jetty-6.1.26-javadoc-API...

    jetty-http-8.1.8.v20121106-API文档-中文版.zip

    赠送jar包:jetty-http-8.1.8.v20121106.jar; 赠送原API文档:jetty-http-8.1.8.v20121106-javadoc.jar; 赠送源代码:jetty-http-8.1.8.v20121106-sources.jar; 赠送Maven依赖信息文件:jetty-...

Global site tag (gtag.js) - Google Analytics