title: Loading ApplicationContext Fails Spring java.lang.NoClassDefFoundError
body: <p>I am developing a Spring application and in the very beginning I am facing an issue, I get the following error </p>
  
  <p><code>java.lang.NoClassDefFoundError: javax/servlet/ServletContext</code>
  when try to load the <code>ApplicationContext</code> </p>
  
  <p>This is the <code>App.java</code> file which is supposed to start the Application </p>
  
  <p>public class App {</p>
  
  <pre><code>public static void main(String[] args){
  
      ApplicationContext context = new FileSystemXmlApplicationContext("/web/WEB-INF/applicationContext.xml");
  
  
      }
   }
  </code></pre>
  
  <p>This is the context of <code>applicationContext.xml</code> file </p>
  
  <pre><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"
      xsi:schemaLocation="http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"&gt;
  &lt;context:component-scan base-package="com.myapp" /&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>and this is the error I get: </p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: javax/servlet/ServletContext
  at java.lang.Class.getDeclaredMethods0(Native Method)
  at java.lang.Class.privateGetDeclaredMethods(Class.java:2688)
  at java.lang.Class.getDeclaredMethods(Class.java:1962)
  at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:612)
  at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:524)
  at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:537)
  at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:510)
  at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:570)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:683)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:627)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:597)
  at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1445)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:445)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:415)
  at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:101)
  at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:678)
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:520)
  at org.springframework.context.support.FileSystemXmlApplicationContext.&lt;init&gt;(FileSystemXmlApplicationContext.java:140)
  at org.springframework.context.support.FileSystemXmlApplicationContext.&lt;init&gt;(FileSystemXmlApplicationContext.java:84)
  at com.nudicode.Poker.App.main(App.java:14)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:483)
  at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
   Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContext
  at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
  </code></pre>
  
  <p>can anyone help me please through it and also please let me know if I have to provide more code from other part of the application.</p>