2014-10-15 2 views
0

난 그냥 웹 스피어 8.5.5에 CDI를 활성화 JAX에서 beans.xml 환경 파일CDI 오류가 8.5

<?xml version="1.0"?> 
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/ 
XMLSchema-instance" 
xsi:schemeLocation="http://java.sun.com/xml/ns/javaee http:// 
java.sun.com/xml/ns/javaee/beans_1_0.xsd"> 
<interceptors> 
    <class>com.example.jaxrs.SecurityChecked</class> 
</interceptors> 
</beans> 

SecurityChecked 주석

import java.lang.annotation.ElementType; 
import java.lang.annotation.Inherited; 
import java.lang.annotation.Retention; 
import java.lang.annotation.RetentionPolicy; 
import java.lang.annotation.Target; 

import javax.interceptor.InterceptorBinding; 

@Inherited 
@InterceptorBinding 
@Target({ ElementType.TYPE, ElementType.METHOD }) 
@Retention(RetentionPolicy.RUNTIME) 
public @interface SecurityChecked { 
} 

import javax.interceptor.AroundInvoke; 
import javax.interceptor.Interceptor; 
import javax.interceptor.InvocationContext; 

@Interceptor 
@SecurityChecked 
public class SecurityCheckInterceptor { 

@AroundInvoke 
public Object checkSecurity(InvocationContext context) throws Exception { 
    /* 
    * check the parameters or do a generic security check before invoking 
    * the original method 
    */ 
    Object[] params = context.getParameters(); 

    /* if security validation fails, you can throw an exception */ 
    System.out.println("in securitycheck interceptor"); 

    /* invoke the proceed() method to call the original method */ 
    Object ret = context.proceed(); 

    /* perform any post method call work */ 
    return ret; 
} 
} 

에서 인터셉터를

을 추가 한 아래의 -RS 클래스

@GET 
@com.example.jaxrs.SecurityChecked 
public String checkInterceptor(String hello) { 
    return "Hello world!"; 
} 

EAR을 배포 할 때 오류가 발생합니다. [53 : 15 259 EDT 10/15/14 14] 00,000,067 BeansDeployer E BeansDeployer org.apache.webbeans.exception.WebBeansConfigurationException를 배포 :

WebContainerL I WebContainerLifecycle startApplication OpenWebBeans 컨테이너 ...

가 시작 주어 클래스 : com.example.jaxrs.SecurityChecked 인터페이스가 인터셉터 클래스가 아닙니다.

이 오류의 원인은 무엇입니까?

답변

3

오류 메시지에 모두 나와 있습니다. SecurityChecked하지 인터셉터이지만, 인터셉터 binding.The 요격에 사용되는 단순한 주석은 그래서 당신의 beans.xml 환경이 포함되어 있어야합니다 SecurityCheckInterceptor입니다 :

<interceptors> 
    <class>com.example.jaxrs.SecurityCheckInterceptor</class> 
</interceptors> 

감사합니다,
일러스트 Svetlin

+0

OOPS! 내 잘못, 그게 고쳐 줄게. 감사! – user923499

+0

문제가 해결되면 내 대답을 받아 들일 것을 고려하십시오 :) –

+0

좋아, 작동, 가끔 과장 :). – user923499