从my original problem开始,我需要专门配置Apache TomEE以使用Jackson作为JSON提供程序(而不是默认的Johnzon)。
我在pom.xml中导入了以下内容
<dependency>
<!-- I only need this first one because otherwise it's ommited due to a conflict.... -->
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.9</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.9.9</version>
</dependency>
此后,我尝试了几种方法:
在 ejb-jar.xml 文件中提及提供者
<pojo-deployment class-name="jaxrs-application">
<properties>
cxf.jaxrs.providers = com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider
</properties>
</pojo-deployment>
用自定义类扩展JacksonJaxbJsonProvider并注册它:
@Provider
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public class TGJSONProvider extends JacksonJaxbJsonProvider {
}
无论我做什么(即使我什么也没添加,我都有相同的问题:
2019-05-31 16:11:35 SEVERE org.apache.openejb.observer.ObserverManager$MethodInvocation invoke error invoking org.apache.tomee.webservices.TomeeJaxRsService@12bfd80d
java.lang.NoClassDefFoundError: javax/ws/rs/ext/MessageBodyReader
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
...
...
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: javax.ws.rs.ext.MessageBodyReader
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 55 more
我想念什么/做错了什么?
谢谢。