Spring Boot 3 Error Failed to execute goal deploy "WFLYCTL0062" on Wildfly when running mvn clean install

huangapple go评论106阅读模式
英文:

Spring Boot 3 Error Failed to execute goal deploy "WFLYCTL0062" on Wildfly when running mvn clean install

问题

每当我运行mvn clean install时,我会收到以下错误,并且无法部署到WildFly服务器。

Failed to execute goal deploy: {"WFLYCTL0062: Composite
operation failed and was rolled back. Steps that failed:" => {"Operation step-1" => {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"courese-api-app-0.0.1-SNAPSHOT.war\".component.\"jakarta.servlet.http.HttpServlet$NoBodyAsyncContextListener\".WeldInstantiator" => "Failed to start service
[ERROR]     Caused by: org.jboss.weld.resources.spi.ResourceLoadingException: Error while loading class jakarta.servlet.http.HttpServlet$NoBodyAsyncContextListener
[ERROR]     Caused by: java.lang.IncompatibleClassChangeError: jakarta.servlet.http.HttpServlet and jakarta.servlet.http.HttpServlet$NoBodyAsyncContextListener disagree on InnerClasses attribute"}}}} 

使用WildFly-4.0.0.Final

Pom文件如下:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <groupId>ch.qos.logback</groupId>
                <artifactId>logback-classic</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>com.mysql</groupId>
        <artifactId>mysql-connector-j</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
    </dependency>
    <dependency>
        <groupId>cglib</groupId>
        <artifactId>cglib</artifactId>
        <version>3.3.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>jakarta.servlet</groupId>
        <artifactId>jakarta.servlet-api</artifactId>
        <version>6.0.0</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

请告知我是否我的所有依赖项都是正确的,我在Stack Overflow上找不到任何有用的解决方案。

我的执行详细信息如下:

<executions>
    <execution>
        <phase>install</phase>
        <goals>
            <goal>deploy</goal>
        </goals>
    </execution>
</executions>
英文:

Whenever I run mvn clean install I get the error below and doesn't deploy to the WildFly server.

Failed to execute goal deploy: {&quot;WFLYCTL0062: Composite
 operation failed and was rolled back. Steps that failed:&quot; =&gt; {&quot;Operation step-1&quot; =&gt; {&quot;WFLYCTL0080: Failed services&quot; =&gt; {&quot;jboss.deployment.unit.\&quot;courese-api-app-0.0.1-SNAPSHOT.war\&quot;.component.\&quot;jakarta.servlet.http.HttpServlet$NoBodyAsyncContextListener\&quot;.WeldInstantiator&quot; =&gt; &quot;Failed to start service
[ERROR]     Caused by: org.jboss.weld.resources.spi.ResourceLoadingException: Error while loading class jakarta.servlet.http.HttpServlet$NoBodyAsyncContextListener
[ERROR]     Caused by: java.lang.IncompatibleClassChangeError: jakarta.servlet.http.HttpServlet and jakarta.servlet.http.HttpServlet$NoBodyAsyncContextListener disagree on InnerClasses attribute&quot;}}}} 

Using WildFly-4.0.0.Final

Pom file is as below:

	&lt;dependencies&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
			&lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
			&lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
			&lt;exclusions&gt;
				&lt;exclusion&gt;
					&lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;
					&lt;artifactId&gt;logback-classic&lt;/artifactId&gt;
				&lt;/exclusion&gt;
			&lt;/exclusions&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;com.mysql&lt;/groupId&gt;
			&lt;artifactId&gt;mysql-connector-j&lt;/artifactId&gt;
			&lt;scope&gt;runtime&lt;/scope&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
			&lt;artifactId&gt;spring-boot-starter-actuator&lt;/artifactId&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
			&lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
			&lt;scope&gt;test&lt;/scope&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
			&lt;artifactId&gt;lombok&lt;/artifactId&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;cglib&lt;/groupId&gt;
			&lt;artifactId&gt;cglib&lt;/artifactId&gt;
			&lt;version&gt;3.3.0&lt;/version&gt;
			&lt;scope&gt;provided&lt;/scope&gt;
		&lt;/dependency&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;jakarta.servlet&lt;/groupId&gt;
			&lt;artifactId&gt;jakarta.servlet-api&lt;/artifactId&gt;
			&lt;version&gt;6.0.0&lt;/version&gt;
			&lt;scope&gt;provided&lt;/scope&gt;
		&lt;/dependency&gt;
	&lt;/dependencies&gt;

Please advise if all my dependencies are correct, I could not find any solution on stack overflow that helps.

My execution details below:

&lt;executions&gt;
    	&lt;execution&gt;
    	    &lt;phase&gt;install&lt;/phase&gt;
    		&lt;goals&gt;
    		    &lt;goal&gt;deploy&lt;/goal&gt;
    		&lt;/goals&gt;
        &lt;/execution&gt;
&lt;/executions&gt;

答案1

得分: 0

我通过扩展主应用程序中的SpringBootServletInitializer并添加一个类型为SpringApplicationBuilder的覆盖方法configure来解决了这个问题。

@SpringBootApplication
public class CoureseApiAppApplication extends SpringBootServletInitializer {

    public static void main(String[] args) {
        SpringApplication.run(CoureseApiAppApplication.class, args);
    }

    // 如果您需要传统的WAR部署,我们需要扩展SpringBootServletInitializer
    // 这有助于我们将WAR文件部署到Jboss容器
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder springApplicationBuilder) {
        return springApplicationBuilder.sources(CoureseApiAppApplication.class);
    }
}
英文:

I managed to solve the issue by extending the SpringBootServletInitializer inside the main Application and added an override method configure of type SpringApplicationBuilder

@SpringBootApplication
public class CoureseApiAppApplication extends SpringBootServletInitializer {

	public static void main(String[] args) {
		SpringApplication.run(CoureseApiAppApplication.class, args);
	}

	//If you need a traditional war deployment we need to extend the SpringBootServletInitializer
	//This helps us deploy war files to Jboss containers
	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder springApplicationBuilder) {
		return springApplicationBuilder.sources(CoureseApiAppApplication.class);
	}
}

huangapple
  • 本文由 发表于 2023年3月8日 18:52:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/75672087.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定