防止执行ServletContainerInitializer或如何使用绝对顺序 [英] Prevent Execution of ServletContainerInitializer or how to use absolute-order

查看:582
本文介绍了防止执行ServletContainerInitializer或如何使用绝对顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想阻止执行 JerseyServletContainerInitializer.java

有可能阻止执行提供的jar的ServletContainerInitializer。 / code>这是由Glassfish 4.1提供的一个osgi包(在 jersey-container-servlet.jar中)。



或者如何使用web.xml的< absolute-order> 来强制加载 ResteasyServletInitializer.java 提供在 resteasy-servlet-initializer-3.0.11.Final.jar 之前执行球衣对手?



我不明白如何使用web.xml实现这一点。
ServletContainerInitializer 的详细说明:


无论哪种情况,从绝对排序中排除的Web碎片JAR文件中的ServletContainerInitializer服务必须被忽略,并且发现这些服务的顺序必须遵循应用程序的类加载委派模型。


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



请在这个指导我。

<干杯>



(ps去掉 jersey-container-servlet.jar 来自glassfish / modules /文件夹works)

解决方案

Web片段排序不起作用,因为jersey-container-servlet.jar并不是一个真正的网页片段。



但是以下版本在使用Jersey 2的Webogic 12.2中。



为您的应用程序创建类

  package my.app; 

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



<在web.xml中使用这个类的完全限定名称的简单servlet

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

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


is it possible to prevent the execution of the ServletContainerInitializer of a provided jar.

I want to prevent the execution of JerseyServletContainerInitializer.java which is provided by Glassfish 4.1 as an osgi-bundle (in jersey-container-servlet.jar).

Or how can I use the <absolute-order> of web.xml to enforce loading of the ResteasyServletInitializer.java provided in resteasy-servlet-initializer-3.0.11.Final.jar prior to the execution of the jersey counterpart?

I do not understand how this can be achieved using the web.xml. Also the specification of ServletContainerInitializer states:

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.

I therefore tried in my glassfish-web.xml but with no effect.

Please guide me on this one.

Cheers

(p.s. removing jersey-container-servlet.jar from the glassfish/modules/ folder "works")

解决方案

Web fragment ordering won't work, because the jersey-container-servlet.jar is not a real web fragment.

But the following works in Webogic 12.2, which uses Jersey 2.

Create class for your app

package my.app;

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

Register Rest Easy servlet with the fully qualified name of this class in web.xml

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

This will not prevent execution of JerseyServletContainerInitializer, but it won't register the Jersey servlet.

这篇关于防止执行ServletContainerInitializer或如何使用绝对顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