java - Glassfish 4 REST XML Working JSON Error -


i have web service on glassfish 4.1 working xml not json.

the entity class is:

@xmlrootelement public class person implements serializable {     /**      *       */     private static final long serialversionuid = -8969081094076790550l;     integer id;     string firstname;     string lastname;     string employeeid;      /**      *       */     public person() {     }      @override     public string tostring() {         return firstname + " " + lastname + " [" + employeeid + "] [id: " + id + "]";     }     /**      * @return firstname      */     public string getfirstname() {         return this.firstname;     }     /**      * @param firstname firstname set      */     public void setfirstname(string firstname) {         this.firstname = firstname;     }     /**      * @return lastname      */     public string getlastname() {         return this.lastname;     }     /**      * @param lastname lastname set      */     public void setlastname(string lastname) {         this.lastname = lastname;     }     /**      * @return employeeid      */     public string getemployeeid() {         return this.employeeid;     }     /**      * @param employeeid employeeid set      */     public void setemployeeid(string employeeid) {         this.employeeid = employeeid;     }     /**      * @return id      */     public integer getid() {         return this.id;     }     /**      * @param id id set      */     public void setid(integer id) {         this.id = id;     }  } 

the relevant service code is:

@get @path("xml") @produces(mediatype.text_xml) public collection<person> getpeoplexml() {     return persondao.getallpeople();  }  @get @path("json") @produces(mediatype.application_json) public collection<person> getpeoplejson() {     return persondao.getallpeople();  } 

the xml call works, , get:

<people>  <person>   <employeeid>2234</employeeid>   <firstname>mike</firstname>   <id>2</id>   <lastname>jones</lastname>  </person>  <person>   <employeeid>22314</employeeid>   <firstname>joe</firstname>   <id>4</id>   <lastname>smith</lastname>  </person> </people> 

i error json call:

http status 500 - internal server error

type exception report

messageinternal server error

descriptionthe server encountered internal error prevented fulfilling request.

exception

javax.servlet.servletexception: org.glassfish.jersey.server.containerexception: java.lang.noclassdeffounderror: com/fasterxml/jackson/module/jaxb/jaxbannotationintrospector root cause

org.glassfish.jersey.server.containerexception: java.lang.noclassdeffounderror: com/fasterxml/jackson/module/jaxb/jaxbannotationintrospector root cause

java.lang.noclassdeffounderror: com/fasterxml/jackson/module/jaxb/jaxbannotationintrospector root cause

java.lang.classnotfoundexception: com.fasterxml.jackson.module.jaxb.jaxbannotationintrospector not found com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider [129] note full stack traces of exception , root causes available in glassfish server open source edition 4.1 logs.

why error? have need, think. have ivy file , tried adding kinds of jackson deps, nothing seems work. cannot tell if having version problems when add jackson ivy file since it's included glassfish, or what.

glassfish provides following:

/d/glassfish4/glassfish/modules/jackson-annotations.jar /d/glassfish4/glassfish/modules/jackson-core.jar /d/glassfish4/glassfish/modules/jackson-databind.jar /d/glassfish4/glassfish/modules/jackson-jaxrs-base.jar /d/glassfish4/glassfish/modules/jackson-jaxrs-json-provider.jar /d/glassfish4/glassfish/modules/jersey-media-json-jackson.jar 

so, figured out.

  1. stop glassfish

  2. delete of jackson stuff in modules directory glassfish.

  3. delete domains/domain1/osgi-cache/felix directory

  4. copy following files directory:

/glassfish/modules/jackson-annotations-2.4.0.jar

/glassfish/modules/jackson-annotations-2.5.0.jar

/glassfish/modules/jackson-core-2.4.2.jar

/glassfish/modules/jackson-core-2.5.4.jar

/glassfish/modules/jackson-databind-2.4.2.jar

/glassfish/modules/jackson-databind-2.5.4.jar

/glassfish/modules/jackson-jaxrs-base-2.5.4.jar

/glassfish/modules/jackson-jaxrs-json-provider-2.5.4.jar

/glassfish/modules/jackson-module-jaxb-annotations-2.4.2.jar

/glassfish/modules/jackson-module-jaxb-annotations-2.5.4.jar

/glassfish/modules/jersey-media-json-jackson.jar

then works. not sure version original files jackson were, works , upgrades jackson module versions.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -