question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wildfly 10.0 deploy war 'cannot be cast to WsServerContainer' exception

See original GitHub issue

Problem

I took application from blog post: https://spring.io/blog/2014/11/23/bootiful-java-ee-support-in-spring-boot-1-2 and just up spring-boot version to 1.3.5.RELEASE (1.2.0.BUILD-SNAPSHOT don’t work too)

I tried deploy spring-boot app to WildFly server and got error.

I found that it’s don’t work.

Workaround is globally ignore tomcat-embed-websocket via “provide” maven trick like this:

<dependency>
       <artifactId>tomcat-embed-websocket</artifactId>
       <groupId>org.apache.tomcat.embed</groupId>
      <scope>provided</scope>
</dependency>

Environment:

Wildfly-10.0.0.Final Spring Boot 1.3.5.RELEASE Jdk1.8.0_31

Bug report

16:38:27,649 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 111) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./ee-test: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./ee-test: java.lang.RuntimeException: java.lang.ClassCastException: org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to io.undertow.websockets.jsr.ServerWebSocketContainer
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:85)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
    at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: java.lang.RuntimeException: java.lang.ClassCastException: org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to io.undertow.websockets.jsr.ServerWebSocketContainer
    at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:231)
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:100)
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:82)
    ... 6 more
Caused by: java.lang.ClassCastException: org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to io.undertow.websockets.jsr.ServerWebSocketContainer
    at io.undertow.websockets.jsr.Bootstrap$WebSocketListener.contextInitialized(Bootstrap.java:104)
    at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:187)
    at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:198)
    ... 8 more

16:38:27,651 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 4) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "ee-test.war")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.undertow.deployment.default-server.default-host./ee-test" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./ee-test: java.lang.RuntimeException: java.lang.ClassCastException: org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to io.undertow.websockets.jsr.ServerWebSocketContainer
    Caused by: java.lang.RuntimeException: java.lang.ClassCastException: org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to io.undertow.websockets.jsr.ServerWebSocketContainer
    Caused by: java.lang.ClassCastException: org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to io.undertow.websockets.jsr.ServerWebSocketContainer"}}
16:38:27,653 ERROR [org.jboss.as.server] (management-handler-thread - 4) WFLYSRV0021: Deploy of deployment "ee-test.war" was rolled back with the following failure message: 
{"WFLYCTL0080: Failed services" => {"jboss.undertow.deployment.default-server.default-host./ee-test" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./ee-test: java.lang.RuntimeException: java.lang.ClassCastException: org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to io.undertow.websockets.jsr.ServerWebSocketContainer
    Caused by: java.lang.RuntimeException: java.lang.ClassCastException: org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to io.undertow.websockets.jsr.ServerWebSocketContainer
    Caused by: java.lang.ClassCastException: org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to io.undertow.websockets.jsr.ServerWebSocketContainer"}}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
paveletycommented, Jul 13, 2018

To resolve this in Wildfly 11 I edited pom.xml like this

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-web</artifactId>
	<exclusions>
		<exclusion>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-tomcat</artifactId>
		</exclusion>
		<exclusion>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-logging</artifactId>
		</exclusion>
	</exclusions>
</dependency>
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-log4j2</artifactId>
	<scope>provided</scope>
</dependency>
<dependency>
	<groupId>javax</groupId>
	<artifactId>javaee-web-api</artifactId>
	<version>7.0</version>
	<scope>provided</scope>
</dependency>

Also I resolved here problems with log4j2

0reactions
wilkinsonacommented, Jun 13, 2017

@zaenk That’s Gradle and you were posting Maven snippets earlier. As you’ve shown, Gradle handles exclusions differently to Maven.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring Boot Websockets in Wildfly - Stack Overflow
Hi I need to deploy my Spring Boot app ...
Read more >
ClassCastException: org.apache.tomcat.websocket.server ...
WsServerContainer cannot be cast to io.undertow.websockets.jsr. ... are getting an exception trying to deploy our application in JBoss EAP 7.
Read more >
org.dom4j.Documen...| JBoss.org Content Archive (Read Only)
When I try to deploy my .war in a Wilfly 10.0.0 Final I get the next error. ... DocumentFactory cannot be cast to...
Read more >
Building a Spring Boot RESTful Web Service for Wildfly 8.2
RuntimeException : java.lang.ClassCastException: org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to.
Read more >
WildFly 8 / 9 / 10 - Logi Analytics
JBoss has been rebranded as WildFly. It requires JDK 1.8+ or OpenJDK 8+. For Widfly 8 and 9, use Step 1 below to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found