gpt4 book ai didi

java - 防止执行 ServletContainerInitializer 或如何使用绝对顺序

转载 作者:搜寻专家 更新时间:2023-10-30 23:02:37 25 4
gpt4 key购买 nike

是否可以阻止提供的 jar 的 ServletContainerInitializer 的执行。

我想阻止 JerseyServletContainerInitializer.java 的执行它由 Glassfish 4.1 作为 osgi-bundle 提供(在 jersey-container-servlet.jar 中)。

或者我如何使用 <absolute-order> web.xml 以强制加载 ResteasyServletInitializer.javaresteasy-servlet-initializer-3.0.11.Final.jar 中提供在执行 Jersey 对手之前?

我不明白如何使用 web.xml 实现这一点。还有 ServletContainerInitializer 的规范状态:

In either case, ServletContainerInitializer services from web fragment JAR files excluded from an absolute ordering must be ignored, and the order in which these services are discovered must follow the application's classloading delegation model.

因此,我在我的 glassfish-web.xml 中进行了尝试,但没有任何效果。

请在这方面指导我。

干杯

(附注:从 glassfish/modules/文件夹“works”中删除 jersey-container-servlet.jar)

最佳答案

Web 片段排序将不起作用,因为 jersey-container-servlet.jar 不是真正的 web 片段。

但以下内容适用于使用 Jersey 2 的 Webogic 12.2。

为您的应用创建类

package my.app;

public class MyJaxRSApplication extends javax.ws.rs.core.Application {}

在 web.xml 中使用此类的完全限定名称注册 Rest Easy servlet

<servlet>
<servlet-name>my.app.MyJaxRSApplication</servlet-name>
<servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
</servlet>

这不会阻止 JerseyServletContainerInitializer 的执行,但不会注册 Jersey servlet。

关于java - 防止执行 ServletContainerInitializer 或如何使用绝对顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31458850/

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