title: java.lang.NoClassDefFoundError: Could not initialize class org.springframework.web.util.NestedServletException
body: <p>I met an issue but I cannot figure out the cause of this problem because the error quite general.</p>
  
  <blockquote>
    <p>java.lang.NoClassDefFoundError: Could not initialize class org.springframework.web.util.NestedServletException    at
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:980)
      at
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:859)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)     at
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:844)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)     at
    org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:845)
      at
    org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:583)
      at
    org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1160)
      at
    org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511)
      at
    org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1092)
      at
    org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
      at
    org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)
      at org.eclipse.jetty.server.Server.handle(Server.java:518)  at
    org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:308)     at
    org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:244)
      at
    org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:273)
      at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
      at
    org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93)
      at
    org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:246)
      at
    org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:156)
      at
    org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
      at
    org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
      at java.lang.Thread.run(Thread.java:745)</p>
  </blockquote>
  
  <p>This is my project structure:</p>
  
  <p><a href="http://i.stack.imgur.com/53CsC.png" rel="nofollow">Project Structure</a></p>
  
  <p>It's just a very simple project that I use Embedded Jetty with SpringMVC.</p>
  
  <p>This is the <code>pom.xml</code> file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;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/xsd/maven-4.0.0.xsd"&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;com.biendltb&lt;/groupId&gt;
  &lt;artifactId&gt;com.biendltb.world_map&lt;/artifactId&gt;
  &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  &lt;packaging&gt;jar&lt;/packaging&gt;
  
  &lt;name&gt;com.biendltb.world_map&lt;/name&gt;
  
  &lt;properties&gt;
      &lt;endorsed.dir&gt;${project.build.directory}/endorsed&lt;/endorsed.dir&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;jetty.version&gt;9.3.8.v20160314&lt;/jetty.version&gt;
      &lt;spring.version&gt;4.2.5.RELEASE&lt;/spring.version&gt;
      &lt;servlet.version&gt;2.5&lt;/servlet.version&gt;
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax&lt;/groupId&gt;
          &lt;artifactId&gt;javaee-web-api&lt;/artifactId&gt;
          &lt;version&gt;7.0&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;!-- SPRING DEPENDENCY --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-aop&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-beans&lt;/artifactId&gt;
          &lt;version&gt;4.2.5.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
  
  
      &lt;!-- JETTY DEPENDENCY --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.eclipse.jetty&lt;/groupId&gt;
          &lt;artifactId&gt;jetty-server&lt;/artifactId&gt;
          &lt;version&gt;${jetty.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.eclipse.jetty&lt;/groupId&gt;
          &lt;artifactId&gt;jetty-servlet&lt;/artifactId&gt;
          &lt;version&gt;${jetty.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.eclipse.jetty&lt;/groupId&gt;
          &lt;artifactId&gt;jetty-webapp&lt;/artifactId&gt;
          &lt;version&gt;${jetty.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- SERVLET DEPENDENCY --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
          &lt;version&gt;${servlet.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- COMMON LOGGING DEPENDENCY --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;commons-logging&lt;/groupId&gt;
          &lt;artifactId&gt;commons-logging&lt;/artifactId&gt;
          &lt;version&gt;1.1.3&lt;/version&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;version&gt;3.1&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;source&gt;1.7&lt;/source&gt;
                  &lt;target&gt;1.7&lt;/target&gt;
                  &lt;compilerArguments&gt;
                      &lt;endorseddirs&gt;${endorsed.dir}&lt;/endorseddirs&gt;
                  &lt;/compilerArguments&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.6&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;phase&gt;validate&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;copy&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;configuration&gt;
                          &lt;outputDirectory&gt;${endorsed.dir}&lt;/outputDirectory&gt;
                          &lt;silent&gt;true&lt;/silent&gt;
                          &lt;artifactItems&gt;
                              &lt;artifactItem&gt;
                                  &lt;groupId&gt;javax&lt;/groupId&gt;
                                  &lt;artifactId&gt;javaee-endorsed-api&lt;/artifactId&gt;
                                  &lt;version&gt;7.0&lt;/version&gt;
                                  &lt;type&gt;jar&lt;/type&gt;
                              &lt;/artifactItem&gt;
                          &lt;/artifactItems&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.eclipse.jetty&lt;/groupId&gt;
              &lt;artifactId&gt;jetty-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;9.3.7.v20160115&lt;/version&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.4&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;warSourceDirectory&gt;WebContent&lt;/warSourceDirectory&gt;
                  &lt;failOnMissingWebXml&gt;false&lt;/failOnMissingWebXml&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-shade-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.4.3&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;phase&gt;package&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;shade&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;configuration&gt;
                          &lt;createDependencyReducedPom&gt;false&lt;/createDependencyReducedPom&gt;
                          &lt;transformers&gt;
                              &lt;transformer
                                  implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"&gt;
                                  &lt;mainClass&gt;com.biendltb.main_server.TripMapServer&lt;/mainClass&gt;
                              &lt;/transformer&gt;
                          &lt;/transformers&gt;
                          &lt;filters&gt;
                              &lt;filter&gt;
                                  &lt;artifact&gt;*:*&lt;/artifact&gt;
                                  &lt;excludes&gt;
                                      &lt;exclude&gt;META-INF/*.SF&lt;/exclude&gt;
                                      &lt;exclude&gt;META-INF/*.DSA&lt;/exclude&gt;
                                      &lt;exclude&gt;META-INF/*.RSA&lt;/exclude&gt;
                                  &lt;/excludes&gt;
                              &lt;/filter&gt;
                          &lt;/filters&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-resources-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.7&lt;/version&gt;
              &lt;dependencies&gt;
                  &lt;dependency&gt;
                      &lt;groupId&gt;org.apache.maven.shared&lt;/groupId&gt;
                      &lt;artifactId&gt;maven-filtering&lt;/artifactId&gt;
                      &lt;version&gt;1.3&lt;/version&gt;
                  &lt;/dependency&gt;
              &lt;/dependencies&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
      &lt;resources&gt;
          &lt;resource&gt;
              &lt;targetPath&gt;webapp&lt;/targetPath&gt;
              &lt;directory&gt;src/main/webapp&lt;/directory&gt;
          &lt;/resource&gt;
          &lt;resource&gt;
              &lt;directory&gt;src/main/resources&lt;/directory&gt;
          &lt;/resource&gt;
      &lt;/resources&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p></p>
  
  <p>This is the <code>main</code> class:</p>
  
  <pre><code>public class TripMapServer {
  
      private static final int DEFAULT_PORT = 8080;
      private static final String CONTEXT_PATH = "/";
      private static final String MAPPING_URL = "/*";
      private static final String CONFIG_LOCATION = "com.biendltb.config";
      private static final String DEFAULT_PROFILE = "dev";
  
      public static void main(String[] args) throws Exception {
          new TripMapServer().startJetty(getPortFromArgs(args));
      }
  
      private static int getPortFromArgs(String[] args) {
          if (args.length &gt; 0) {
              try {
                  return Integer.valueOf(args[0]);
              } catch (NumberFormatException ignore) {
              }
          }
          return DEFAULT_PORT;
      }
  
      private void startJetty(int port) throws Exception {
          Server server = new Server(port);
          server.setHandler(getServletContextHandler(getContext()));
          server.start();
          server.join();
      }
  
      private static ServletContextHandler getServletContextHandler(WebApplicationContext context) throws IOException {
          ServletContextHandler contextHandler = new ServletContextHandler();
          contextHandler.setErrorHandler(null);
          contextHandler.setContextPath(CONTEXT_PATH);
          contextHandler.addServlet(new ServletHolder("default", new DispatcherServlet(context)), MAPPING_URL);
          contextHandler.addEventListener(new ContextLoaderListener(context));
          contextHandler.setResourceBase(new ClassPathResource("webapp").getURI().toString());
          return contextHandler;
      }
  
      private static WebApplicationContext getContext() {
          AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
          context.setConfigLocation(CONFIG_LOCATION);
          context.getEnvironment().setDefaultProfiles(DEFAULT_PROFILE);
          return context;
      }
  }
  </code></pre>
  
  <p>And this is the class <code>WebConfig.java</code> instead <code>.xml</code> file:</p>
  
  <pre><code>@Configuration
  @EnableWebMvc
  @Import({DefaultConfig.class})
  @ComponentScan(basePackages = {"com.biendltb.controller"})
  public class WebConfig extends WebMvcConfigurerAdapter{
      private static final Charset UTF8 = Charset.forName("UTF-8");
  
      @Autowired
      public Environment env;
  
      @Override
      public void configureMessageConverters(List&lt;HttpMessageConverter&lt;?&gt;&gt; converters) {
          converters.add(stringConverter());
      }
  
      private StringHttpMessageConverter stringConverter() {
          StringHttpMessageConverter stringConverter = new StringHttpMessageConverter();
          stringConverter.setSupportedMediaTypes(Arrays.asList(new MediaType("text", "plain", UTF8)));
          return stringConverter;
      }
  
      @Override
      public void addResourceHandlers(ResourceHandlerRegistry registry) {
          registry.addResourceHandler("/assets/**").addResourceLocations("classpath:/src/main/resources/").setCachePeriod(Integer.MAX_VALUE);
          registry.addResourceHandler("/js/**").addResourceLocations("/js/").setCachePeriod(Integer.MAX_VALUE);
          registry.addResourceHandler("/css/**").addResourceLocations("/css/").setCachePeriod(Integer.MAX_VALUE);
          registry.addResourceHandler("/img/**").addResourceLocations("/img/").setCachePeriod(Integer.MAX_VALUE);
      }
  
      @Override
      public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
          configurer.enable();
      }
  
      @Bean
      public InternalResourceViewResolver getInternalResourceViewResolver() {
          InternalResourceViewResolver resolver = new InternalResourceViewResolver();
          resolver.setPrefix("/src/main/resources/pages/");
          resolver.setSuffix(".jsp");
          return resolver;
      }
  }
  </code></pre>
  
  <p>Please help figure out the cause or how to trace that error.</p>
  
  <p>Thank you very much!</p>