我正在尝试在 Tomcat 8 中编写一个 Jersey 2 Web 服务。但是我被错误难倒了

I'm trying to write a Jersey 2 Web Service in Tomcat 8. But am stumped by error

Sep 27, 2017 5:08:54 PM org.apache.catalina.core.ApplicationContext log
SEVERE: StandardWrapper.Throwable
java.lang.NoClassDefFoundError: javax/json/bind/JsonbException
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
    at java.lang.Class.getDeclaredMethods(Unknown Source)
    at org.glassfish.jersey.server.model.IntrospectionModeller.run(IntrospectionModeller.java:255)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.glassfish.jersey.server.model.IntrospectionModeller.getAllDeclaredMethods(IntrospectionModeller.java:249)
    at org.glassfish.jersey.server.model.IntrospectionModeller.checkForNonPublicMethodIssues(IntrospectionModeller.java:174)
    at org.glassfish.jersey.server.model.IntrospectionModeller.doCreateResourceBuilder(IntrospectionModeller.java:121)
    at org.glassfish.jersey.server.model.IntrospectionModeller.access[=11=]0(IntrospectionModeller.java:82)
    at org.glassfish.jersey.server.model.IntrospectionModeller.call(IntrospectionModeller.java:114)
    at org.glassfish.jersey.server.model.IntrospectionModeller.call(IntrospectionModeller.java:111)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:316)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:298)
    at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:256)
    at org.glassfish.jersey.server.model.IntrospectionModeller.createResourceBuilder(IntrospectionModeller.java:111)
    at org.glassfish.jersey.server.model.Resource.from(Resource.java:800)
    at org.glassfish.jersey.server.ResourceBagConfigurator.init(ResourceBagConfigurator.java:79)
    at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:354)
    at org.glassfish.jersey.server.ApplicationHandler.lambda$initialize(ApplicationHandler.java:316)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:316)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:298)
    at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:256)
    at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:315)
    at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:282)
    at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:335)
    at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:178)
    at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:370)
    at javax.servlet.GenericServlet.init(GenericServlet.java:158)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1231)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1144)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1031)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4923)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5215)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: javax.json.bind.JsonbException
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1333)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167)
    ... 40 more

Sep 27, 2017 5:08:54 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet [Jersey REST Service] in web application [/ExtraTechAutoSysSDKWS] threw load() exception
java.lang.ClassNotFoundException: javax.json.bind.JsonbException
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1333)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167)
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
    at java.lang.Class.getDeclaredMethods(Unknown Source)
    at org.glassfish.jersey.server.model.IntrospectionModeller.run(IntrospectionModeller.java:255)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.glassfish.jersey.server.model.IntrospectionModeller.getAllDeclaredMethods(IntrospectionModeller.java:249)
    at org.glassfish.jersey.server.model.IntrospectionModeller.checkForNonPublicMethodIssues(IntrospectionModeller.java:174)
    at org.glassfish.jersey.server.model.IntrospectionModeller.doCreateResourceBuilder(IntrospectionModeller.java:121)
    at org.glassfish.jersey.server.model.IntrospectionModeller.access[=11=]0(IntrospectionModeller.java:82)
    at org.glassfish.jersey.server.model.IntrospectionModeller.call(IntrospectionModeller.java:114)
    at org.glassfish.jersey.server.model.IntrospectionModeller.call(IntrospectionModeller.java:111)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:316)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:298)
    at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:256)
    at org.glassfish.jersey.server.model.IntrospectionModeller.createResourceBuilder(IntrospectionModeller.java:111)
    at org.glassfish.jersey.server.model.Resource.from(Resource.java:800)
    at org.glassfish.jersey.server.ResourceBagConfigurator.init(ResourceBagConfigurator.java:79)
    at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:354)
    at org.glassfish.jersey.server.ApplicationHandler.lambda$initialize(ApplicationHandler.java:316)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:316)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:298)
    at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:256)
    at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:315)
    at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:282)
    at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:335)
    at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:178)
    at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:370)
    at javax.servlet.GenericServlet.init(GenericServlet.java:158)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1231)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1144)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1031)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4923)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5215)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

错误发生在我尝试 运行 我 IDE 内 Tomcat 网络服务器上的应用程序时,所以我假设这是一个部署问题。

有人知道为什么会这样吗?

我从 here

下载了 jaxrs-ri-2。26.zip

我正在尝试将它与 Tomcat 8.

一起使用

我不得不调整 catalina.properties tomcat.util.scan.StandardJarScanFilter.jarsToSkip 对于这些罐子:

javax.json-api-1.1.jar
javax.json-1.1.jar

根据此 post here 关于 BPEL 问题。 形式:

SEVERE: Unable to process Jar entry [module-info.class] from Jar... for annotations 
org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 19

我一直在使用 Spring 工具套件,我在其中创建了一个动态 Web 项目。

我使用这个 Youtube video 系列作为指导。

在 WebContext\WEB-INF\lib 文件夹中,我有以下 jar。

hk2-api-2.5.0-b42.jar
hk2-locator-2.5.0-b42.jar
hk2-utils-2.5.0-b42.jar
javax.inject-1.jar
javax.inject-2.5.0-b42.jar
javax.json-1.1.jar
javax.json-api-1.1.jar
javax.ws.rs-api-2.1.jar
jersey-client.jar
jersey-common.jar
jersey-container-servlet-core.jar
jersey-container-servlet.jar
jersey-hk2.jar
jersey-media-jaxb.jar
jersey-media-json-binding.jar
jersey-media-sse.jar
jersey-server.jar
servlet-api-3.1.jar

java -版本产量:

java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

错误提示您没有包含 javax.json.bind。我用谷歌搜索并在此处找到它:https://mvnrepository.com/artifact/javax.json.bind/javax.json.bind-api

这是一个丢失的罐子

javax.json.bind-api-1.0.jar

而且还必须添加到要跳过的 catalina.properties...

它也不见了:

validation-api-1.1.0.Final.jar

这让我明白了应用程序将部署的意义...