我想在我的电脑上创建并运行一个简单的 RESTful 应用程序。我在 Eclipse Helios IDE 上使用 Java 编程语言,在 Microsoft Windows Xp 操作系统上使用 Apache Tomcat 7 服务器。
我一直在尝试在我的电脑上复制本教程的相同过程(从 3 到 3.4 步骤),但它不起作用。
这是我所做的:
使用 Apache Tomcat 7 设置在 Eclipse 上创建了一个动态项目
将我的 Jersey 和 jsr311-api-1.0 jar 文件放入项目
\WEB-INF\lib\
目录将网页中的代码部分复制到我的项目中
右键单击项目,单击“运行方式->在服务器上运行”
试图到达
http://localhost:8080/de.vogella.jersey.first/rest/hello
但我看到的是:
为什么它不起作用?我做错了什么?为什么?
非常感谢!
编辑:
这是控制台所说的:
25-set-2012 9.35.07 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Programmi\Java\jdk1.6.0_21\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Programmi/Java/jre6/bin/client;C:/Programmi/Java/jre6/bin;C:/Programmi/Java/jre6/lib/i386;C:\WINDOWS\;C:\WINDOWS\System32;"C:\ApacheMaven\apache-maven-3.0.4\bin";C:\WINDOWS\;C:\WINDOWS\System32;"C:\ApacheMaven\apache-maven-3.0.4\bin";C:\WINDOWS\;C:\WINDOWS\System32;"C:\ApacheMaven\apache-maven-3.0.4\bin";C:\WINDOWS\System32;C:\WINDOWS\;C:\WINDOWS\System32; C:\Programmi\R-Language\R-2.13.1\bin\;C:\Programmi\OpenVPN\bin\; C:\Programmi\Java\jdk1.6.0_21\bin\; "C:\ApacheMaven\apache-maven-3.0.4\bin";;C:\Programmi\eclipseEC;
25-set-2012 9.35.08 org.apache.tomcat.util.digester.SetPropertiesRule begin
AVVERTENZA: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:de.vogella.jersey.first' did not find a matching property.
25-set-2012 9.35.10 org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
25-set-2012 9.35.10 org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
25-set-2012 9.35.10 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 3459 ms
25-set-2012 9.35.10 org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
25-set-2012 9.35.10 org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.6
25-set-2012 9.35.11 org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: urn:com:sun:jersey:api:view is already defined
25-set-2012 9.35.12 org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: urn:com:sun:jersey:api:view is already defined
25-set-2012 9.35.12 org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: urn:com:sun:jersey:api:view is already defined
25-set-2012 9.35.12 org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet Jersey REST Service as unavailable
25-set-2012 9.35.12 org.apache.catalina.core.StandardContext loadOnStartup
GRAVE: Servlet /de.vogella.jersey.first threw load() exception
java.lang.ClassNotFoundException: javax.servlet.Filter
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1558)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1488)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:397)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1048)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:996)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4741)
at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5062)
at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5057)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
25-set-2012 9.35.12 org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler ["http-bio-8080"]
25-set-2012 9.35.12 org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
25-set-2012 9.35.12 org.apache.catalina.startup.Catalina start
INFO: Server startup in 1790 ms
也许缺少一些课程?