简体   繁体   中英

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:

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.

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. 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. I assume this has to go into WEB-INF/lib of your WAR file.

  3. Disable classloader delegation in glassfish-web.xml of your application. 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. So you might get around your problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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