1、 将servlet-api.jar拷贝到JRE中的JRE_PATH/LIB/EXT目录下。
2、将servlet-api.jar包括路径添加到系统变量CLASSPATH中,忘了这步了 呵呵
tomcat启动的时候报错 配置文件一点都没有变动
2009-5-7 10:37:49 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: The Apache Tomcat Native library which allows optimal performance in produ
ction environments was not found on the java.library.path: C:\Program Files\java
\jdk1.6.0_07\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;.;C:\P
rogram Files\java\jdk1.6.0_07\bin;C:\Program Files\Common Files\Adobe\AGL;C:\Pro
gram Files\StormII\Codec;C:\Program Files\StormII
2009-5-7 10:37:49 org.apache.coyote.http11.Http11BaseProtocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2009-5-7 10:37:49 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 532 ms
2009-5-7 10:37:49 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2009-5-7 10:37:49 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/5.5.27
2009-5-7 10:37:49 org.apache.catalina.core.StandardHost start
信息: XML validation disabled
2009-5-7 10:37:50 org.apache.tomcat.util.digester.Digester endElement
严重: End event threw exception
java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor21.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tomcat.util.IntrospectionUtils.callMethodN(IntrospectionUt
ils.java:930)
at org.apache.tomcat.util.digester.CallMethodRule.end(CallMethodRule.jav
a:579)
at org.apache.tomcat.util.digester.Rule.end(Rule.java:229)
at org.apache.tomcat.util.digester.Digester.endElement(Digester.java:105
8)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endEleme
nt(AbstractSAXParser.java:601)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp
l.scanEndElement(XMLDocumentFragmentScannerImpl.java:1774)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp
l$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2930)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(X
MLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp
l.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(X
ML11Configuration.java:807)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(X
ML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.
java:107)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Ab
stractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.p
arse(SAXParserImpl.java:522)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1562)
at org.apache.catalina.startup.ContextConfig.applicationWebConfig(Contex
tConfig.java:348)
at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:10
48)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfi
g.java:261)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
eSupport.java:120)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4
148)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:760)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:74
0)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.jav
a:927)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.j
ava:890)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492
)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1150)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
eSupport.java:120)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443
)
at org.apache.catalina.core.StandardService.start(StandardService.java:4
48)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:700
)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
Caused by: java.lang.IllegalArgumentException: Invalid <url-pattern> lookHello i
n servlet mapping
at org.apache.catalina.core.StandardContext.addServletMapping(StandardCo
ntext.java:2327)
at org.apache.catalina.core.StandardContext.addServletMapping(StandardCo
ntext.java:2303)
... 45 more
2009-5-7 10:37:50 org.apache.catalina.startup.ContextConfig applicationWebConfig
严重: Parse error in application web.xml file at jndi:/localhost/ch7/WEB-INF/web
.xml
java.lang.IllegalArgumentException: Invalid <url-pattern> lookHello in servlet m
apping
at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.
java:2726)
at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.
java:2752)
at org.apache.tomcat.util.digester.Digester.endElement(Digester.java:106
1)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endEleme
nt(AbstractSAXParser.java:601)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp
l.scanEndElement(XMLDocumentFragmentScannerImpl.java:1774)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp
l$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2930)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(X
MLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp
l.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(X
ML11Configuration.java:807)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(X
ML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.
java:107)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Ab
stractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.p
arse(SAXParserImpl.java:522)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1562)
at org.apache.catalina.startup.ContextConfig.applicationWebConfig(Contex
tConfig.java:348)
at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:10
48)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfi
g.java:261)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
eSupport.java:120)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4
148)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:760)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:74
0)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.jav
a:927)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.j
ava:890)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492
)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1150)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
eSupport.java:120)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443
)
at org.apache.catalina.core.StandardService.start(StandardService.java:4
48)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:700
)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
2009-5-7 10:37:50 org.apache.catalina.startup.ContextConfig applicationWebConfig
严重: Occurred at line 10 column 19
2009-5-7 10:37:50 org.apache.catalina.startup.ContextConfig start
严重: Marking this application unavailable due to previous error(s)
2009-5-7 10:37:50 org.apache.catalina.core.StandardContext start
严重: Error getConfigured
2009-5-7 10:37:50 org.apache.catalina.core.StandardContext start
严重: Context [/ch7] startup failed due to previous errors
2009-5-7 10:37:50 org.apache.coyote.http11.Http11BaseProtocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2009-5-7 10:37:50 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2009-5-7 10:37:50 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/15 config=null
2009-5-7 10:37:50 org.apache.catalina.storeconfig.StoreLoader load
信息: Find registry server-registry.xml at classpath resource
2009-5-7 10:37:50 org.apache.catalina.startup.Catalina start
信息: Server startup in 1125 ms
最近跟着尚学堂的视频做一个在线聊天系统
代码没错 可一run就出错
找不出错哪儿了
import java.io.IOException;
import java.net.*;
public class f {
public static void main(String[] args) {
try {
ServerSocket ss = new ServerSocket (8888);
while(true) {
Socket s = ss.accept();
System.out.println("a client connected!");
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
下面是报的错
java.net.BindException: Address already in use: JVM_Bind
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359)
at java.net.ServerSocket.bind(ServerSocket.java:319)
at java.net.ServerSocket.<init>(ServerSocket.java:185)
at java.net.ServerSocket.<init>(ServerSocket.java:97)
at ChatServer.main(ChatServer.java:8)
编译时没错 运行时错误就报啦
其一:
public class Fib1{
public static void main(String []args){
System.out.println(f(7));
}
public static long f(int index){
if(index == 1 || index == 2){
return 1;
}
long f1= 1L;
long f2 = 1L;
long f = 0;
for(int i=0;i<index-2;i++){
f = f1+f2;
f1 = f2;
f2 = f;
}
return f;
}
}
其二:
//package demo;
//打印斐波那契数列
public class Fib{
public static void main(String[] args){
int x = 0;
int y = 1;
System.out.print(x+" ");
for(int i=1;i<=20;i++){
System.out.print(y+" ");
y=x+y;
x=y-x;
}
}
}
其三:
//求出第n个数是几
public class Fib{
public static void main(String args[]){
System.out.println(f(6));
}
public static int f(int n){
if(n == 1 || n == 2){
return 1;
}else{
return f(n-1) + f(n-2);
}
}
}