javascript - Jackson Faster XML AJAX Submit not working properly @JsonBackReference, @JsonManagedReference -


so i'm using spring boot , i'm trying submit form using ajax, , i'm getting error in console in eclipse (sts), , in chrome console, data submitting fine, it's not following through ajax because tell page reload submit nothing happens when click submit button. when check in mysql database submitted , mapped way want , when refresh browser data submitted shows up.

i'm trying add comment post , assign comment user object. i'll show guys code can see i'm talking about.

so here's user object, have mapped @onetomany annotation along @jsonmanaged annotation.

@onetomany(fetch=fetchtype.eager, cascade=cascadetype.all, mappedby="user") @jsonmanagedreference @jsonignoreproperties(allowgetters=true, value = "user" ) public set<comment> getcomments() {   return comments; } 

i have @ top of user object

@entity @table(name="users") @jsonidentityinfo(generator = objectidgenerators.intsequencegenerator.class, property = "@id") public class user 

here's comment object

@manytoone @jsonbackreference @jsonignoreproperties(allowgetters=true, value = "comments") public user getuser() {     return user; } 

along this

@jsonidentityinfo(generator = objectidgenerators.intsequencegenerator.class, property = "@id") public class comment 

here's ajax, of code allow work thymeleaf, in case you're unfamiliar.

<script th:inline="javascript">          /*<![cdata[*/          var postid = /*[[${post.id}]]*/'1';          var token = $("meta[name='_csrf']").attr("content");         var header = $("meta[name='_csrf_header']").attr("content");          $(document).ajaxsend(function(e, xhr, options) {             xhr.setrequestheader(header, token);         });          $(document).ready(function(){         $("#submit").on("click", function(ev) {             ev.preventdefault();             $.ajax({                 url : "newcomment",                 type : "post",                 data : {                     "postid" : postid,                     "newcomment" : $("#newcomment").val()                 },                 success : function(data) {                     console.log(data);                     location.reload();                 },                 error : function() {                     console.log("there error");                 }              });         });       });     /*]]>*/  </script> 

here's controller

@requestmapping(value="viewcourse/post/newcomment", method=requestmethod.post) public @responsebody post newcomment (@valid @requestparam long postid, @requestparam string newcomment, modelmap model, @authenticationprincipal user user) { post post = postrepo.findone(postid); comment comment = new comment(); comment.setcomment(newcomment); comment.setpost(post);  comment.setuser(user); user.getcomments().add(comment);  comment.setuser(user);  post.getcomments().add(comment); post savedpost = postrepo.save(post);  return savedpost; } 

and here's part of error in eclipse (sts) console, it's pretty long didn't think should post whole thing.

java.lang.nosuchmethoderror: com.fasterxml.jackson.annotation.jsonignoreproperties.allowgetters()z @ com.fasterxml.jackson.databind.introspect.jacksonannotationintrospector.findpropertiestoignore(jacksonannotationintrospector.java:126) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.std.beanserializerbase.createcontextual(beanserializerbase.java:424) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.serializerprovider.handlesecondarycontextualization(serializerprovider.java:944) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.serializerprovider.findvalueserializer(serializerprovider.java:495) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.impl.propertyserializermap.findandaddsecondaryserializer(propertyserializermap.java:90) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.std.asarrayserializerbase._findandadddynamic(asarrayserializerbase.java:321) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.std.collectionserializer.serializecontents(collectionserializer.java:144) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.std.collectionserializer.serialize(collectionserializer.java:111) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.std.collectionserializer.serialize(collectionserializer.java:24) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.beanpropertywriter.serializeasfield(beanpropertywriter.java:693) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.std.beanserializerbase.serializefields(beanserializerbase.java:675) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.std.beanserializerbase._serializewithobjectid(beanserializerbase.java:597) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.beanserializer.serialize(beanserializer.java:148) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.std.collectionserializer.serializecontents(collectionserializer.java:149) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.std.collectionserializer.serialize(collectionserializer.java:111) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.std.collectionserializer.serialize(collectionserializer.java:24) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.beanpropertywriter.serializeasfield(beanpropertywriter.java:693) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.std.beanserializerbase.serializefields(beanserializerbase.java:675) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.beanserializer.serialize(beanserializer.java:157) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.beanpropertywriter.serializeasfield(beanpropertywriter.java:693) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.std.beanserializerbase.serializefields(beanserializerbase.java:675) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.std.beanserializerbase._serializewithobjectid(beanserializerbase.java:597) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.beanserializer.serialize(beanserializer.java:148) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.std.collectionserializer.serializecontents(collectionserializer.java:149) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.std.collectionserializer.serialize(collectionserializer.java:111) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.std.collectionserializer.serialize(collectionserializer.java:24) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.beanpropertywriter.serializeasfield(beanpropertywriter.java:693) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.std.beanserializerbase.serializefields(beanserializerbase.java:675) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.beanserializer.serialize(beanserializer.java:157) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.beanpropertywriter.serializeasfield(beanpropertywriter.java:693) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.std.beanserializerbase.serializefields(beanserializerbase.java:675) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.std.beanserializerbase._serializewithobjectid(beanserializerbase.java:597) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.beanserializer.serialize(beanserializer.java:148) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.beanpropertywriter.serializeasfield(beanpropertywriter.java:693) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.std.beanserializerbase.serializefields(beanserializerbase.java:675) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.std.beanserializerbase._serializewithobjectid(beanserializerbase.java:597) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.beanserializer.serialize(beanserializer.java:148) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.ser.defaultserializerprovider.serializevalue(defaultserializerprovider.java:130) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.objectwriter$prefetch.serialize(objectwriter.java:1387) ~[jackson-databind-2.6.3.jar:2.6.3] @ com.fasterxml.jackson.databind.objectwriter.writevalue(objectwriter.java:889) ~[jackson-databind-2.6.3.jar:2.6.3] 

