Spring MVC and Hibernate: NestedServletException: Handler processing failed; nested exception NoClassDefFoundError:JsonMappingException$Reference -


  • am trying integration spring mvc , hibernate & oracle 11g
  • tables users & org & userorg[forgin keys userid,orgid]
  • pom.xml

    <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/maven-v4_0_0.xsd"> <modelversion>4.0.0</modelversion> <groupid>com.tests</groupid> <artifactid>test</artifactid> <packaging>war</packaging> <version>1.0-snapshot</version> <name>tests maven webapp</name> <url>http://maven.apache.org</url> <properties>     <spring.version>4.1.5.release</spring.version>     <hibernate.version>4.3.8.final</hibernate.version>     <mysql.version>5.1.10</mysql.version>     <junit-version>4.11</junit-version>     <servlet-api-version>3.1.0</servlet-api-version>     <jsp-version>2.1</jsp-version>     <jstl-version>1.2</jstl-version> </properties> <dependencies>     <!-- spring 4 dependencies -->     <dependency>         <groupid>org.springframework</groupid>         <artifactid>spring-core</artifactid>         <version>${spring.version}</version>     </dependency>     <dependency>         <groupid>org.springframework</groupid>         <artifactid>spring-context</artifactid>         <version>${spring.version}</version>     </dependency>     <dependency>         <groupid>org.springframework</groupid>         <artifactid>spring-web</artifactid>         <version>${spring.version}</version>     </dependency>     <dependency>         <groupid>org.springframework</groupid>         <artifactid>spring-webmvc</artifactid>         <version>${spring.version}</version>     </dependency>     <dependency>         <groupid>org.springframework</groupid>         <artifactid>spring-orm</artifactid>         <version>${spring.version}</version>     </dependency>     <dependency>         <groupid>org.springframework</groupid>         <artifactid>spring-test</artifactid>         <version>${spring.version}</version>         <scope>test</scope>     </dependency>     <!-- hibernate 4 dependencies -->     <dependency>         <groupid>org.hibernate</groupid>         <artifactid>hibernate-core</artifactid>         <version>${hibernate.version}</version>     </dependency>     <dependency>         <groupid>org.hibernate</groupid>         <artifactid>hibernate-c3p0</artifactid>         <version>${hibernate.version}</version>     </dependency>     <!-- servlet , jsp -->     <dependency>         <groupid>javax.servlet</groupid>         <artifactid>javax.servlet-api</artifactid>         <version>${servlet-api-version}</version>     </dependency>     <dependency>         <groupid>javax.servlet.jsp</groupid>         <artifactid>jsp-api</artifactid>         <version>${jsp-version}</version>         <scope>provided</scope>     </dependency>     <!-- jstl dependency -->     <dependency>         <groupid>jstl</groupid>         <artifactid>jstl</artifactid>         <version>${jstl-version}</version>     </dependency>     <!-- junit -->     <dependency>         <groupid>junit</groupid>         <artifactid>junit</artifactid>         <version>${junit-version}</version>         <scope>test</scope>     </dependency>     <!-- external oralce jar -->     <dependency>         <groupid>ojdbc7</groupid>         <artifactid>ojdbc7</artifactid>         <version>1.0</version>     </dependency>     <!-- json dependency -->     <dependency>         <groupid>org.codehaus.jackson</groupid>         <artifactid>jackson-mapper-asl</artifactid>         <version>1.9.13</version>     </dependency>     <dependency>         <groupid>com.fasterxml.jackson.core</groupid>         <artifactid>jackson-core</artifactid>         <version>2.4.1</version>     </dependency>     <dependency>         <groupid>com.fasterxml.jackson.core</groupid>         <artifactid>jackson-databind</artifactid>         <version>2.4.1.1</version>     </dependency>     <!-- json dependency -->     <!-- slf4j-log4j -->     <dependency>         <groupid>org.slf4j</groupid>         <artifactid>slf4j-log4j12</artifactid>         <version>1.6.1</version>     </dependency> </dependencies> <build>     <finalname>tests</finalname>     <!-- <resources> <resource> <directory>src/main/java</directory> <includes>          <include>**/*.xml</include> <include>**/*.properties</include> </includes>          </resource> </resources> -->     <plugins>         <plugin>             <groupid>org.apache.maven.plugins</groupid>             <artifactid>maven-war-plugin</artifactid>             <configuration>                 <outputdirectory>d:\newfolder\softwares\jboss-as-7.1.1.final\standalone\deployments</outputdirectory>                                    </configuration>         </plugin>         <plugin>             <groupid>org.apache.maven.plugins</groupid>             <artifactid>maven-eclipse-plugin</artifactid>             <configuration>                 <downloadsources>true</downloadsources>                 <downloadjavadocs>true</downloadjavadocs>             </configuration>         </plugin>     </plugins> </build> 

  • entity files

  • org.java & users.java & usersorg.java

        package com.tests.entity; /**  * org generated hbm2java  */ @entity @jsonidentityinfo(generator = objectidgenerators.propertygenerator.class, property = "orgid") public class org implements java.io.serializable {     @id     @column(name = "orgid")     @generatedvalue(strategy = generationtype.identity)     private bigdecimal orgid;     private bigdecimal parentorgid;     private bigdecimal orgcode;     private string orgname;     private string description;     private bigdecimal actstat;     private set<userorg> userorgs = new hashset<userorg>(0);             public org() {     }     public org(bigdecimal orgid, bigdecimal parentorgid, bigdecimal orgcode, string orgname, bigdecimal actstat) {         this.orgid = orgid;         this.parentorgid = parentorgid;         this.orgcode = orgcode;         this.orgname = orgname;         this.actstat = actstat;     }     public org(bigdecimal orgid, bigdecimal parentorgid, bigdecimal orgcode, string orgname, string description, bigdecimal actstat,              set<userorg> userorgs) {         this.orgid = orgid;         this.parentorgid = parentorgid;         this.orgcode = orgcode;         this.orgname = orgname;         this.description = description;         this.actstat = actstat;         this.userorgs = userorgs;     }     public bigdecimal getorgid() {         return this.orgid;     }     public void setorgid(bigdecimal orgid) {         this.orgid = orgid;     }     public bigdecimal getparentorgid() {         return this.parentorgid;     }     public void setparentorgid(bigdecimal parentorgid) {         this.parentorgid = parentorgid;     }     public bigdecimal getorgcode() {         return this.orgcode;     }     public void setorgcode(bigdecimal orgcode) {         this.orgcode = orgcode;     }     public string getorgname() {         return this.orgname;     }     public void setorgname(string orgname) {         this.orgname = orgname;     }     public string getdescription() {         return this.description;     }     public void setdescription(string description) {         this.description = description;     }     public bigdecimal getactstat() {         return this.actstat;     }     public void setactstat(bigdecimal actstat) {         this.actstat = actstat;     }     public bigdecimal getorgphone() {         return this.orgphone;     }     @onetomany(cascade=cascadetype.all, fetch=fetchtype.eager)     // @jsonignore     public set<userorg> getuserorgs() {         return this.userorgs;     }     // @manytoone(cascade={}, fetch=fetchtype.lazy)     // @jsonignore     public void setuserorgs(set<userorg> userorgs) {         this.userorgs = userorgs;     } } 
  • same users.java & userorg.java[orgid,userid forgin keys]

  • hibernate hbm xml files users.hbm.xml & userorg.hbm.xml & org.hbm.xml

        <?xml version="1.0"?> <!doctype hibernate-mapping public "-//hibernate/hibernate mapping dtd 3.0//en" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <!-- generated jun 17, 2016 3:32:52 pm hibernate tools 3.4.0.cr1 --> <hibernate-mapping package="com.tests.entity">     <class name="org" table="org">     <id name="orgid" type="big_decimal">         <column name="org_id" precision="22" scale="0" />         <generator class="increment" />     </id>     <property name="parentorgid" type="big_decimal">         <column name="parent_org_id" precision="22" scale="0" not-null="true" />     </property>     <property name="orgcode" type="big_decimal">         <column name="org_code" precision="22" scale="0" not-null="true" />     </property>     <property name="orgname" type="string">         <column name="org_name" length="32" not-null="true" unique="true" />     </property>     <property name="description" type="string">         <column name="description" length="100" />     </property>     <property name="actstat" type="big_decimal">         <column name="act_stat" precision="22" scale="0" not-null="true" />     </property>             <set name="userorgs" table="user_org" inverse="true" lazy="true" fetch="select">         <key>         <column name="org_id" precision="22" scale="0" />         </key>         <one-to-many class="userorg" />     </set>     <set name="branches" table="branch" inverse="true" lazy="true" fetch="select">         <key>         <column name="org_id" precision="22" scale="0" not-null="true" />         </key>         <one-to-many class="branch" />     </set>     <!-- <set name="users" table="user_org" inverse="true" lazy="true" fetch="select">          <key>         <column name="org_id" precision="22" scale="0" />         </key>         <many-to-many class="users" column="user_id" />     </set>     <set name="branches" table="branch" inverse="true" lazy="false" fetch="select">         <key>         <column name="org_id" precision="22" scale="0" not-null="true" />         </key>         <one-to-many class="branch" />     </set> -->     </class> </hibernate-mapping> 
  • userorg.hbm.xml

        <?xml version="1.0"?> <!doctype hibernate-mapping public "-//hibernate/hibernate mapping dtd 3.0//en" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <!-- generated jun 17, 2016 3:32:52 pm hibernate tools 3.4.0.cr1 --> <hibernate-mapping package="com.tests.entity">     <class name="userorg" table="user_org">     <id name="userorgid" type="big_decimal">         <column name="user_org_id" precision="22" scale="0" />         <generator class="assigned" />     </id>     <many-to-one name="org" class="org"  fetch="select">         <column name="org_id" precision="22" scale="0" />     </many-to-one>     <many-to-one name="users" class="users" fetch="select">         <column name="user_id" precision="22" scale="0" />     </many-to-one>     </class> </hibernate-mapping> 
  • hibernate util file

        package com.tests.util; @repository public class hibernateutil {     @autowired     private sessionfactory sessionfactory;     public object getbyuserid(string userquery, string userid) {          return sessionfactory.getcurrentsession().createquery(userquery).setparameter("userid", userid).uniqueresult();     } } 
  • interceptor class

        package com.tests.interceptor; public class organizationinterceptor extends handlerinterceptoradapter {     @override     public boolean prehandle(httpservletrequest request, httpservletresponse response, object handler) throws exception {         string servletpath = request.getservletpath();         if (servletpath.equals("/organization")) {             return true;         }         return true;     } } 
  • and other service & dao classes
  • controller class

        package com.tests.controller;   @controller @requestmapping("organization") public class organizationlogincontroller {     @suppresswarnings("unused")     private static logger logger = loggerfactory.getlogger(organizationlogincontroller.class);     @autowired     private organizationservice organizationservice;     @suppresswarnings({ "unused", "rawtypes" })     @requestmapping(value = { "/", "", "login" })     public @responsebody void organizationlogin(@requestparam(required = false) string username, @requestparam(required = false) string password,             httpservletrequest request, httpservletresponse response) {             users loginuser = organizationservice.getloginauthentication(username, password);             if(loginuser != null){                 //do             }else{                               //do             }     } } 
  • deployment project when run application got error [error log below]

  • i have done many changes getting same error, if @jsonignore using working fine unable mapping data.

  • server.log

        15:32:36,948 debug [org.springframework.web.servlet.dispatcherservlet] (ajp-localhost-127.0.0.1-8009-1) not complete request: org.springframework.web.util.nestedservletexception: handler processing failed; nested exception java.lang.noclassdeffounderror: org/codehaus/jackson/map/jsonmappingexception$reference     @ org.springframework.web.servlet.dispatcherservlet.triggeraftercompletionwitherror(dispatcherservlet.java:1287) [spring-webmvc-4.1.5.release.jar:4.1.5.release]     @ org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:961) [spring-webmvc-4.1.5.release.jar:4.1.5.release]     @ org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:877) [spring-webmvc-4.1.5.release.jar:4.1.5.release]     @ org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:966) [spring-webmvc-4.1.5.release.jar:4.1.5.release]     @ org.springframework.web.servlet.frameworkservlet.doget(frameworkservlet.java:857) [spring-webmvc-4.1.5.release.jar:4.1.5.release]     @ javax.servlet.http.httpservlet.service(httpservlet.java:734) [jboss-servlet-api_3.0_spec-1.0.0.final.jar:1.0.0.final]     @ org.springframework.web.servlet.frameworkservlet.service(frameworkservlet.java:842) [spring-webmvc-4.1.5.release.jar:4.1.5.release]     @ javax.servlet.http.httpservlet.service(httpservlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.final.jar:1.0.0.final]     @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:329) [jbossweb-7.0.13.final.jar:]     @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:248) [jbossweb-7.0.13.final.jar:]     @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:275) [jbossweb-7.0.13.final.jar:]     @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:161) [jbossweb-7.0.13.final.jar:]     @ org.jboss.as.web.security.securitycontextassociationvalve.invoke(securitycontextassociationvalve.java:153) [jboss-as-web-7.1.1.final.jar:7.1.1.final]     @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:155) [jbossweb-7.0.13.final.jar:]     @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:102) [jbossweb-7.0.13.final.jar:]     @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:109) [jbossweb-7.0.13.final.jar:]     @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:368) [jbossweb-7.0.13.final.jar:]     @ org.apache.coyote.ajp.ajpprocessor.process(ajpprocessor.java:505) [jbossweb-7.0.13.final.jar:]     @ org.apache.coyote.ajp.ajpprotocol$ajpconnectionhandler.process(ajpprotocol.java:445) [jbossweb-7.0.13.final.jar:]     @ org.apache.tomcat.util.net.jioendpoint$worker.run(jioendpoint.java:930) [jbossweb-7.0.13.final.jar:]     @ java.lang.thread.run(unknown source) [rt.jar:1.7.0_79] caused by: java.lang.noclassdeffounderror: org/codehaus/jackson/map/jsonmappingexception$reference     @ org.codehaus.jackson.map.ser.std.beanserializerbase.serializefields(beanserializerbase.java:166) [jackson-mapper-asl-1.9.13.jar:1.9.13]     @ org.codehaus.jackson.map.ser.beanserializer.serialize(beanserializer.java:112) [jackson-mapper-asl-1.9.13.jar:1.9.13] 
  • please me did wrong, new in hibernat

  • thanks in advance

try adding jackson-core-asl dependency

<dependency>     <groupid>org.codehaus.jackson</groupid>     <artifactid>jackson-core-asl</artifactid>     <version>1.9.13</version> </dependency> 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -