Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » [Moxy Jersey] NLP at org.eclipse.persistence.jaxb.rs.MOXyJsonProvider.writeTo(MOXyJsonProvider.java:
[Moxy Jersey] NLP at org.eclipse.persistence.jaxb.rs.MOXyJsonProvider.writeTo(MOXyJsonProvider.java: [message #1739521] Tue, 02 August 2016 16:06
Ryan Remer is currently offline Ryan RemerFriend
Messages: 1
Registered: August 2016
Junior Member
Hi I'm trying to use process JSON using Moxy and Jersey 2.0 on an apache tomcat 8.0.36 server.

The following error is produced

SEVERE: Servlet.service() for servlet [ResourceLoader] in context with path [/Test] threw exception [java.lang.NullPointerException] with root cause
java.lang.NullPointerException
at orrrg.eclipse.persistence.jaxb.rs.MOXyJsonProvider.writeTo(MOXyJsonProvider.java:944)


Apologise if this is not the correct place for this post.

Pom.xml

<project xmlns="htttttp://maven.apache.org/POM/4.0.0" xmlns:xsi="httttp://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="htttttp://maven.apache.org/POM/4.    0.0 httttp://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>Test</groupId>
      <artifactId>Test</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <packaging>war</packaging>
      <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
          <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.5.1</version>
            <configuration>
              <source>1.8</source>
              <target>1.8</target>
            </configuration>
          </plugin>
          <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.6</version>
            <configuration>
              <warSourceDirectory>WebContent</warSourceDirectory>
              <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
          </plugin>
        </plugins>
      </build>
      <dependencies>
        <dependency>
          <groupId>asm</groupId>
          <artifactId>asm</artifactId>
          <version>3.3.1</version>
        </dependency>
        <dependency>
          <groupId>orrrg.glassfish.jersey.containers</groupId>
          <artifactId>jersey-container-servlet</artifactId>
          <version>2.23.1</version>
          <exclusions>
            <exclusion>
              <groupId>javax.ws.rs</groupId>
              <artifactId>jsr311-api</artifactId>
            </exclusion>
          </exclusions>
        </dependency>
        <dependency>
             <groupId>orrrg.glassfish.jersey.media</groupId>
             <artifactId>jersey-media-moxy</artifactId>
               <version>2.23.1</version>
        </dependency>
      </dependencies>
       </project>


web.xml

<?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="htttttp://www.w3.org/2001/XMLSchema-instance" xmlns="httttp://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="httttp://xmlns.jcp.    org/xml/ns/javaee httttp://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
      <display-name>Test</display-name>
      <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
      </welcome-file-list>
        <servlet>
        <servlet-name>Test</servlet-name>
        <init-param>
        <param-name>javax.ws.rs.Application</param-name>
        <param-value>ResourceLoader</param-value>
        </init-param>
       </servlet>
    </web-app>


ResourceLoader.java
    import java.util.HashSet;
    import java.util.Set;
    import javax.ws.rs.ApplicationPath;
    import javax.ws.rs.core.Application;
    import org.glassfish.jersey.server.ResourceConfig;
    
    @ApplicationPath("/*")
    public class ResourceLoader extends Application//ResourceConfig 
    {
    	
    	@Override
        public Set<Class<?>> getClasses() 
    	{
            final Set<Class<?>> classes = new HashSet<Class<?>>();
            
            // register root resource
            classes.add(HelloRest.class);
           
            return classes;
        }
        /*
    	public ResourceLoader() 
    	{		
            packages("src");
        }*/
    	
    }

HelloRest.java
    import javax.ws.rs.GET;
    import javax.ws.rs.Path;
    import javax.ws.rs.core.MediaType;
    import javax.ws.rs.Produces;
    
    @Path("/hello")
    public class HelloRest 
    {
      @GET
      @Produces(MediaType.APPLICATION_JSON)
      public Event message()
      {
      System.out.println("Hey");
      Event event = new Event(1,"Terry","Edinburgh");
        return event;
      }
    }

Event.java
    public class Event
    {
      private int id;
      private String name;
      private String location;
      public Event(){}
      public Event(int id,String name, String location)
      {
        this.id = id;
        this.name = name;
        this.location = location;
      }
      public int getId() {
        return id;
      }
      public void setId(int id) {
        this.id = id;
      }
      public String getName() {
        return name;
      }
      public void setName(String name) {
        this.name = name;
      }
      public String getLocation() {
        return location;
      }
      public void setLocation(String location) {
        this.location = location;
      }
    }

Previous Topic:How to completely ignore annotations for entity mapped with xml?
Next Topic:Fetch API cursor in Eclipselink lazy loading
Goto Forum:
  


Current Time: Mon Dec 11 04:03:55 GMT 2017

Powered by FUDForum. Page generated in 0.01689 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software