maven - java.lang.NoClassDefFoundError: org.springframework.beans.FatalBeanException -


i building jax-ws web service in java 8 , using spring 4.2.6 , hibernate 5.1 it. when deploying project on tomcat, encountering following exception. have googled same , none of stackoverflow post has been helpful.

exception stack

    severe: exception sending context initialized event listener instance of class org.springframework.web.context.contextloaderlistener java.lang.noclassdeffounderror: org.springframework.beans.fatalbeanexception     @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:553)     @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory.java:482)     @ org.springframework.beans.factory.support.abstractbeanfactory$1.getobject(abstractbeanfactory.java:306)     @ org.springframework.beans.factory.support.defaultsingletonbeanregistry.getsingleton(defaultsingletonbeanregistry.java:230)     @ org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.java:302)     @ org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory.java:197)     @ org.springframework.beans.factory.support.defaultlistablebeanfactory.preinstantiatesingletons(defaultlistablebeanfactory.java:772)     @ org.springframework.context.support.abstractapplicationcontext.finishbeanfactoryinitialization(abstractapplicationcontext.java:839)     @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:538)     @ org.springframework.web.context.contextloader.configureandrefreshwebapplicationcontext(contextloader.java:389)     @ org.springframework.web.context.contextloader.initwebapplicationcontext(contextloader.java:294)     @ org.springframework.web.context.contextloaderlistener.contextinitialized(contextloaderlistener.java:112)     @ org.apache.catalina.core.standardcontext.listenerstart(standardcontext.java:4729)     @ org.apache.catalina.core.standardcontext.startinternal(standardcontext.java:5167)     @ org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:150)     @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1408)     @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1398)     @ java.util.concurrent.futuretask.run(futuretask.java:266)     @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1142)     @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:617)     @ java.lang.thread.run(thread.java:745)  may 28, 2016 10:42:25 pm org.apache.catalina.core.standardcontext startinternal severe: 1 or more listeners failed start. full details found in appropriate container log file may 28, 2016 10:42:25 pm org.apache.catalina.core.standardcontext startinternal severe: context [/mavenemployee] startup failed due previous errors may 28, 2016 10:42:25 pm org.apache.catalina.core.applicationcontext log info: closing spring root webapplicationcontext may 28, 2016 10:42:25 pm org.springframework.context.support.abstractapplicationcontext doclose info: closing root webapplicationcontext: startup date [sat may 28 22:42:14 ist 2016]; root of context hierarchy may 28, 2016 10:42:25 pm org.springframework.context.support.abstractapplicationcontext doclose warning: exception thrown lifecycleprocessor on context close java.lang.illegalstateexception: lifecycleprocessor not initialized - call 'refresh' before invoking lifecycle methods via context: root webapplicationcontext: startup date [sat may 28 22:42:14 ist 2016]; root of context hierarchy     @ org.springframework.context.support.abstractapplicationcontext.getlifecycleprocessor(abstractapplicationcontext.java:415)     @ org.springframework.context.support.abstractapplicationcontext.doclose(abstractapplicationcontext.java:975)     @ org.springframework.context.support.abstractapplicationcontext.close(abstractapplicationcontext.java:934)     @ org.springframework.web.context.contextloader.closewebapplicationcontext(contextloader.java:559)     @ org.springframework.web.context.contextloaderlistener.contextdestroyed(contextloaderlistener.java:143)     @ org.apache.catalina.core.standardcontext.listenerstop(standardcontext.java:4776)     @ org.apache.catalina.core.standardcontext.stopinternal(standardcontext.java:5390)     @ org.apache.catalina.util.lifecyclebase.stop(lifecyclebase.java:232)     @ org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:160)     @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1408)     @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1398)     @ java.util.concurrent.futuretask.run(futuretask.java:266)     @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1142)     @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:617)     @ java.lang.thread.run(thread.java:745) 

