gpt4 book ai didi

java - ServletExtension 类的问题

转载 作者:太空宇宙 更新时间:2023-11-04 13:09:23 26 4
gpt4 key购买 nike

我实现了undertow api的SevletExtention机制。代码就像

public class MyServletExtentionClass implements ServletExtension{

@Override
public void handleDeployment(final DeploymentInfo deploymentInfo, final ServletContextImpl servletContext) {
deploymentInfo.addInitialHandlerChainWrapper(new HandlerWrapper() {

@Override
public HttpHandler wrap(HttpHandler handler) {
return Handlers.path()
.addPrefixPath("/", handler)
.addPrefixPath("/hello", new MyHandler());
}
});

}
}

我还在 META_INF/services 下添加了文件 io.undertow.servlet.ServletExtension ,其内容为 com.handler.MyServletExtentionClass

但是当我在 Wildfly 中部署 war 文件时,我收到如下异常。

jboss.undertow.deployment.default-server.default-host./webapps: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./webapps: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_71]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_71]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_71]
Caused by: java.lang.AbstractMethodError
at io.undertow.servlet.core.DeploymentManagerImpl.handleExtensions(DeploymentManagerImpl.java:244)
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:149)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:87)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.start(UndertowDeploymentService.java:72)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
... 3 more

最佳答案

试试这个

...
import io.undertow.servlet.ServletExtension;
import javax.enterprise.inject.spi.Extension;

public class MyServletExtentionClass implements Extension, ServletExtension {
....

关于java - ServletExtension 类的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34129521/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com