简体   繁体   English

REST API 和 Glassfish 中的 JSON 响应

[英]JSON response in REST API and Glassfish

I have a REST API that returns a JSON response, but when I deployed it on Glassfish, it keeps giving me an Exception of class not found as below: I have a REST API that returns a JSON response, but when I deployed it on Glassfish, it keeps giving me an Exception of class not found as below:

java.lang.ClassNotFoundException: javax.xml.parsers.ParserConfigurationException not found by org.eclipse.persistence.moxy

based on the suggested fix is to replace the MOXy JAR inside the Glassfish modules folder, but I am wondering if there is a better solution without touching this folder.基于建议的修复方法是替换 Glassfish 模块文件夹中的 MOXy JAR,但我想知道是否有更好的解决方案而不接触此文件夹。

Thinking a little further about your problem, another solution comes to my mind.进一步考虑您的问题,我想到了另一个解决方案。 I haven't tested it but you might give it a shot.我还没有测试过,但你可以试一试。

  1. Download the JAR where the problem is fixed.下载问题已解决的 JAR。 http://central.maven.org/maven2/org/eclipse/persistence/org.eclipse.persistence.moxy/2.6.1/org.eclipse.persistence.moxy-2.6.1.jar http://central.maven.org/maven2/org/eclipse/persistence/org.eclipse.persistence.moxy/2.6.1/org.eclipse.persistence.moxy-2.6.1.jar

  2. Package the JAR into your application. Package 将 JAR 放入您的应用程序中。 I assume this has to go into WEB-INF/lib of your WAR file.我假设这必须将 go 放入 WAR 文件的WEB-INF/lib中。

  3. Disable classloader delegation in glassfish-web.xml of your application.在应用程序的glassfish-web.xml中禁用类加载器委托。 Here is a description how to do it: Glassfish where do I set classloader delegate option to false This causes Glassfish to first look into your WEB-INF/lib when searching for classes.以下是如何执行此操作的说明: Glassfish 我在哪里将类加载器委托选项设置为 false这会导致 Glassfish 在搜索类时首先查看您的WEB-INF/lib So you might get around your problem.所以你可能会解决你的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM