2012-09-25 57 views
0

我:的Java:碼頭錯誤 - 503

C:\jtty\WEB-INF\web.xml 
      | 
      | 
     classes 
      |------hello.war 
      |------HelloWord.java 
      |------HelloWord.class 
      |------javax.servlet 

首先我創建WEB-INF文件夾中的文件的web.xml:

<web-app xmlns="http://java.sun.com/xml/ns/j2ee" version="2.4" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http:/java.sun.com/dtd/web-app_2_3.dtd"> 
    <servlet> 
    <servlet-name>HelloWorldServlet</servlet-name> 
    <servlet-class>HelloWorld</servlet-class> 
    </servlet> 
    <servlet-mapping> 
    <servlet-name>HelloWorldServlet</servlet-name> 
    <url-pattern>/</url-pattern> 
    </servlet-mapping> 
</web-app> 

然後,創建文件夾 「類」,並創建文件HelloWord.java

import java.io.*; 
import javax.servlet.*; 
import javax.servlet.http.*; 


public class HelloWorld extends HttpServlet { 
    public void doGet(HttpServletRequest request, 
    HttpServletResponse response) 
    throws ServletException,IOException { 
    response.setContentType("text/html"); 
    PrintWriter pw = response.getWriter(); 
    pw.println("<html><head><title>Hello World</title></title>"); 
    pw.println("<body><h1>Hello World</h1></body></html>"); 
    } 
} 

運行此命令在Windows控制檯:

C:\ jtty \ WEB-INF \類> C:\甲骨文\爪哇\ jdk1.7.0 \ BIN \ javac的-g -classpath 「;的javax .servlet.jar。」 HelloWorld.java後-verbose

是Java的編譯器創建文件HelloWord.class

此命令創建hello.war

罐子CVF hello.war。

然後開始碼頭:

C:\jtty\WEB-INF\classes>C:\Oracle\Java\jdk1.7.0\bin\java -DDEBUG -jar c:\jetty-r 
unner-7.0.0.RC2.jar hello.war 
2012-09-25 10:23:37.765::INFO: Logging to StdErrLog::DEBUG=false via org.eclips 
e.jetty.util.log.StdErrLog 
2012-09-25 10:23:37.765::INFO: Runner 
2012-09-25 10:23:37.765::DEBUG: Runner classpath [] 
2012-09-25 10:23:37.765::WARN: No tx manager found 
2012-09-25 10:23:37.796::DEBUG: Container [email protected] 
cf + [email protected] as handler 
2012-09-25 10:23:37.796::DEBUG: Container [email protected] + ContextHa 
[email protected] as handler 
2012-09-25 10:23:37.796::DEBUG: Container [email protected] + DefaultHa 
[email protected] as handler 
2012-09-25 10:23:37.796::DEBUG: Container [email protected] + RequestLo 
[email protected] as handler 
2012-09-25 10:23:37.812::DEBUG: Container [email protected] 
cf + [email protected]:8080 as connector 
2012-09-25 10:23:37.828::DEBUG: Checking Resource aliases 
2012-09-25 10:23:37.828::INFO: Deploying file:/C:/jtty/WEB-INF/classes/hello.wa 
r @/
2012-09-25 10:23:37.843::DEBUG: Container [email protected] + We 
[email protected]@6281635b/,null as handler 
2012-09-25 10:23:37.843::DEBUG: Container [email protected]@6281635b/,null, 
file:/C:/jtty/WEB-INF/classes/hello.war + [email protected] as erro 
rHandler 
[[email protected][email protected]/,null,file:/C:/jtty/WEB-INF/classes/hello.war] 
2012-09-25 10:23:37.843::DEBUG: Starting [email protected] 
f 
2012-09-25 10:23:37.843::INFO: jetty-7.0.0.RC2 
2012-09-25 10:23:37.859::DEBUG: Container [email protected] 
cf + qtp1533090852{8<=0<=0/254,-1} as threadpool 
2012-09-25 10:23:37.859::DEBUG: Starting qtp1533090852{8<=0<=0/254,-1} 
2012-09-25 10:23:37.859::DEBUG: STARTED qtp1533090852{8<=2<=8/254,0} 
2012-09-25 10:23:37.859::DEBUG: Starting [email protected] 
2012-09-25 10:23:37.875::DEBUG: Starting [email protected] 
2012-09-25 10:23:37.875::DEBUG: Starting [email protected]@6281635b/,null,f 
ile:/C:/jtty/WEB-INF/classes/hello.war 
2012-09-25 10:23:37.875::DEBUG: Thread Context class loader is: [email protected] 
ll([])/[email protected] 
2012-09-25 10:23:37.875::DEBUG: Parent class loader is: sun.misc.Launcher$AppCla 
[email protected] 
2012-09-25 10:23:37.875::DEBUG: Parent class loader is: sun.misc.Launcher$ExtCla 
[email protected] 
2012-09-25 10:23:38.000::DEBUG: Set temp dir C:\temp\Jetty_0_0_0_0_8080_hello.wa 
r____d40q3p 
2012-09-25 10:23:38.109::DEBUG: Try webapp=file:/C:/jtty/WEB-INF/classes/hello.w 
ar, exists=true, directory=false 
2012-09-25 10:23:38.234::INFO: Extract file:/C:/jtty/WEB-INF/classes/hello.war 
to C:\temp\Jetty_0_0_0_0_8080_hello.war____d40q3p\webapp 
2012-09-25 10:23:38.343::DEBUG: Extract jar:file:/C:/jtty/WEB-INF/classes/hello. 
war!/ to C:\temp\Jetty_0_0_0_0_8080_hello.war____d40q3p\webapp 
2012-09-25 10:23:38.453::DEBUG: Extracting entry = null from jar file:/C:/jtty/W 
EB-INF/classes/hello.war 
2012-09-25 10:23:38.593::DEBUG: webapp=file:/C:/temp/Jetty_0_0_0_0_8080_hello.wa 
r____d40q3p/webapp/ 
**2012-09-25 10:23:38.718::WARN: Failed startup of context [email protected] 
@6281635b/,file:/C:/temp/Jetty_0_0_0_0_8080_hello.war____d40q3p/webapp/,file:/C: 
/jtty/WEB-INF/classes/hello.war** 
java.lang.NullPointerException 
     at org.eclipse.jetty.webapp.WebInfConfiguration.findJars(WebInfConfigura 
tion.java:588) 
     at org.eclipse.jetty.webapp.WebInfConfiguration.preConfigure(WebInfConfi 
guration.java:96) 
     at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:339 
) 
     at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLife 
