Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/312.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java ContainerRequestFilter JBoss AS 7.1.1 RestEasy 3.0.6.Final_Java_Rest_Jboss_Resteasy_Interceptor - Fatal编程技术网

Java ContainerRequestFilter JBoss AS 7.1.1 RestEasy 3.0.6.Final

Java ContainerRequestFilter JBoss AS 7.1.1 RestEasy 3.0.6.Final,java,rest,jboss,resteasy,interceptor,Java,Rest,Jboss,Resteasy,Interceptor,我试图设置一个请求过滤器,因为我想在调用我的逻辑之前检查一些http头信息。不幸的是,我的过滤器在JBossAS7.1.1中从未被调用。我已经尝试将RestEasy实现(模块)更新为3.0.6,如RestEasy文档中所述。它说您只需要替换新的实现zip文件提供的目录,我就是这么做的。 启动时没有任何错误,但行为不会以任何方式更改。每一个请求都不受干扰。我从一个更复杂的示例中提取了这段代码,但即使是这个简单的东西也不起作用: Filter.java ItemsResource.java Appl

我试图设置一个请求过滤器,因为我想在调用我的逻辑之前检查一些http头信息。不幸的是,我的过滤器在JBossAS7.1.1中从未被调用。我已经尝试将RestEasy实现(模块)更新为3.0.6,如RestEasy文档中所述。它说您只需要替换新的实现zip文件提供的目录,我就是这么做的。 启动时没有任何错误,但行为不会以任何方式更改。每一个请求都不受干扰。我从一个更复杂的示例中提取了这段代码,但即使是这个简单的东西也不起作用:

Filter.java

ItemsResource.java

ApplicationConfig.java

Secured.java


如果我尝试在没有注释的情况下使用拦截器和资源,我不会更改任何内容。我希望所有的请求都会被拦截,但不会。我没有胶水怎么办。有谁能给我们一些建议吗?让我们添加一些附加的东西。我在Wildfly上也做了同样的尝试(JBoss8.0.0最终版)。使用@NameBinding并应用自定义注释进行拦截也不起作用,但如果我不使用注释,只使用@Provider注释拦截器,那么我的所有请求都会被拦截。我必须迁移到Wildfly还是什么?

我们遇到了同样的问题。 我们使用了带有POM依赖项的RESTeasy的最终版本。
同时使用zip文件resteasy-jaxrs-3.0.7.Final的内容更新JBOSS(EAp 6.1)的模块。
唯一的区别在于我们使用的过滤器:

@Provider @PreMatching
@Precedence("SECURITY")
public class SecurityInterceptor implements ContainerRequestFilter{
@Override
public void filter(ContainerRequestContext arg0) throws IOException {
    ...
    }
}
此外,我们还需要在web.xml中手动注册提供商

<context-param>
    <param-name>resteasy.providers</param-name>
    <param-value>com.neology.rest.SecurityInterceptor</param-value>
</context-param>

希望这有帮助

我们遇到了同样的问题。 我们使用了带有POM依赖项的RESTeasy的最终版本。
同时使用zip文件resteasy-jaxrs-3.0.7.Final的内容更新JBOSS(EAp 6.1)的模块。
唯一的区别在于我们使用的过滤器:

@Provider @PreMatching
@Precedence("SECURITY")
public class SecurityInterceptor implements ContainerRequestFilter{
@Override
public void filter(ContainerRequestContext arg0) throws IOException {
    ...
    }
}
此外,我们还需要在web.xml中手动注册提供商

<context-param>
    <param-name>resteasy.providers</param-name>
    <param-value>com.neology.rest.SecurityInterceptor</param-value>
</context-param>

希望这有帮助

您的问题已经提到:


您需要删除@prematch,并确保在运行时保留您的安全批注(Retention=Runtime)。

您的问题已经提到:

您需要删除@prematch,并确保您的安全批注在运行时被保留(Retention=Runtime)。

您可以使用Resteasy:

import org.jboss.resteasy.annotations.interception.ServerInterceptor;
导入org.jboss.resteasy.spi.interception.PreProcessInterceptor;
导入javax.ws.rs.ext.Provider;
@提供者
@服务器拦截器
公共类SecurityInterceptor实现预处理侦听器{
@凌驾
公共服务器响应预处理(HttpRequest请求,ResourceMethod)引发失败,WebApplicationException{
if(/*检查用户当前是否经过身份验证*/){
//没有当前经过身份验证的用户:引发异常
抛出新的NotAuthenticationDexception();
}
返回null;/=继续而不中断
}
}
您可以使用Resteasy:

import org.jboss.resteasy.annotations.interception.ServerInterceptor;
导入org.jboss.resteasy.spi.interception.PreProcessInterceptor;
导入javax.ws.rs.ext.Provider;
@提供者
@服务器拦截器
公共类SecurityInterceptor实现预处理侦听器{
@凌驾
公共服务器响应预处理(HttpRequest请求,ResourceMethod)引发失败,WebApplicationException{
if(/*检查用户当前是否经过身份验证*/){
//没有当前经过身份验证的用户:引发异常
抛出新的NotAuthenticationDexception();
}
返回null;/=继续而不中断
}
}

在您的META-INF/services下添加提供者文件,如:/META-INF/services/javax.ws.rs.ext.Providers,javax.ws.rs.ext.Providers是一个文件,内容是您的过滤器路径,如:com.hujiang.foe.sattage.liquisition.biz.impl.account.filter.ContextCleanFilter

在您的META-INF/services下添加提供者文件,like:/META-INF/services/javax.ws.rs.ext.Providers,javax.ws.rs.ext.Providers是一个文件,内容是您的过滤器路径,如:com.hujiang.foe.sattage.liquilization.biz.impl.account.filter.ContextCleanFilter

预处理侦听器可能重复的可能重复被拒绝预处理侦听器被拒绝谢谢!帮助我使用JBossAS 7.1.1配置
ContainerRequestFilter
。将RestEASY升级到3.0.5版后,它运行正常。首先,我尝试将RestEASY升级到3.6.3版,但没有成功。谢谢!帮助我使用JBossAS 7.1.1配置
ContainerRequestFilter
。将RestEASY升级到3.0.5版后,它运行正常。首先,我尝试将RestEASY升级到3.6.3版,但没有成功。
@Provider @PreMatching
@Precedence("SECURITY")
public class SecurityInterceptor implements ContainerRequestFilter{
@Override
public void filter(ContainerRequestContext arg0) throws IOException {
    ...
    }
}
<context-param>
    <param-name>resteasy.providers</param-name>
    <param-value>com.neology.rest.SecurityInterceptor</param-value>
</context-param>
<!-- RESTeasy Listener 1st -->
<listener>
    <listener-class>
    org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
    </listener-class>
</listener>
<!-- Spring Listener 2nd -->
<listener>
    <listener-class>
    org.springframework.web.context.ContextLoaderListener
    </listener-class>
</listener>
<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" />
<mvc:resources mapping="/rest/**" location="/rest/" />