You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring Boot 1.4.7-RELEASE部署报错:JSR-356支持不可用

Fixing Spring Boot 1.4.7.RELEASE Deployment Failure on Jetty (JSR-356 Support Unavailable Error)

Hey there! Let's work through this Jetty deployment issue you're facing with your Spring Boot app. That Not running on Jetty, JSR-356 support unavailable error typically stems from mismatched WebSocket dependencies or incorrect packaging for external Jetty deployment. Here's a step-by-step guide to resolve it:

1. Fix WebSocket Dependency Conflicts

Spring Boot 1.4.x includes Tomcat's WebSocket support by default if you're using spring-boot-starter-websocket. But when deploying to Jetty, we need to swap this out for Jetty's WebSocket implementation:

For Maven projects:

Add this to your pom.xml:

<!-- Replace Tomcat WebSocket with Jetty's -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-websocket</artifactId>
    <exclusions>
        <exclusion>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-websocket</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<!-- Add Jetty WebSocket dependency (matches Spring Boot 1.4.7's Jetty version) -->
<dependency>
    <groupId>org.eclipse.jetty.websocket</groupId>
    <artifactId>javax-websocket-server-impl</artifactId>
    <version>9.3.20.v20170531</version>
</dependency>

For Gradle projects:

Add this to your build.gradle:

compile('org.springframework.boot:spring-boot-starter-websocket') {
    exclude group: 'org.apache.tomcat.embed', module: 'tomcat-embed-websocket'
}
compile 'org.eclipse.jetty.websocket:javax-websocket-server-impl:9.3.20.v20170531'

2. Configure Your App for External Jetty Deployment

Since you're deploying to an external Jetty server instead of using Spring Boot's embedded container, you need to adjust your project setup:

  • Switch to WAR packaging:
    In pom.xml (Maven), set:

    <packaging>war</packaging>
    

    In build.gradle (Gradle), set:

    apply plugin: 'war'
    
  • Exclude embedded Tomcat:
    For Maven:

    <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>
    

    For Gradle:

    compile('org.springframework.boot:spring-boot-starter-web') {
        exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
    }
    
  • Add provided Servlet API dependency:
    This ensures you don't package the Servlet API with your app (Jetty already provides it):
    Maven:

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <scope>provided</scope>
    </dependency>
    

    Gradle:

    providedCompile 'javax.servlet:javax.servlet-api:3.1.0'
    
  • Update your main application class:
    Make it extend SpringBootServletInitializer to enable deployment as a WAR:

    @SpringBootApplication
    public class YourApplication extends SpringBootServletInitializer {
        @Override
        protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
            return application.sources(YourApplication.class);
        }
    
        public static void main(String[] args) {
            SpringApplication.run(YourApplication.class, args);
        }
    }
    

3. Verify Jetty Version Compatibility

Spring Boot 1.4.7.RELEASE is designed to work with Jetty 9.3.20.v20170531. Ensure your server's Jetty version matches this—mismatched versions often cause compatibility issues like this error.

4. Clean, Repackage, and Redeploy

  • Run a clean build to clear old dependencies:
    Maven: mvn clean package
    Gradle: ./gradlew clean war
  • Deploy the generated WAR file to your Jetty server's webapps directory.
  • Restart Jetty and check the logs again.

If you still run into issues, take a closer look at Jetty's full logs for additional dependency conflict details—sometimes other hidden dependencies can cause similar problems.

内容的提问来源于stack exchange,提问作者az4dan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:59:44