我正在使用JBoss 6 AS,並試圖通過AOP將攔截器添加到來自部署應用程序的某些包中的類中。這是場景:帶AOP的JBoss 6 AS拋出StackOverflowError
- 我有一個
app.jar
包含我要添加意見的類。這個JAR也有一些EJB(ejb-jar.xml,jboss.xml)。 我創建了JBoss上攔截這樣的:
package util; import org.jboss.aop.joinpoint.Invocation; import org.jboss.aop.joinpoint.MethodInvocation; public class MyInterceptor implements org.jboss.aop.advice.Interceptor { @Override public Object invoke(Invocation invocation) throws Throwable { long startTime = System.currentTimeMillis(); try { return invocation.invokeNext(); } finally { long endTime = System.currentTimeMillis() - startTime; System.out.println("MyInterceptor : " + endTime); if (invocation instanceof MethodInvocation) { MethodInvocation mi = (MethodInvocation) invocation; String clazz = ""; String method = ""; try { clazz = mi.getTargetObject().getClass().toString(); method = mi.getMethod().getName(); } catch (Throwable e) { System.out.println("Error when trying to get target info"); } System.out.println("MyInterceptor : " + endTime); } } } @Override public String getName() { return "MyInterceptor"; } }
我創建了一個
jboss-aop.xml
文件,其中包含:<?xml version="1.0" encoding="UTF-8"?> <aop xmlns="urn:jboss:aop-beans:1.0"> <interceptor name="MyInterceptor" class="util.MyInterceptor"/> <bind pointcut="execution(* my.app.*->*(..))"> <interceptor-ref name="MyInterceptor"/> </bind> </aop>
我已經設置
enableLoadTimeWeaving
(引導/ aop.xml文件)- 我有
pluggable-instrumentor.jar
在正確的地方(JBOSS/bin) - 我已經開始在服務器與
-javaagent:pluggable-instrumentor.jar
- 我創建了一個JAR文件
interceptor.jar
這裏我把MyInterceptor.class
並在其META-INF我放在jboss-aop.xml
文件現在
,他這樣說的選項,問題是,當我運行我的應用程序和來自my.app
包中的任何類的某種方法時,攔截器似乎攔截了該調用,但它引發了令人討厭的StackOverflowError
。這是我的錯誤堆棧的一部分:
java.lang.StackOverflowError
at org.jboss.resteasy.core.SynchronousDispatcher.unwrapException(SynchronousDispatcher.java:345) [:6.1.0.Final]
at org.jboss.resteasy.core.SynchronousDispatcher.handleApplicationException(SynchronousDispatcher.java:321) [:6.1.0.Final]
at org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:214) [:6.1.0.Final]
at org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:190) [:6.1.0.Final]
at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:534) [:6.1.0.Final]
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496) [:6.1.0.Final]
at org.jboss.resteasy.core.SynchronousDispatcher.invokePropagateNotFound(SynchronousDispatcher.java:155) [:6.1.0.Final]
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:212) [:6.1.0.Final]
at org.jboss.resteasy.plugins.server.servlet.FilterDispatcher.doFilter(FilterDispatcher.java:59) [:6.1.0.Final]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:6.1.0.Final]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.1.0.Final]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [:6.1.0.Final]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [:6.1.0.Final]
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181) [:6.1.0.Final]
at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285) [:1.1.0.Final]
at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261) [:1.1.0.Final]
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88) [:6.1.0.Final]
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100) [:6.1.0.Final]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:159) [:6.1.0.Final]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [:6.1.0.Final]
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) [:6.1.0.Final]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [:6.1.0.Final]
at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53) [:6.1.0.Final]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [:6.1.0.Final]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [:6.1.0.Final]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654) [:6.1.0.Final]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [:6.1.0.Final]
at java.lang.Thread.run(Thread.java:745) [:1.7.0_79]
Caused by: java.lang.StackOverflowError
at my.app.JoinPoint_invoke_N_5164114663869737738_3.invokeJoinpoint(JoinPoint_invoke_N_5164114663869737738_3.java) [:]
at my.app.MyInterceptor$MyInterceptorAdvisor.invoke_N_5164114663869737738(MyInterceptor$MyInterceptorAdvisor.java) [:]
at my.app.MyInterceptor.invoke(MyInterceptor.java) [:]
at my.app.JoinPoint_invoke_N_5164114663869737738_3.invokeNext(JoinPoint_invoke_N_5164114663869737738_3.java) [:]
at my.app.JoinPoint_invoke_N_5164114663869737738_3.invokeJoinpoint(JoinPoint_invoke_N_5164114663869737738_3.java) [:]
at my.app.MyInterceptor$MyInterceptorAdvisor.invoke_N_5164114663869737738(MyInterceptor$MyInterceptorAdvisor.java) [:]
at my.app.MyInterceptor.invoke(MyInterceptor.java) [:]
基本上什麼情況是,被拋出這四條線,直到StackOverflowError
被提出:
at my.app.JoinPoint_invoke_N_5164114663869737738_3.invokeNext(JoinPoint_invoke_N_5164114663869737738_3.java) [:]
at my.app.JoinPoint_invoke_N_5164114663869737738_3.invokeJoinpoint(JoinPoint_invoke_N_5164114663869737738_3.java) [:]
at my.app.MyInterceptor$MyInterceptorAdvisor.invoke_N_5164114663869737738(MyInterceptor$MyInterceptorAdvisor.java) [:]
at my.app.MyInterceptor.invoke(MyInterceptor.java) [:]
如果任何人有一些類似的問題,任何幫助,將appeciated !
你的意思是JBoss EAP 6嗎? –
我的意思是JBoss AS 6(社區發行)和NOT EAP 6(這將是基於JBoss AS 7的企業發行版) –
所以基本上JBoss 6.x IIUC? –