Cycle.java:56) 
     at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCol 
lection.java:164) 
     at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(Con 
textHandlerCollection.java:161) 
     at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLife 
Cycle.java:56) 
     at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCol 
lection.java:164) 
     at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLife 
Cycle.java:56) 
     at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrappe 
r.java:92) 
     at org.eclipse.jetty.server.Server.doStart(Server.java:232) 
     at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLife 
Cycle.java:56) 
     at org.mortbay.jetty.runner.Runner.run(Runner.java:448) 
     at org.mortbay.jetty.runner.Runner.main(Runner.java:587) 
2012-09-25 10:23:40.390::DEBUG: STARTED [email protected]@6281635b/,file:/C 
:/temp/Jetty_0_0_0_0_8080_hello.war____d40q3p/webapp/,file:/C:/jtty/WEB-INF/clas 
ses/hello.war 
2012-09-25 10:23:40.562::DEBUG: starting [email protected] 
2012-09-25 10:23:40.625::DEBUG: STARTED [email protected] 
2012-09-25 10:23:40.671::DEBUG: Starting [email protected] 
2012-09-25 10:23:40.734::DEBUG: starting [email protected] 
2012-09-25 10:23:40.796::DEBUG: STARTED [email protected] 
2012-09-25 10:23:40.843::DEBUG: Starting [email protected] 
2012-09-25 10:23:40.906::DEBUG: starting [email protected] 
2012-09-25 10:23:40.968::DEBUG: STARTED [email protected] 
2012-09-25 10:23:41.031::DEBUG: starting [email protected] 
2012-09-25 10:23:41.078::DEBUG: STARTED [email protected] 
2012-09-25 10:23:41.140::DEBUG: starting [email protected] 
f 
2012-09-25 10:23:41.265::DEBUG: Starting [email protected]:8080 
2012-09-25 10:23:41.312::DEBUG: Starting org.eclipse.jetty.server.nio.SelectChan 
[email protected] 
2012-09-25 10:23:41.468::DEBUG: STARTED org.eclipse.jetty.server.nio.SelectChann 
[email protected] 
2012-09-25 10:23:41.593::INFO: Started [email protected]:8080 
2012-09-25 10:23:41.640::DEBUG: STARTED [email protected]:8080 
2012-09-25 10:23:41.703::DEBUG: [email protected] STOPPED 

[email protected] started 
    [email protected] started 
    | **[email protected]@6281635b/,file:/C:/temp/Jetty_0_0_0_0_8080_hello 
.war____d40q3p/webapp/,file:/C:/jtty/WEB-INF/classes/hello.war started 
    |  +-null** 
    [email protected] started 
    [email protected] started 
     +-null 

2012-09-25 10:23:42.343::DEBUG: STARTED [email protected] 

finaly我看到這一點:

http://xxx.xxx.xxx.xxx:8080/

HTTP錯誤:503

問題訪問/。原因:

Service Unavailable 

技術碼頭://

在控制檯日誌:

2012年9月25日10:31:22.359 :: DEBUG:REQUEST /上org.eclipse.jetty。 server.nio.Select ChannelConnector $ -2 @ 77e8a5c 2012年9月25日10:31:22.406 :: DEBUG:RESPONSE/503

回答

1

嘗試碼頭澆道的較新版本,或嘗試使用碼頭分佈,7.0 .0.RC2早在碼頭創建者的早期,我們剛剛發佈了7.6.7.v20 120910