每当我尝试用Jersey运行Tomcat时,它都拒绝加载

时间:2015-06-10 18:02:04

标签: java rest tomcat jersey

基本上我正在尝试使用Rational Software Architect创建一个简单的Hello World程序。要创建服务器,我使用Tomcat和Jersey。我发现当我创建服务器时没有将jersey jar文件放入WEB-INF / lib而是我创建了一个包含所有jar文件的自定义用户库,Tomcat将编译正常但是url不会加载“Hello World”文本,只是404错误。我简单地做http://localhost:8080/ 项目名称 / rest / 类路径名,什么都不会出现。我认为它是因为我没有WEB-INF / lib中的泽西文件,但是当我将jersey jar文件放在该文件夹中并尝试运行tomcat服务器时,我得到一个“localhost上的服务器Tomcat v7.0服务器失败”开始。”错误。

请提前帮助我,并提前致谢。

Jun 10, 2015 12:56:28 PM org.apache.tomcat.util.digester.SetPropertiesRule       begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:RestHello' did not find a matching property.
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version:        Apache Tomcat/7.0.62
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built:          May 7 2015 17:14:55 UTC
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number:         7.0.62.0
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name:               Windows 7
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version:            6.1 build 7601 Service Pack 1
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture:          x86
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home:             C:\SDP80x\jdk\jre
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version:           jvmwi3260sr9-20110324_78506
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor:            IBM Corporation
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE:         C:\EzraZWS\.metadata\.plugins\org.eclipse.wst.server.core\tmp1
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME:         C:\RESTWS\Tomcat 7.0
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Xjcl:jclscar_24
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcom.ibm.oti.vm.bootstrap.library.path=C:\SDP80x\jdk\jre\bin
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dsun.boot.library.path=C:\SDP80x\jdk\jre\bin
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.library.path=C:\SDP80x\jdk\jre\bin;.;C:/SDP80x/jdk/jre/bin/j9vm;C:/SDP80x/jdk/jre/bin;C:/SDP80x/jdk/jre/lib/i386;c:\eip40\tibco\tibrv\8.4\bin;C:\eip40\tibco\tibrv\8.3\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\RationalSDLC\ClearCase\bin;C:\RationalSDLC\common;C:\Program Files (x86)\WebEx\Productivity Tools;C:\Program Files\Dell\Dell Data Protection\Encryption\;C:\Program Files (x86)\nodejs\;C:\SDP80x\jdk\bin;;C:\SDP80x;
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.home=C:\SDP80x\jdk\jre
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.ext.dirs=C:\SDP80x\jdk\jre\lib\ext
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Duser.dir=C:\SDP80x
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: _j2se_j9=71168
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Xdump
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.class.path=c:\eip40\tibco\tibrv\8.4\lib\tibrvnative.jar;C:\eip40\tibco\tibrv\8.3\lib\tibrvnative.jar;C:\SDP80x\jdk\bin;
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=C:\EzraZWS\.metadata\.plugins\org.eclipse.wst.server.core\tmp1
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=C:\RESTWS\Tomcat 7.0
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=C:\EzraZWS\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=C:\RESTWS\Tomcat 7.0\endorsed
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=Cp1252
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.class.path=C:\RESTWS\Tomcat 7.0\bin\bootstrap.jar;C:\RESTWS\Tomcat 7.0\bin\tomcat-juli.jar;C:\SDP80x\jdk\lib\tools.jar;C:\EzraZWS\RestHello\WebContent\WEB-INF\lib\jersey-client.jar;C:\EzraZWS\RestHello\WebContent\WEB-INF\lib\jersey-common.jar;C:\EzraZWS\RestHello\WebContent\WEB-INF\lib\jersey-container-servlet.jar;C:\EzraZWS\RestHello\WebContent\WEB-INF\lib\jersey-container-servlet-core.jar;C:\EzraZWS\RestHello\WebContent\WEB-INF\lib\jersey-media-jaxb.jar;C:\EzraZWS\RestHello\WebContent\WEB-INF\lib\jersey-server.jar
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dsun.java.command=org.apache.catalina.startup.Bootstrap start
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dsun.java.launcher=SUN_STANDARD
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: _port_library
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: _org.apache.harmony.vmi.portlib
Jun 10, 2015 12:56:28 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\SDP80x\jdk\jre\bin;.;C:/SDP80x/jdk/jre/bin/j9vm;C:/SDP80x/jdk/jre/bin;C:/SDP80x/jdk/jre/lib/i386;c:\eip40\tibco\tibrv\8.4\bin;C:\eip40\tibco\tibrv\8.3\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\RationalSDLC\ClearCase\bin;C:\RationalSDLC\common;C:\Program Files (x86)\WebEx\Productivity Tools;C:\Program Files\Dell\Dell Data Protection\Encryption\;C:\Program Files (x86)\nodejs\;C:\SDP80x\jdk\bin;;C:\SDP80x;
Jun 10, 2015 12:56:28 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Jun 10, 2015 12:56:28 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 559 ms
Jun 10, 2015 12:56:28 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jun 10, 2015 12:56:28 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.62
Jun 10, 2015 12:56:28 PM org.apache.catalina.core.ContainerBase startInternal
SEVERE: A child container failed during start
Throwable occurred: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
    at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:233)
    at java.util.concurrent.FutureTask.get(FutureTask.java:94)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:819)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:314)
    at java.util.concurrent.FutureTask.run(FutureTask.java:149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:897)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:919)
    at java.lang.Thread.run(Thread.java:736)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    ... 7 more
