首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Tomcat上的AOP与Weld

Tomcat上的AOP与Weld
EN

Stack Overflow用户
提问于 2017-02-02 19:13:49
回答 1查看 311关注 0票数 0

我正在学习如何在RESTful AOP服务中使用面向方面编程。我选择Tomcat作为平台,选择Weld来引入CDI,我也使用CXF作为JAX-RS实现(这是一个委员会特定的技术约束,在这方面我是相当新手)。这是我的sandbox.,据我所知Weld已正确加载,我从here获得了Tomcat + Weld配置,它找到了我的拦截器(这是一个日志快照):

代码语言:javascript
复制
...
2017-02-02 11:26:03 DEBUG Bootstrap:238 - WELD-000105: Enabled interceptor types for Weld BeanManager for /SecProof_/WEB-INF/classes [bean count=2]: 
  - class org.jboss.weld.context.activator.ActivateRequestContextInterceptor,
  - class edu.pezzati.sec.CanAccessImpl
2017-02-02 11:26:03 DEBUG Bootstrap:236 - WELD-000103: Enabled alternatives for Weld BeanManager for org.jboss.weld.environment.deployment.WeldDeployment.additionalClasses [bean count=3]: (empty collection)
2017-02-02 11:26:03 DEBUG Bootstrap:237 - WELD-000104: Enabled decorator types for Weld BeanManager for org.jboss.weld.environment.deployment.WeldDeployment.additionalClasses [bean count=3]: (empty collection)
2017-02-02 11:26:03 DEBUG Bootstrap:238 - WELD-000105: Enabled interceptor types for Weld BeanManager for org.jboss.weld.environment.deployment.WeldDeployment.additionalClasses [bean count=3]: 
  - class org.jboss.weld.context.activator.ActivateRequestContextInterceptor
2017-02-02 11:26:03 INFO  servletTomcat:45 - WELD-ENV-001100: Tomcat 7+ detected, CDI injection will be available in Servlets, Filters and Listeners.
2017-02-02 11:26:03 TRACE Bean:300 - WELD-001536: Found [] constructors annotated with @Inject for [EnhancedAnnotatedTypeImpl] public @Path class edu.pezzati.sec.WebBoundary
2017-02-02 11:26:03 TRACE Bean:300 - WELD-001536: Found [] constructors annotated with @Inject for [EnhancedAnnotatedTypeImpl] public @CanAccess @Interceptor class edu.pezzati.sec.CanAccessImpl
2017-02-02 11:26:03 TRACE Bean:309 - WELD-000002: Exactly one constructor ([EnhancedAnnotatedConstructorImpl] public edu.pezzati.sec.WebBoundary()) defined, using it as the bean constructor for [EnhancedAnnotatedTypeImpl] public @Path class edu.pezzati.sec.WebBoundary
2017-02-02 11:26:03 TRACE Bean:309 - WELD-000002: Exactly one constructor ([EnhancedAnnotatedConstructorImpl] public edu.pezzati.sec.CanAccessImpl()) defined, using it as the bean constructor for [EnhancedAnnotatedTypeImpl] public @CanAccess @Interceptor class edu.pezzati.sec.CanAccessImpl
2017-02-02 11:26:03 TRACE Bean:300 - WELD-001536: Found [] constructors annotated with @Inject for [EnhancedAnnotatedTypeImpl] public @CanAccess @Interceptor class edu.pezzati.sec.CanAccessImpl
2017-02-02 11:26:03 TRACE Bean:309 - WELD-000002: Exactly one constructor ([EnhancedAnnotatedConstructorImpl] public edu.pezzati.sec.CanAccessImpl()) defined, using it as the bean constructor for [EnhancedAnnotatedTypeImpl] public @CanAccess @Interceptor class edu.pezzati.sec.CanAccessImpl
2017-02-02 11:26:03 TRACE Bean:300 - WELD-001536: Found [] constructors annotated with @Inject for [EnhancedAnnotatedTypeImpl] public @Path class edu.pezzati.sec.WebBoundary
...

好吧,我可以访问我的简单服务,但是我的拦截器没有被触发。这是Tomcat给我的回馈:

代码语言:javascript
复制
...
INFORMAZIONI: Server startup in 2293 ms
2017-02-02 11:28:59 TRACE Servlet:232 - WELD-000708: Initializing request org.apache.catalina.connector.Request@2b2c4052
2017-02-02 11:28:59 DEBUG Reflection:82 - WELD-000620: interface javax.enterprise.inject.Intercepted is not declared @Target(METHOD, FIELD, PARAMETER, TYPE). Weld will use this annotation, however this may make the application unportable.
2017-02-02 11:28:59 DEBUG Reflection:82 - WELD-000620: interface javax.enterprise.inject.Decorated is not declared @Target(METHOD, FIELD, PARAMETER, TYPE). Weld will use this annotation, however this may make the application unportable.
2017-02-02 11:28:59 TRACE Context:69 - WELD-000222: Loading bean store org.jboss.weld.context.beanstore.http.LazySessionBeanStore@366ca776 map from session null
2017-02-02 11:28:59 TRACE DefaultListableBeanFactory:568 - No bean named 'org.apache.cxf.phase.PhaseManager' found in org.springframework.beans.factory.support.DefaultListableBeanFactory@2c80a98d: defining beans [cxf,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,sec,secproof]; root of factory hierarchy
2017-02-02 11:28:59 TRACE DefaultListableBeanFactory:568 - No bean named 'org.apache.cxf.policy.PolicyDataEngine' found in org.springframework.beans.factory.support.DefaultListableBeanFactory@2c80a98d: defining beans [cxf,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,sec,secproof]; root of factory hierarchy
2017-02-02 11:28:59 TRACE Servlet:293 - WELD-000709: Destroying request org.apache.catalina.connector.Request@2b2c4052
...

我遗漏了什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-02-03 22:45:34

不要紧。它只是缺少配置。我必须使用cxf-integration-cdi才能使其工作,this博客帖子和this示例是基础。感谢作者。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42000741

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档