here the

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.maven.ws</groupid> <artifactid>mavenemployee</artifactid> <packaging>war</packaging> <version>1.0</version> <name>maven ws</name> <url>http://maven.apache.org</url>  <dependencies>     <dependency>         <groupid>junit</groupid>         <artifactid>junit</artifactid>         <version>3.8.1</version>         <scope>test</scope>     </dependency>       <dependency>         <groupid>org.springframework</groupid>         <artifactid>spring-context</artifactid>         <version>4.2.6.release</version>     </dependency>      <!-- http://mvnrepository.com/artifact/org.springframework/spring-orm -->     <dependency>         <groupid>org.springframework</groupid>         <artifactid>spring-orm</artifactid>         <version>4.2.6.release</version>     </dependency>       <dependency>         <groupid>com.sun.xml.ws</groupid>         <artifactid>jaxws-rt</artifactid>         <version>2.2.10</version>     </dependency>      <!-- library java.net, integrate spring jax-ws -->     <dependency>         <groupid>org.jvnet.jax-ws-commons.spring</groupid>         <artifactid>jaxws-spring</artifactid>         <version>1.9</version>          <exclusions>             <exclusion>                 <groupid>org.springframework</groupid>                 <artifactid>spring-core</artifactid>             </exclusion>             <exclusion>                 <groupid>com.sun.xml.stream.buffer</groupid>                 <artifactid>streambuffer</artifactid>             </exclusion>             <exclusion>                 <groupid>org.jvnet.staxex</groupid>                 <artifactid>stax-ex</artifactid>             </exclusion>         </exclusions>     </dependency>    <dependency>             <groupid>com.oracle</groupid>             <artifactid>ojdbc6</artifactid>             <version>11.2.0</version>         </dependency>     <!-- http://mvnrepository.com/artifact/org.hibernate/hibernate-core -->     <dependency>         <groupid>org.hibernate</groupid>         <artifactid>hibernate-core</artifactid>         <version>5.1.0.final</version>     </dependency>      <!-- http://mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager -->     <dependency>         <groupid>org.hibernate</groupid>         <artifactid>hibernate-entitymanager</artifactid>         <version>5.1.0.final</version>     </dependency>       <!-- hibernate library dependency start -->     <dependency>         <groupid>dom4j</groupid>         <artifactid>dom4j</artifactid>         <version>1.6.1</version>     </dependency>      <dependency>         <groupid>commons-logging</groupid>         <artifactid>commons-logging</artifactid>         <version>1.1.1</version>     </dependency>      <dependency>         <groupid>commons-collections</groupid>         <artifactid>commons-collections</artifactid>         <version>3.2.1</version>     </dependency>      <dependency>         <groupid>antlr</groupid>         <artifactid>antlr</artifactid>         <version>2.7.7</version>     </dependency>     <!-- hibernate library dependency end -->      <!-- http://mvnrepository.com/artifact/commons-dbcp/commons-dbcp -->     <dependency>         <groupid>commons-dbcp</groupid>         <artifactid>commons-dbcp</artifactid>         <version>1.4</version>     </dependency>  </dependencies>  <build>     <finalname>mavenemployee</finalname> </build> 

applicationcontext.xml

    <?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans"     xmlns:ws="http://jax-ws.dev.java.net/spring/core" xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"     xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"     xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://jax-ws.dev.java.net/spring/core http://jax-ws.java.net/spring/core.xsd http://jax-ws.dev.java.net/spring/servlet http://jax-ws.java.net/spring/servlet.xsd">      <wss:binding url="/employee">         <wss:service>             <ws:service bean="#employeews" />         </wss:service>     </wss:binding>      <bean id="employeews" class="com.maven.spring.employeewsimpl">         <property name="employee" ref="employeepojo" />     </bean>      <bean id="employeepojo" class="com.maven.spring.employee">         <property name="empid" value="1234" />         <property name="name" value="steve" />         <property name="designation" value="hod"></property>     </bean>      <bean id="datasource" class="org.apache.commons.dbcp.basicdatasource">         <property name="driverclassname" value="oracle.jdbc.driver.oracledriver"></property>         <property name="url" value="jdbc:oracle:thin:@schoolpc:1721:orcl2"></property>         <property name="username" value="admin"></property>         <property name="password" value="admin123"></property>     </bean>       <bean id="sessionfactory"         class="org.springframework.orm.hibernate5.localsessionfactorybean">         <property name="datasource" ref="datasource"></property>         <property name="mappingresources">             <list>                 <value>employee.hbm.xml</value>             </list>         </property>          <property name="hibernateproperties">             <props>                 <prop key="hibernate.dialect">org.hibernate.dialect.oracle10gdialect</prop>                 <prop key="hibernate.hbm2ddl.auto">update</prop>                 <prop key="hibernate.show_sql">true</prop>             </props>         </property>     </bean>      <bean id="employeedao" class="com.maven.spring.employeedaoimpl">         <property name="sessionfactory" ref="sessionfactory"></property>     </bean>  </beans> 

employee.hbm.xml

    <?xml version="1.0" encoding="utf-8"?> <!doctype hibernate-mapping public   "-//hibernate/hibernate mapping dtd//en"  "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">  <hibernate-mapping>     <class name="com.maven.spring.employee" table="emp_rcrd">         <meta attribute="clas-description">             employee pojo         </meta>         <id name="empid" type="string" column="emp_id">         </id>         <property name="name" type="string" column="emp_name"></property>         <property name="designation" type="string" column="emp_desig"></property>     </class> </hibernate-mapping> 

web.xml

 <?xml version="1.0" encoding="utf-8"?> <web-app id="webapp_id" version="2.4"     xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"     xsi:schemalocation="http://java.sun.com/xml/ns/j2ee      http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">      <display-name>mavenemployee</display-name>      <servlet>         <servlet-name>jaxws-servlet</servlet-name>         <servlet-class>com.sun.xml.ws.transport.http.servlet.wsspringservlet</servlet-class>     </servlet>      <servlet-mapping>         <servlet-name>jaxws-servlet</servlet-name>         <url-pattern>/employee</url-pattern>     </servlet-mapping>      <!-- register spring listener -->     <listener>         <listener-class>org.springframework.web.context.contextloaderlistener</listener-class>     </listener>      <context-param>         <param-name>contextconfiglocation</param-name>         <param-value>web-inf/classes/applicationcontext.xml</param-value>     </context-param>  </web-app> 

project structure

project structure

i have been struggling error whole day. don't know missing here.

update error comes upon execution of following line in java file.

classpathxmlapplicationcontext context = new classpathxmlapplicationcontext("applicationcontext.xml");

the problem got resolved using following line of code

resource resource = new classpathresource("applicationcontext.xml"); 

instead of

classpathxmlapplicationcontext context = new classpathxmlapplicationcontext("applicationcontext.xml"); 

i still don't know reason why worked. appreciate if explain this.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -