Skip to content

Tomcat 8.0: java.lang.ClassNotFoundException: org.apache.coyote.UpgradeProtocol #10960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
candrews opened this issue Nov 9, 2017 · 4 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@candrews
Copy link
Contributor

candrews commented Nov 9, 2017

Running Spring Boot 2.0.0.M6 on Tomcat 8.0 (I'm using 8.0.45, which is the version currently used by AWS Elastic Beanstalk), the follow exception occurs at startup preventing the application from starting. Note that this exception occurs regardless of the value of server.http2.enabled - there is no way (that I can figure out) to run Spring Boot 2.0.0.M6 on Tomcat < 8.5.

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tomcatServletWebServerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfiguration$EmbeddedTomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory]: Factory method 'tomcatServletWebServerFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/coyote/UpgradeProtocol
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:583) ~[spring-beans-5.0.1.RELEASE.jar:5.0.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1249) ~[spring-beans-5.0.1.RELEASE.jar:5.0.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1098) ~[spring-beans-5.0.1.RELEASE.jar:5.0.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-5.0.1.RELEASE.jar:5.0.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502) ~[spring-beans-5.0.1.RELEASE.jar:5.0.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312) ~[spring-beans-5.0.1.RELEASE.jar:5.0.1.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.1.RELEASE.jar:5.0.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) ~[spring-beans-5.0.1.RELEASE.jar:5.0.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-5.0.1.RELEASE.jar:5.0.1.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:756) ~[spring-beans-5.0.1.RELEASE.jar:5.0.1.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868) ~[spring-context-5.0.1.RELEASE.jar:5.0.1.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.0.1.RELEASE.jar:5.0.1.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:122) ~[spring-boot-2.0.0.M6.jar:2.0.0.M6]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:751) ~[spring-boot-2.0.0.M6.jar:2.0.0.M6]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:387) ~[spring-boot-2.0.0.M6.jar:2.0.0.M6]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) ~[spring-boot-2.0.0.M6.jar:2.0.0.M6]
	at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:155) [spring-boot-2.0.0.M6.jar:2.0.0.M6]
	at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:135) [spring-boot-2.0.0.M6.jar:2.0.0.M6]
	at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:87) [spring-boot-2.0.0.M6.jar:2.0.0.M6]
	at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:172) [spring-web-5.0.1.RELEASE.jar:5.0.1.RELEASE]
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303) [catalina.jar:8.0.45]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) [catalina.jar:8.0.45]
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753) [catalina.jar:8.0.45]
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:729) [catalina.jar:8.0.45]
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717) [catalina.jar:8.0.45]
	at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1129) [catalina.jar:8.0.45]
	at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1871) [catalina.jar:8.0.45]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_141]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_141]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_141]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_141]
	at java.lang.Thread.run(Thread.java:748) [na:1.8.0_141]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory]: Factory method 'tomcatServletWebServerFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/coyote/UpgradeProtocol
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:186) ~[spring-beans-5.0.1.RELEASE.jar:5.0.1.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:575) ~[spring-beans-5.0.1.RELEASE.jar:5.0.1.RELEASE]
	... 31 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/apache/coyote/UpgradeProtocol
	at org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration$EmbeddedTomcat.tomcatServletWebServerFactory(ServletWebServerFactoryAutoConfiguration.java:93) ~[spring-boot-autoconfigure-2.0.0.M6.jar:2.0.0.M6]
	at org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration$EmbeddedTomcat$$EnhancerBySpringCGLIB$$741ce4cb.CGLIB$tomcatServletWebServerFactory$0(<generated>) ~[spring-boot-autoconfigure-2.0.0.M6.jar:2.0.0.M6]
	at org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration$EmbeddedTomcat$$EnhancerBySpringCGLIB$$741ce4cb$$FastClassBySpringCGLIB$$9a5a8a82.invoke(<generated>) ~[spring-boot-autoconfigure-2.0.0.M6.jar:2.0.0.M6]
	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-5.0.1.RELEASE.jar:5.0.1.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361) ~[spring-context-5.0.1.RELEASE.jar:5.0.1.RELEASE]
	at org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration$EmbeddedTomcat$$EnhancerBySpringCGLIB$$741ce4cb.tomcatServletWebServerFactory(<generated>) ~[spring-boot-autoconfigure-2.0.0.M6.jar:2.0.0.M6]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_141]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_141]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_141]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_141]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:155) ~[spring-beans-5.0.1.RELEASE.jar:5.0.1.RELEASE]
	... 32 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.apache.coyote.UpgradeProtocol
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1333) ~[catalina.jar:8.0.45]
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167) ~[catalina.jar:8.0.45]
	... 43 common frames omitted
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 9, 2017
@wilkinsona wilkinsona added priority: normal type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 9, 2017
@wilkinsona wilkinsona added this to the 2.0.0.M7 milestone Nov 9, 2017
@wilkinsona wilkinsona self-assigned this Nov 9, 2017
@candrews
Copy link
Contributor Author

candrews commented Nov 9, 2017

@wilkinsona Do you have any suggestions as to how I can work around this issue with 2.0.0.M6?

@wilkinsona
Copy link
Member

Excluding org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration via your @SpringBootApplication annotation's exclude attribute should do the trick

@MrBuddyCasino
Copy link

MrBuddyCasino commented Nov 27, 2017

I have the same problem, @wilkinsona 's suggestion worked.

@arnonuem
Copy link

arnonuem commented Dec 1, 2017

I am working with Tomcat 8.0.36 and have not seen this issue.
@candrews Which Tomcat 8 version do you use?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

5 participants