if can see why acting strange , let me know awesome. in advance.

update

here's pom.xml

<?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelversion>4.0.0</modelversion>  <groupid>com.coderscampus</groupid> <artifactid>quizbanks3</artifactid> <version>0.0.1-snapshot</version> <packaging>jar</packaging>  <name>quizbanks3</name> <description>coursecreation project spring boot</description>  <parent>     <groupid>org.springframework.boot</groupid>     <artifactid>spring-boot-starter-parent</artifactid>     <version>1.3.0.release</version>     <relativepath/> <!-- lookup parent repository --> </parent>  <properties>     <project.build.sourceencoding>utf-8</project.build.sourceencoding>     <java.version>1.8</java.version> </properties>  <dependencies>     <dependency>         <groupid>org.springframework.security</groupid>         <artifactid>spring-security-core</artifactid>     </dependency>     <dependency>         <groupid>org.springframework.security</groupid>         <artifactid>spring-security-web</artifactid>     </dependency>     <dependency>         <groupid>org.springframework.security</groupid>         <artifactid>spring-security-config</artifactid>     </dependency>     <dependency>         <groupid>org.springframework</groupid>         <artifactid>springloaded</artifactid>     </dependency>     <dependency>         <groupid>org.springframework.boot</groupid>         <artifactid>spring-boot-starter-data-jpa</artifactid>     </dependency>     <dependency>         <groupid>org.springframework.boot</groupid>         <artifactid>spring-boot-starter-thymeleaf</artifactid>     </dependency>     <dependency>         <groupid>org.springframework.boot</groupid>         <artifactid>spring-boot-starter-web</artifactid>     </dependency>     <dependency>         <groupid>org.apache.tomcat.embed</groupid>         <artifactid>tomcat-embed-el</artifactid>     </dependency>     <dependency>         <groupid>mysql</groupid>         <artifactid>mysql-connector-java</artifactid>         <scope>runtime</scope>     </dependency>     <dependency>         <groupid>org.springframework.boot</groupid>         <artifactid>spring-boot-starter-test</artifactid>         <scope>test</scope>     </dependency>     <dependency>         <groupid>org.spockframework</groupid>         <artifactid>spock-spring</artifactid>     </dependency>     <dependency>     <groupid>org.springframework.security</groupid>     <artifactid>spring-security-core</artifactid>     </dependency>     <dependency>         <groupid>org.springframework.security</groupid>         <artifactid>spring-security-web</artifactid>     </dependency>     <dependency>         <groupid>org.springframework.security</groupid>         <artifactid>spring-security-config</artifactid>     </dependency>             <dependency>         <groupid>org.springframework.security</groupid>         <artifactid>spring-security-data</artifactid>     </dependency>     <!--thymeleaf spring security-->     <dependency>         <groupid>org.thymeleaf</groupid>         <artifactid>thymeleaf-spring4</artifactid>     </dependency>     <dependency>         <groupid>org.thymeleaf.extras</groupid>         <artifactid>thymeleaf-extras-springsecurity4</artifactid>         <version>2.1.2.release</version><!--$no-mvn-man-ver$-->     </dependency>     <dependency>         <groupid>com.fasterxml.jackson.core</groupid>         <artifactid>jackson-databind</artifactid>     </dependency>     <dependency>         <groupid>org.springframework.hateoas</groupid>         <artifactid>spring-hateoas</artifactid>     </dependency>     <dependency>         <groupid>com.fasterxml.jackson.core</groupid>         <artifactid>jackson-annotations</artifactid>     </dependency>     <dependency>         <groupid>com.fasterxml.jackson.core</groupid>         <artifactid>jackson-core</artifactid>     </dependency>     </dependencies>      <build>         <plugins>             <plugin>             <groupid>org.springframework.boot</groupid>             <artifactid>spring-boot-maven-plugin</artifactid>             </plugin>         </plugins>     </build>         <repositories>           <repository>               <id>spring-releases</id>               <name>spring releases</name>               <url>https://repo.spring.io/libs-release</url>           </repository>       </repositories>        <pluginrepositories>           <pluginrepository>               <id>spring-releases</id>               <name>spring releases</name>               <url>https://repo.spring.io/libs-release</url>           </pluginrepository>       </pluginrepositories>   </project> 


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -