title: Why I cannot initialize group definition from jar file?
body: <p>I am trying to create bean from jar file from our company to retrieve data from database.
  I added</p>
  
  <pre><code>&lt;context-param&gt;
      &lt;param-name&gt;parentContextKey&lt;/param-name&gt;
      &lt;param-value&gt;common.context&lt;/param-value&gt;
  &lt;/context-param&gt;
  </code></pre>
  
  <p>to my web.xml,
  then there are some errors happened</p>
  
  <p>Here is stacktrace:</p>
  
  <pre><code>Nov 01, 2013 2:42:54 PM org.apache.catalina.core.StandardContext listenerStart
  SEVERE: Exception sending context initialized event to listener instance of class
  org.springframework.web.context.ContextLoaderListener
  org.springframework.beans.factory.access.BootstrapException: Unable to initialize group   definition. Group resource name [classpath*:beanRefContext.xml], factory key [common.context]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'common.context' defined in URL [jar:file:/C:/tomcat/lib/student2-common.jar!/beanRefContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.context.support.ClassPathXmlApplicationContext]: Constructor threw exception; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [edu.ucsd.act.student2.common.email.JavaEmailSender] for bean with name 'javaEmailSender' defined in URL [jar:file:/C:/tomcat/lib/student2-common.jar!/edu/ucsd/act/student2/common/email/JavaEmailSender.class]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/springframework/mail/javamail/JavaMailSenderImpl
  at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.useBeanFactory(SingletonBeanFactoryLocator.java:386)
  at org.springframework.web.context.ContextLoader.loadParentContext(ContextLoader.java:536)
  at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:376)
  at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
  at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
  at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
  at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
  at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
  at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
  at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
  at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
  at org.apache.catalina.core.StandardService.start(StandardService.java:525)
  at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
  at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  at java.lang.reflect.Method.invoke(Unknown Source)
  at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
  at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
  
  Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'common.context' defined in URL [jar:file:/C:/tomcat/lib/student2-common.jar!/beanRefContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.context.support.ClassPathXmlApplicationContext]: Constructor threw exception; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [edu.ucsd.act.student2.common.email.JavaEmailSender] for bean with name 'javaEmailSender' defined in URL [jar:file:/C:/tomcat/lib/student2-common.jar!/edu/ucsd/act/student2/common/email/JavaEmailSender.class]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/springframework/mail/javamail/JavaMailSenderImpl
  at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:288)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1035)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:939)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
  at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
  at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
  at org.springframework.context.access.ContextSingletonBeanFactoryLocator.initializeDefinition(ContextSingletonBeanFactoryLocator.java:143)
  at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.useBeanFactory(SingletonBeanFactoryLocator.java:381)
  ... 19 more
  
  Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.context.support.ClassPathXmlApplicationContext]: Constructor threw exception; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [edu.ucsd.act.student2.common.email.JavaEmailSender] for bean with name 'javaEmailSender' defined in URL [jar:file:/C:/tomcat/lib/student2-common.jar!/edu/ucsd/act/student2/common/email/JavaEmailSender.class]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/springframework/mail/javamail/JavaMailSenderImpl
  at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:162)
  at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:110)
  at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:280)
  ... 32 more
  
  Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [edu.ucsd.act.student2.common.email.JavaEmailSender] for bean with name 'javaEmailSender' defined in URL [jar:file:/C:/tomcat/lib/student2-common.jar!/edu/ucsd/act/student2/common/email/JavaEmailSender.class]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/springframework/mail/javamail/JavaMailSenderImpl
  at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1265)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:576)
  at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1331)
  at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:897)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:566)
  at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
  at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:139)
  at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:93)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
  at java.lang.reflect.Constructor.newInstance(Unknown Source)
  at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
  ... 34 more
  
  Caused by: java.lang.NoClassDefFoundError: org/springframework/mail/javamail/JavaMailSenderImpl
  at java.lang.ClassLoader.findBootstrapClass(Native Method)
  at java.lang.ClassLoader.findBootstrapClassOrNull(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1595)
  at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
  at org.springframework.util.ClassUtils.forName(ClassUtils.java:258)
  at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:417)
  at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1283)
  at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1254)
  ... 47 more
  
  
  Nov 01, 2013 2:42:54 PM org.apache.catalina.core.StandardContext start
  SEVERE: Error listenerStart
  Nov 01, 2013 2:42:54 PM org.apache.catalina.core.StandardContext start
  SEVERE: Context [/studentMyEnrollment] startup failed due to previous errors
  </code></pre>
  
  <p>I thought this was because I am missing a jar file contain org/springframework/mail/javamail/JavaMailSenderImpl
  this particular file is in springframework-context-support jar file and I do have it and build the path of it
  Now I have no idea why is this happening when I start tomcat server.
  Here is my web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"&gt;
  
  &lt;display-name&gt;...&lt;/display-name&gt;
  
  &lt;context-param&gt;
      &lt;param-name&gt;parentContextKey&lt;/param-name&gt;
      &lt;param-value&gt;common.context&lt;/param-value&gt;
  &lt;/context-param&gt;
  
  &lt;!-- spring context --&gt;
  &lt;context-param&gt;
  &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
  &lt;param-value&gt;/WEB-INF/config/ApplicationContext.xml&lt;/param-value&gt;
  &lt;/context-param&gt;    
  
  &lt;listener&gt;
  &lt;listener-class&gt;
    org.springframework.web.context.ContextLoaderListener
  &lt;/listener-class&gt;
  &lt;/listener&gt;
  
  &lt;servlet&gt;
  &lt;servlet-name&gt;mvc-dispatcher&lt;/servlet-name&gt;
  &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
  &lt;init-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;/WEB-INF/config/mvc-dispatcher-servlet.xml&lt;/param-value&gt;
  &lt;/init-param&gt;
  &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
  &lt;servlet-name&gt;mvc-dispatcher&lt;/servlet-name&gt;
  &lt;url-pattern&gt;*.html&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;...&lt;/welcome-file&gt;
      &lt;welcome-file&gt;...&lt;/welcome-file&gt;
  &lt;/welcome-file-list&gt;
  
  &lt;/web-app&gt;
  </code></pre>