joshlong-attic/boot-examples

ClassCastException deploying on WildFly

Closed this issue · 14 comments

21:13:44,321 INFO [org.springframework.boot.SpringApplication](MSC service thread 1-6) Started application in 3.622 seconds (JVM running for 463.148)
21:13:44,345 ERROR [org.jboss.msc.service.fail](MSC service thread 1-6) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host."/rest-and-mvc-0.0.1-SNAPSHOT": org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host."/rest-and-mvc-0.0.1-SNAPSHOT": Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.0.Final.jar:1.2.0.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_45]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_45]
at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_45]
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:216)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:86)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.start(UndertowDeploymentService.java:71)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.0.Final.jar:1.2.0.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.0.Final.jar:1.2.0.Final]
... 3 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:63)
at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:173)
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:187)
... 7 more

21:13:44,350 ERROR [org.jboss.as.controller.management-operation](management-handler-thread - 1) JBAS014613: Operation ("deploy") failed - address: ({"deployment" => "rest-and-mvc-0.0.1-SNAPSHOT.war"}) - failure description: {"JBAS014671: Failed services" => {"jboss.undertow.deployment.default-server.default-host."/rest-and-mvc-0.0.1-SNAPSHOT"" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host."/rest-and-mvc-0.0.1-SNAPSHOT": Failed to start service
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"}}
21:13:44,351 ERROR [org.jboss.as.server](management-handler-thread - 1) JBAS015870: Deploy of deployment "rest-and-mvc-0.0.1-SNAPSHOT.war" was rolled back with the following failure message:
{"JBAS014671: Failed services" => {"jboss.undertow.deployment.default-server.default-host."/rest-and-mvc-0.0.1-SNAPSHOT"" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host."/rest-and-mvc-0.0.1-SNAPSHOT": Failed to start service
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"}}
21:13:44,355 INFO [org.jboss.as.connector.deployers.jdbc](MSC service thread 1-3) JBAS010418: Stopped Driver service with driver-name = rest-and-mvc-0.0.1-SNAPSHOT.war_org.hsqldb.jdbc.JDBCDriver_2_3
21:13:44,355 INFO [org.jboss.as.connector.deployers.jdbc](MSC service thread 1-16) JBAS010418: Stopped Driver service with driver-name = rest-and-mvc-0.0.1-SNAPSHOT.war_org.h2.Driver_1_3
21:13:44,390 INFO [org.jboss.as.server.deployment](MSC service thread 1-1) JBAS015877: Stopped deployment rest-and-mvc-0.0.1-SNAPSHOT.war (runtime-name: rest-and-mvc-0.0.1-SNAPSHOT.war) in 39ms
21:13:44,392 INFO [org.jboss.as.controller](management-handler-thread - 1) JBAS014774: Service status report
JBAS014775: New missing/unsatisfied dependencies:
service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".component."com.sun.faces.config.ConfigureListener".START (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".component."javax.faces.webapp.FacetTag".START (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".component."javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV".START (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".component."javax.servlet.jsp.jstl.tlv.ScriptFreeTLV".START (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".component."org.springframework.web.servlet.tags.ArgumentTag".START (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".component."org.springframework.web.servlet.tags.BindErrorsTag".START (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".component."org.springframework.web.servlet.tags.BindTag".START (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".component."org.springframework.web.servlet.tags.EscapeBodyTag".START (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".component."org.springframework.web.servlet.tags.EvalTag".START (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".component."org.springframework.web.servlet.tags.HtmlEscapeTag".START (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".component."org.springframework.web.servlet.tags.MessageTag".START (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".component."org.springframework.web.servlet.tags.NestedPathTag".START (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".component."org.springframework.web.servlet.tags.ParamTag".START (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".component."org.springframework.web.servlet.tags.ThemeTag".START (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".component."org.springframework.web.servlet.tags.TransformTag".START (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".component."org.springframework.web.servlet.tags.UrlTag".START (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".component."org.springframework.web.servlet.tags.form.ButtonTag".START (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".component."org.springframework.web.servlet.tags.form.CheckboxTag".START (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".component."org.springframework.web.servlet.tags.form.CheckboxesTag".START (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".component."org.springframework.web.servlet.tags.form.ErrorsTag".START (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".component."org.springframework.web.servlet.tags.form.FormTag".START (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".component."org.springframework.web.servlet.tags.form.HiddenInputTag".START (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".component."org.springframework.web.servlet.tags.form.InputTag".START (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".component."org.springframework.web.servlet.tags.form.LabelTag".START (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".component."org.springframework.web.servlet.tags.form.OptionTag".START (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".component."org.springframework.web.servlet.tags.form.OptionsTag".START (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".component."org.springframework.web.servlet.tags.form.PasswordInputTag".START (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".component."org.springframework.web.servlet.tags.form.RadioButtonTag".START (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".component."org.springframework.web.servlet.tags.form.RadioButtonsTag".START (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".component."org.springframework.web.servlet.tags.form.SelectTag".START (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".component."org.springframework.web.servlet.tags.form.TextareaTag".START (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
service jboss.undertow.deployment.default-server.default-host."/rest-and-mvc-0.0.1-SNAPSHOT" (missing) dependents: [service jboss.deployment.unit."rest-and-mvc-0.0.1-SNAPSHOT.war".deploymentCompleteService]
JBAS014777: Services which failed to start: service jboss.undertow.deployment.default-server.default-host."/rest-and-mvc-0.0.1-SNAPSHOT"

21:13:47,972 ERROR stderr Exception in thread "PoolCleaner[1061993128:1393380822968]" java.lang.NoClassDefFoundError: org/apache/tomcat/jdbc/pool/FairBlockingQueue$FairIterator
21:13:47,972 ERROR stderr at org.apache.tomcat.jdbc.pool.FairBlockingQueue.iterator(FairBlockingQueue.java:233)
21:13:47,973 ERROR stderr at org.apache.tomcat.jdbc.pool.ConnectionPool.checkIdle(ConnectionPool.java:989)
21:13:47,973 ERROR stderr at org.apache.tomcat.jdbc.pool.ConnectionPool.checkIdle(ConnectionPool.java:981)
21:13:47,973 ERROR stderr at org.apache.tomcat.jdbc.pool.ConnectionPool$PoolCleaner.run(ConnectionPool.java:1348)
21:13:47,973 ERROR stderr at java.util.TimerThread.mainLoop(Timer.java:555)
21:13:47,974 ERROR stderr at java.util.TimerThread.run(Timer.java:505)
21:13:47,974 ERROR stderr Caused by: java.lang.ClassNotFoundException: org.apache.tomcat.jdbc.pool.FairBlockingQueue$FairIterator from [Module "deployment.rest-and-mvc-0.0.1-SNAPSHOT.war:main" from Service Module Loader]
21:13:47,974 ERROR stderr at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:197)
21:13:47,975 ERROR stderr at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:443)
21:13:47,975 ERROR stderr at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:431)
21:13:47,975 ERROR stderr at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:373)
21:13:47,975 ERROR stderr at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:118)
21:13:47,975 ERROR stderr ... 6 more

Download WildFly from http://download.jboss.org/wildfly/8.0.0.Final/wildfly-8.0.0.Final.zip
Unzip
Start as: ./bin/standalone.sh
Deploy: ./bin/jboss-cli.sh -c --command="deploy target/rest-and-mvc-0.0.1-SNAPSHOT.war"

You might try making the Tomcat JARs provided so they aren't included in the WAR:

    <dependency>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <groupId>org.springframework.boot</groupId>
        <scope>provided</scope>
    </dependency>

No such dependency in pom.xml. Do I need to explicitly include it and mark it provided ?

Yes, that's what we did on our project to get around similar issues.

Or, you might simply exclude o.sf.boot:Spring-boot-starter-tomcat from spring-boot-starter-web. Then it's all gone. That's the recipe I use when switching to jetty (8,9).

Seems like there are couple of ways to fix it. Can somebody fix it the right way and I'll give it another shot ?

Just exclude it as I mentioned above:

  <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>
            </exclusions>
        </dependency>

Here is the next error:

07:14:06,238 ERROR stderr Exception in thread "PoolCleaner[131265969:1393589641236]" java.lang.NoClassDefFoundError: org/apache/tomcat/jdbc/pool/FairBlockingQueue$FairIterator
07:14:06,239 ERROR stderr at org.apache.tomcat.jdbc.pool.FairBlockingQueue.iterator(FairBlockingQueue.java:233)
07:14:06,239 ERROR stderr at org.apache.tomcat.jdbc.pool.ConnectionPool.checkIdle(ConnectionPool.java:989)
07:14:06,239 ERROR stderr at org.apache.tomcat.jdbc.pool.ConnectionPool.checkIdle(ConnectionPool.java:981)
07:14:06,239 ERROR stderr at org.apache.tomcat.jdbc.pool.ConnectionPool$PoolCleaner.run(ConnectionPool.java:1348)
07:14:06,240 ERROR stderr at java.util.TimerThread.mainLoop(Timer.java:555)
07:14:06,240 ERROR stderr at java.util.TimerThread.run(Timer.java:505)
07:14:06,240 ERROR stderr Caused by: java.lang.ClassNotFoundException: org.apache.tomcat.jdbc.pool.FairBlockingQueue$FairIterator from [Module "deployment.rest-and-mvc-0.0.1-SNAPSHOT.war:main" from Service Module Loader]
07:14:06,240 ERROR stderr at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:197)
07:14:06,240 ERROR stderr at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:443)
07:14:06,241 ERROR stderr at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:431)
07:14:06,241 ERROR stderr at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:373)
07:14:06,241 ERROR stderr at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:118)
07:14:06,241 ERROR stderr ... 6 more

That is probably due to the tomcat connection pool not being on the CLASSPATH. Replace it with Commons DBCP or restore that one Tomcat jar

What change needs to be done in pom.xml ?

Hi,

I got this working by changing the pom.xml file, as detailed in this gist. I ran mvn clean install from the rest-and-mvc directory then, and cp'ied the target/rest-and-mvc*war .war to JBoss' $JBOSS_HOME/standalone/deployments directory. It was then available at http://localhost:8080/rest-and-mvc-1.0.0.RC4/bookings.html. HTH..

Did you try deploying on WildFly as well ?

I can deploy on Wildfly using this config:

 <parent>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-parent</artifactId>
      <version>1.0.0.RC3</version>
      <relativePath/>
   </parent>

   <build>
      <plugins>
         <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
         </plugin>
      </plugins>
   </build>

   <dependencies>

      <dependency>
         <groupId>javax</groupId>
         <artifactId>javaee-web-api</artifactId>
         <version>7.0</version>
         <scope>provided</scope>
      </dependency>

      <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>
         </exclusions>
      </dependency>
   </dependencies>

   <repositories>
      <repository>
         <id>spring-milestones</id>
         <name>Spring Milestones</name>
         <url>http://repo.spring.io/milestone</url>
         <snapshots>
            <enabled>false</enabled>
         </snapshots>
      </repository>
   </repositories>

@joshlong @ivargrimstad Do we know if JBoss Wildfly will be a supported Servlet container going forward?