Caused by: java.lang.UnsupportedClassVersionError: JVMCFRE003 bad major version; class=org/glassfish/jersey/servlet/init/JerseyServletContainerInitializer, offset=6
    at java.lang.ClassLoader.defineClass(ClassLoader.java:275)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:69)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:540)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:451)
    at java.net.URLClassLoader.access$300(URLClassLoader.java:79)
    at java.net.URLClassLoader$ClassFinder.run(URLClassLoader.java:1038)
    at java.security.AccessController.doPrivileged(AccessController.java:284)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:429)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:653)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:358)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:645)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:619)
    at java.lang.Class.forNameImpl(Native Method)
    at java.lang.Class.forName(Class.java:172)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1707)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
    at java.lang.Class.forNameImpl(Native Method)
    at java.lang.Class.forName(Class.java:172)
    at org.apache.catalina.startup.WebappServiceLoader.loadServices(WebappServiceLoader.java:192)
    at org.apache.catalina.startup.WebappServiceLoader.load(WebappServiceLoader.java:157)
    at org.apache.catalina.startup.ContextConfig.processServletContainerInitializers(ContextConfig.java:1577)
    at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1281)
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:889)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:386)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5416)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 7 more
Jun 10, 2015 12:56:28 PM org.apache.catalina.core.ContainerBase startInternal
SEVERE: A child container failed during start
Throwable occurred: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/RestHello]]
    at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:233)
    at java.util.concurrent.FutureTask.get(FutureTask.java:94)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:819)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:314)
    at java.util.concurrent.FutureTask.run(FutureTask.java:149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:897)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:919)
    at java.lang.Thread.run(Thread.java:736)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/RestHello]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    ... 7 more
Caused by: java.lang.UnsupportedClassVersionError: JVMCFRE003 bad major version; class=org/glassfish/jersey/servlet/init/JerseyServletContainerInitializer, offset=6 (unable to load class org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer)
    at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2961)
    at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1210)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1690)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
    at java.lang.Class.forNameImpl(Native Method)
    at java.lang.Class.forName(Class.java:172)
    at org.apache.catalina.startup.WebappServiceLoader.loadServices(WebappServiceLoader.java:192)
    at org.apache.catalina.startup.WebappServiceLoader.load(WebappServiceLoader.java:157)
    at org.apache.catalina.startup.ContextConfig.processServletContainerInitializers(ContextConfig.java:1577)
    at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1281)
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:889)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:386)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5416)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 7 more
Jun 10, 2015 12:56:28 PM org.apache.catalina.core.ContainerBase startInternal
SEVERE: A child container failed during start
Throwable occurred: java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
    at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:233)
    at java.util.concurrent.FutureTask.get(FutureTask.java:94)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:300)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:739)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:689)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:321)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:455)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:314)
    at java.util.concurrent.FutureTask.run(FutureTask.java:149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:897)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:919)
    at java.lang.Thread.run(Thread.java:736)
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1131)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:819)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 7 more
Jun 10, 2015 12:56:28 PM org.apache.catalina.startup.Catalina start
SEVERE: The required Server component failed to start so Tomcat is unable to start.
Throwable occurred: org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8005]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:689)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:321)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:455)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Catalina]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:739)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 7 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 9 more
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1131)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:300)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 11 more
Jun 10, 2015 12:56:28 PM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-bio-8080"]
Jun 10, 2015 12:56:28 PM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-bio-8009"]
Jun 10, 2015 12:56:28 PM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Jun 10, 2015 12:56:28 PM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-bio-8080"]
Jun 10, 2015 12:56:28 PM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["ajp-bio-8009"]

我的代码:

package RestHello;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path ("/hello")
public class Hello {

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String sayHello() {
        return "Hello";
    }
}

我的web.xml是:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
id="WebApp_ID" version="3.0">
    <display-name>RestHello</display-name>
    <servlet>
            <servlet-name>Jersey REST Service</servlet-name>
            <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
                <!-- Register resources and providers under com.vogella.jersey.first package. -->
            <init-param>
                <param-name>jersey.config.server.provider.packages</param-name>
                <param-value>RestHello</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Jersey REST Service</servlet-name>
            <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>
</web-app>

2 个答案:

答案 0 :(得分:1)

我终于明白了。谢谢Sasikanth你对我的错误是正确的。 jre必须匹配apache,你的项目和Jersey。最新的Jersey使用jre7所以当你安装apache时,使用jre7作为构建路径。我的Rational项目也默认为java 1.6而不是1.7。因此,您必须手动创建jre7的构建路径。该视频教你如何做到这一点(只需在项目属性中转到java构建路径,双击jre系统库,单击已安装的jres,然后添加一个到jre目录的新路径)。要查找jre目录,只需在开始菜单中查找java,单击java选项卡,然后单击view。这使我的项目构建路径jre7,tomcat应该已经安装了jre7,并且jersey也是jre7所以一切都匹配,你的服务器将正常运行。

视频:https://www.youtube.com/watch?v=whQaqnI4SrU

答案 1 :(得分:0)

不受支持的类版本错误表明您使用的是比tomcat安装支持的更新版本的jersey。很可能是因为jre版本不匹配 - 你使用的球衣库需要更新的jre但是你的版本较旧