Content-Length: 132525 | pFad | https://nowokay.hatenablog.com/entry/20131129/1385696180

CDI1.1でInterceptorを使うときの注意 - きしだのHatena

CDI1.1でInterceptorを使うときの注意

CDIを使うときに便利なInterceptorですが、なんかJava EE 7のCDI 1.1で試そうと思ったら

Enabled interceptor class MyInterceptor in file:/C:/.../beans.xml@7 is neither annotated @Interceptor nor registered through a portable extension

という例外が出てデプロイできませんでした。


どうも、bean.xmlのbean-discovery-modeをallにするか、CDIを1.0にするか、っていう必要があるみたい。
xsi:schemaLocationをbeans_1_0.xsdにする方法は、うまく動くことが確認できなかったけど。
EAR deployment fails with WELD-001417: Enabled interceptor (...) is neither annotated @Interceptor nor registered through a portable extension - Java.net JIRA


試したらbean-discovery-modeがannotatedのままでも、Interceptorに@Dependentアノテーションをつけても動作します。これが一番無難な気がする。
ただし、beans.xmlへのinterceptors記述は必要でした。









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://nowokay.hatenablog.com/entry/20131129/1385696180

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy