eclipse - NoSuchMethodError: LocalSessionFactoryBuilder.addAnnotatedClass(Ljava/lang/Class;)Lorg/hibernate/cfg/Configuration; -


i using spring 3.2 , hibernate4. included jars required. using jboss as. deploying eclipse. getting error.

org.springframework.beans.factory.beancreationexception: error creating bean name  'personcontroller': injection of autowired dependencies failed; nested exception  org.springframework.beans.factory.beancreationexception: not autowire field: private  com.springmvcsample.service.personservice  com.springmvcsample.controller.personcontroller.personservice; nested exception  org.springframework.beans.factory.beancreationexception: error creating bean name  'personservice': injection of autowired dependencies failed; nested exception  org.springframework.beans.factory.beancreationexception: not autowire field: private  com.springmvcsample.dao.persondao com.springmvcsample.service.personserviceimpl.persondao; nested  exception org.springframework.beans.factory.beancreationexception: error creating bean  name 'persondao': injection of autowired dependencies failed; nested exception      org.springframework.beans.factory.beancreationexception: not autowire field:   org.hibernate.sessionfactory com.springmvcsample.dao.persondaoimpl.sessionfactory; nested   exception org.springframework.beans.factory.beancreationexception: error creating bean   name 'sessionfactory' defined in servletcontext resource [/web-inf/hibernate_config.xml]:   invocation of init method failed; nested exception java.lang.nosuchmethoderror:   org.springframework.orm.hibernate4.localsessionfactorybuilder.addannotatedclass  (ljava/lang/class;)lorg/hibernate/cfg/configuration; 

web.xml

   <servlet>    <servlet-name> springmvc_hibernate</servlet-name>     <servlet-class>               org.springframework.web.servlet.dispatcherservlet     </servlet-class>    <load-on-startup>1</load-on-startup>     </servlet>     <context-param> <param-name>contextconfiglocation</param-name> <param-value>/web-inf/springmvc_hibernate-servlet.xml</param-value>   </context-param>   <servlet-mapping>    <servlet-name>springmvc_hibernate</servlet-name>    <url-pattern>*.htm</url-pattern>  </servlet-mapping> 

springmvc_hibernate-servlet.xml

        <context:component-scan base-package="com.springmvcsample.controller"/>     <context:component-scan base-package="com.springmvcsample.dao"/>     <context:component-scan base-package="com.springmvcsample.service"/>     <import resource="hibernate_config.xml"/>      <mvc:annotation-driven content-negotiation-manager="contentnegotiationmanager"/>     <bean id="contentnegotiationmanager" class="org.springframework.web.accept.contentnegotiationmanagerfactorybean">         <!-- turn off working out content type based on url file extension, should fall looking @ accept headers -->         <property name="favorpathextension" value="false" />     </bean>      <bean name="sender" class="com.springmvcsample.utility.messagesender"/> 

hibernate_config.xml

  <bean id="propertyconfigurer" class="org.springframework.beans.factory.config.propertyplaceholderconfigurer">     <property name="locations">         <list>             <value>/resources/db.properties</value>         </list>     </property> </bean>  <bean id="datasource" class="org.springframework.jdbc.datasource.drivermanagerdatasource">     <property name="driverclassname" value="com.mysql.jdbc.driver" />     <property name="url" value="${jdbc.url}" />     <property name="username" value="${jdbc.user}" />     <property name="password" value="${jdbc.password}" /> </bean>  <bean id="sessionfactory" class="org.springframework.orm.hibernate4.localsessionfactorybean">     <property name="datasource" ref="datasource"/>     <property name="packagestoscan" value="com.springmvcsample.controller" />     <property name="hibernateproperties">         <props>             <prop key="hibernate.dialect">org.hibernate.dialect.mysqldialect</prop>             <prop key="hibernate.show_sql">true</prop>          </props>     </property> </bean>  <tx:annotation-driven transaction-manager="transactionmanager"/>  <bean id="transactionmanager" class="org.springframework.orm.hibernate4.hibernatetransactionmanager">     <property name="sessionfactory" ref="sessionfactory"/> </bean> 

my lib flder

additional jars include:

  spring-jms-3.2x.jar    spring-orm-*.jar   spring-tx-*.jar   spring-web-*.jar   spring-webmvc-*.jar 

using maven makes life easier in such cases.

opening pom.xml in ide eclipse / sts give better picture following:-

enter image description here


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -