title: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
body: <p>I have been struggling at successfully implementing openId in spring from last 3 weeks now.
  Please help me out with it.</p>
  
  <p>I tried to implement it from <a href="http://krams915.blogspot.in/2011/02/spring-security-3-openid-login-with_13.html" rel="nofollow">http://krams915.blogspot.in/2011/02/spring-security-3-openid-login-with_13.html</a>, now i m getting an exception.
  console log:</p>
  
  <pre><code>SEVERE: Exception sending context initialized event to listener instance of class        org.springframework.web.context.ContextLoaderListener
  java.lang.NoClassDefFoundError: org/openid4java/consumer/ConsumerException
  at java.lang.Class.getDeclaredConstructors0(Native Method)
  at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
  at java.lang.Class.getDeclaredConstructors(Class.java:1836)
  at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:228)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:911)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:884)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
  at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:562)
  at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871)
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
  at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:272)
  at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:196)
  at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
  at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
  at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
  at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
  at java.util.concurrent.FutureTask.run(FutureTask.java:138)
  at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
  at java.lang.Thread.run(Thread.java:662)
  Caused by: java.lang.ClassNotFoundException: org.openid4java.consumer.ConsumerException
  at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
  at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
  ... 28 more
  </code></pre>
  
  <p>my web.xml:</p>
  
  
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;  
   &lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"  
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;  
  
   &lt;filter&gt;
      &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
  
       &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-       class&gt;
  &lt;/filter&gt;
  
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;   &lt;/filter-mapping&gt;
  
  &lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;
      /WEB-INF/spring-security.xml
      /WEB-INF/applicationContext.xml
      &lt;/param-value&gt;
  &lt;/context-param&gt;
  
  &lt;servlet&gt;  
      &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;  
      &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;  
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;  
  &lt;/servlet&gt;  
  
  &lt;servlet-mapping&gt;  
      &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;  
      &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt;  
  &lt;/servlet-mapping&gt; 
  
  &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
  &lt;/listener&gt;
  
  &lt;welcome-file-list&gt;  
      &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;  
  &lt;/welcome-file-list&gt;  
  </code></pre>
  
  <p> </p>
  
  <p>Dispatcher.servlet:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
     &lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns:context="http://www.springframework.org/schema/context"
  xmlns:tx="http://www.springframework.org/schema/tx"
  xmlns:oxm="http://www.springframework.org/schema/oxm"
  xsi:schemaLocation="
      http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
      http://www.springframework.org/schema/context
      http://www.springframework.org/schema/context/spring-context-3.0.xsd
      http://www.springframework.org/schema/tx
      http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
      http://www.springframework.org/schema/oxm
      http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd"&gt;
  
  &lt;context:property-placeholder location="classpath:jdbc.properties" /&gt;
  &lt;context:component-scan base-package="com.kratin" /&gt;
  
  &lt;bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"&gt;
      &lt;property name="order" value="1" /&gt;
      &lt;property name="messageConverters"&gt;
          &lt;list&gt;
              &lt;!-- Default converters --&gt;
              &lt;bean class="org.springframework.http.converter.StringHttpMessageConverter"/&gt;
              &lt;bean class="org.springframework.http.converter.FormHttpMessageConverter"/&gt;
              &lt;bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter" /&gt;
              &lt;bean class="org.springframework.http.converter.xml.SourceHttpMessageConverter"/&gt;
              &lt;bean class="org.springframework.http.converter.BufferedImageHttpMessageConverter"/&gt;
              &lt;bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" /&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;tx:annotation-driven transaction-manager="hibernateTransactionManager" /&gt;
  
  &lt;bean id="jspViewResolver"
      class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
      &lt;property name="viewClass"
          value="org.springframework.web.servlet.view.JstlView" /&gt;
      &lt;property name="prefix" value="/WEB-INF/view/" /&gt;
      &lt;property name="suffix" value=".jsp" /&gt;
  &lt;/bean&gt; 
  
  &lt;bean id="dataSource"
      class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
      &lt;property name="driverClassName" value="${database.driver}" /&gt;
      &lt;property name="url" value="${database.url}" /&gt;
      &lt;property name="username" value="${database.user}" /&gt;
      &lt;property name="password" value="${database.password}" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="sessionFactory"
      class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;property name="annotatedClasses"&gt;
          &lt;list&gt;
              &lt;value&gt;com.kratin.domain.User&lt;/value&gt;
          &lt;/list&gt;
      &lt;/property&gt;
      &lt;property name="hibernateProperties"&gt;
          &lt;props&gt;
              &lt;prop key="hibernate.dialect"&gt;${hibernate.dialect}&lt;/prop&gt;
              &lt;prop key="hibernate.show_sql"&gt;${hibernate.show_sql}&lt;/prop&gt;
          &lt;/props&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="hibernateTransactionManager"
      class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt;
      &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p></p>
  
  <p>spring-security.xml:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns:security="http://www.springframework.org/schema/security"
  xsi:schemaLocation="http://www.springframework.org/schema/beans 
          http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
          http://www.springframework.org/schema/security 
          http://www.springframework.org/schema/security/spring-security-3.0.xsd"&gt;
  
  &lt;!-- This is where we configure Spring-Security  --&gt;
  &lt;security:http auto-config="true" use-expressions="true" access-denied-page="/rest/auth/denied" &gt;
  
      &lt;security:intercept-url pattern="/rest/auth/login" access="permitAll"/&gt;
      &lt;security:intercept-url pattern="/rest/main/admin" access="hasRole('ROLE_ADMIN')"/&gt;
      &lt;security:intercept-url pattern="/rest/main/common" access="hasRole('ROLE_USER')"/&gt;
  
      &lt;!-- Adding the openid-login tag activates Spring Security's support for OpenID  --&gt;
      &lt;security:openid-login
              login-page="/rest/auth/login" 
              authentication-failure-url="/rest/auth/login?error=true" 
              default-target-url="/rest/main/common"/&gt;
  
      &lt;security:logout 
              invalidate-session="true" 
              logout-success-url="/rest/auth/login" 
              logout-url="/rest/auth/logout"/&gt;
  
  &lt;/security:http&gt;
  
  &lt;!-- Declare an authentication-manager to use a custom userDetailsService --&gt;
  &lt;security:authentication-manager&gt;
          &lt;security:authentication-provider user-service-ref="userDetailsService"&gt;
                  &lt;security:password-encoder ref="passwordEncoder"/&gt;
          &lt;/security:authentication-provider&gt;
  &lt;/security:authentication-manager&gt;
  
  &lt;!-- Use a Md5 encoder since the user's passwords are stored as Md5 in the database --&gt;
  &lt;bean class="org.springframework.security.authentication.encoding.Md5PasswordEncoder" id="passwordEncoder"/&gt;
  
   &lt;!-- An in-memory list of users. No need to access an external database layer.
          See Spring Security 3.1 Reference 5.2.1 In-Memory Authentication --&gt;
   &lt;security:user-service id="userDetailsService"&gt;
      &lt;!-- user name is based on the returned OpenID identifier from Google --&gt;
      &lt;security:user name="https://www.google.com/accounts/o8/id?id=AItxxioJSDLFJLjxcksdfjOpAASDFosSSoJ0E" 
                          password="" authorities="ROLE_USER, ROLE_ADMIN" /&gt;
   &lt;/security:user-service&gt;
  </code></pre>
  
  <p></p>
  
  <p>applicationContext.xml:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns:context="http://www.springframework.org/schema/context"
  xmlns:mvc="http://www.springframework.org/schema/mvc"
  xsi:schemaLocation="http://www.springframework.org/schema/beans 
          http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
          http://www.springframework.org/schema/context
          http://www.springframework.org/schema/context/spring-context-3.0.xsd
          http://www.springframework.org/schema/mvc 
          http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"&gt;
  
  &lt;!-- Activates various annotations to be detected in bean classes --&gt;
  &lt;context:annotation-config /&gt;
  
  &lt;!-- Scans the classpath for annotated components that will be auto-registered as Spring beans.
   For example @Controller and @Service. Make sure to set the correct base-package--&gt;
  &lt;context:component-scan base-package="com.kratin" /&gt;
  
  &lt;!-- Configures the annotation-driven Spring MVC Controller programming model.
  Note that, with Spring 3.0, this tag works in Servlet MVC only!  --&gt;
  &lt;mvc:annotation-driven /&gt; 
  </code></pre>
  
  <p></p>