title: Tomcat 7 + Grails 3.1.10 - ClassNotFoundException: javax.servlet.http.HttpUpgradeHandler
body: <p><strong>Development environment:</strong></p>
  
  <ul>
  <li>Grails 3.1.10</li>
  <li>Java: version "1.8.0_72" (Java HotSpot(TM) 64-Bit)</li>
  <li>Ubuntu 14.04</li>
  </ul>
  
  <p><strong>Production environment (app deployment):</strong></p>
  
  <ul>
  <li>Java: version "1.8.0_101-b13" (Java OpenJDK 64-Bit Server VM)</li>
  <li>Tomcat: 7.0.57</li>
  </ul>
  
  <p><strong>build.gradle:</strong></p>
  
  <pre><code>dependencies {
      compile "org.springframework.boot:spring-boot-starter-logging"
      compile "org.springframework.boot:spring-boot-autoconfigure"
      compile "org.grails:grails-core"
      compile "org.springframework.boot:spring-boot-starter-actuator"
      //compile "org.springframework.boot:spring-boot-starter-tomcat"
      compile "org.grails:grails-dependencies"
      compile "org.grails:grails-web-boot"
      compile "org.grails.plugins:cache"
      compile "org.grails.plugins:scaffolding"
      compile "org.grails.plugins:hibernate4"
      compile "org.hibernate:hibernate-ehcache"
      console "org.grails:grails-console"
      profile "org.grails.profiles:web"
      runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.8.2"
      runtime "com.h2database:h2"
      testCompile "org.grails:grails-plugin-testing"
      testCompile "org.grails.plugins:geb"
      testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
      testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
  
      compile 'org.grails.plugins:views-json:1.0.0'
  
      compile 'org.grails.plugins:spring-security-core:3.1.1'
      compile "org.grails.plugins:spring-security-rest:2.0.0.M2"
      compile 'net.sourceforge.jtds:jtds:1.3.1'
      runtime 'org.grails.plugins:grails-console:2.0.8'
  
      //deve ser inserido para rodar num tomcat externo
      provided "org.springframework.boot:spring-boot-starter-tomcat"
  }
  </code></pre>
  
  <p>Since I'm not using the Grails embedded Tomcat it's necessary to change the dependecy <code>"org.springframework.boot:spring-boot-starter-tomcat"</code> from <strong>compile</strong> to <strong>provided</strong>.</p>
  
  <p><strong>I'm facing the following issue:</strong></p>
  
  <p>The app runs perfectly fine on my Development environment, but when I deploy the app to Server environment I get the following exception:</p>
  
  <pre><code>ERROR org.springframework.boot.context.web.ErrorPageFilter - Forwarding to error page from request [/api/samplingPlan] due to exception [javax/servlet/http/HttpUpgradeHandler]
  java.lang.NoClassDefFoundError: javax/servlet/http/HttpUpgradeHandler
      at java.lang.Class.getDeclaredMethods0(Native Method)
      at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
      at java.lang.Class.privateGetPublicMethods(Class.java:2902)
      at java.lang.Class.getMethods(Class.java:1615)
      at java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1336)
      at java.beans.Introspector.getTargetMethodInfo(Introspector.java:1197)
      at java.beans.Introspector.getBeanInfo(Introspector.java:426)
      at java.beans.Introspector.getBeanInfo(Introspector.java:173)
      at groovy.lang.MetaClassImpl$15.run(MetaClassImpl.java:3290)
      at java.security.AccessController.doPrivileged(Native Method)
      at groovy.lang.MetaClassImpl.addProperties(MetaClassImpl.java:3288)
      at groovy.lang.MetaClassImpl.initialize(MetaClassImpl.java:3265)
      at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:254)
      at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:285)
      at grails.views.mvc.GenericGroovyTemplateView$HttpViewRequest.$getStaticMetaClass(GenericGroovyTemplateView.groovy)
      at grails.views.mvc.GenericGroovyTemplateView$HttpViewRequest.&lt;init&gt;(GenericGroovyTemplateView.groovy)
      at grails.views.mvc.GenericGroovyTemplateView.prepareWritable(GenericGroovyTemplateView.groovy:96)
      at grails.views.mvc.GenericGroovyTemplateView.renderMergedOutputModel(GenericGroovyTemplateView.groovy:59)
      at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)
      at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1246)
      at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1029)
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:973)
      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:895)
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967)
      at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:858)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
      at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at javax.servlet.FilterChain$doFilter.call(Unknown Source)
      at Tomcat 7.0.57org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      at javax.servlet.FilterChain$doFilter.call(Unknown Source)
      at grails.plugin.springsecurity.rest.RestLogoutFilter.doFilter(RestLogoutFilter.groovy:80)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at br.com.sgsgeosol.sampling.CorsFilter.doFilter(CorsFilter.java:40)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration$ApplicationContextHeaderFilter.doFilterInternal(EndpointWebMvcAutoConfiguration.java:281)
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:115)
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:316)
      at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126)
      at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
      at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
      at javax.servlet.FilterChain$doFilter.call(Unknown Source)
      at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
      at grails.plugin.springsecurity.rest.RestTokenValidationFilter.processFilterChain(RestTokenValidationFilter.groovy:118)
      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:498)
      at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
      at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
      at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:190)
      at grails.plugin.springsecurity.rest.RestTokenValidationFilter.doFilter(RestTokenValidationFilter.groovy:84)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
      at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:169)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
      at javax.servlet.FilterChain$doFilter.call(Unknown Source)
      at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      at javax.servlet.FilterChain$doFilter.call(Unknown Source)
      at grails.plugin.springsecurity.rest.RestAuthenticationFilter.doFilter(RestAuthenticationFilter.groovy:143)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
      at grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.groovy:62)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
      at grails.plugin.springsecurity.web.SecurityRequestHolderFilter.doFilter(SecurityRequestHolderFilter.groovy:58)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
      at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:213)
      at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:176)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:75)
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.grails.web.filters.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:67)
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:103)
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.springframework.boot.context.web.ErrorPageFilter.doFilter(ErrorPageFilter.java:120)
      at org.springframework.boot.context.web.ErrorPageFilter.access$000(ErrorPageFilter.java:61)
      at org.springframework.boot.context.web.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:95)
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      at org.springframework.boot.context.web.ErrorPageFilter.doFilter(ErrorPageFilter.java:113)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      at java.lang.Thread.run(Thread.java:745)
  Caused by: java.lang.ClassNotFoundException: javax.servlet.http.HttpUpgradeHandler
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
      ... 125 common frames omitted
  </code></pre>
  
  <p><strong>Some important facts:</strong></p>
  
  <ul>
  <li>The app runs perfectly fine on my Development Environment;</li>
  <li>This exception occurs in a REST call. Others call works fine (GSP, for example).</li>
  <li>We have others app (Grails 2.5.x) running perfectly fine on OpenJDK/Tomcat 7.0.57;</li>
  <li>We have others app (non Grails) running perfectly fine on OpenJDK/Tomcat 7.0.57;</li>
  </ul>
  
  <p><strong>Question:</strong></p>
  
  <p>Why I'm getting <code>java.lang.NoClassDefFoundError</code> and <code>java.lang.ClassNotFoundException</code> on <code>javax.servlet.http.HttpUpgradeHandler</code> when I depoly my app to Tomcat 7.0.57?</p>