[jboss-user] [EJB/JBoss] - Problems creating a Retry Interceptor

davidyo do-not-reply at jboss.com
Tue Jul 28 08:57:54 EDT 2009


Hi, I want to create an interceptor to retry EJB that are using container managed transactions.  I am using Jboss 4.2.2, I have written a sample app to attempt to intercept the exceptions from the CMT, but am having problems in getting it working.  Any help would be greatly appreciated, or an alternative approach?

Currently I am getting a Null Pointer Exception.


  | 13:48:37,750 WARN  [ServiceController] Problem starting service jboss.j2ee:ear=RetryTest.ear,jar=RetryTest-ejb.jar,name=SimpleSessionBean,service=EJB3
  | java.lang.NullPointerException
  |         at java.util.Arrays$ArrayList.<init>(Arrays.java:2355)
  |         at java.util.Arrays.asList(Arrays.java:2341)
  |         at org.jboss.ejb3.stateless.StatelessRemoteProxyFactory.getInterfaces(StatelessRemoteProxyFactory.java:76)
  |         at org.jboss.ejb3.stateless.BaseStatelessProxyFactory.init(BaseStatelessProxyFactory.java:163)
  |         at org.jboss.ejb3.stateless.StatelessRemoteProxyFactory.init(StatelessRemoteProxyFactory.java:113)
  |         at org.jboss.ejb3.stateless.BaseStatelessProxyFactory.start(BaseStatelessProxyFactory.java:212)
  |         at org.jboss.ejb3.stateless.StatelessRemoteProxyFactory.start(StatelessRemoteProxyFactory.java:120)
  |         at org.jboss.ejb3.ProxyDeployer.start(ProxyDeployer.java:83)
  | 
  | 

This is my jboss.xml file


  | <?xml version="1.0" encoding="UTF-8"?>
  | <jboss>
  | 
  | 	<container-configuration extends="Standard Stateless SessionBean">
  |          <container-name>Retry</container-name>
  |          <container-interceptors>
  |             <interceptor>org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor</interceptor>
  |             <interceptor>org.jboss.ejb.plugins.LogInterceptor</interceptor>
  |             <interceptor>retrytest.RetryInterceptor</interceptor>
  |             <interceptor>org.jboss.ejb.plugins.SecurityInterceptor</interceptor>
  |             <!-- CMT -->
  |             <interceptor transaction="Container">org.jboss.ejb.plugins.TxInterceptorCMT</interceptor>
  |             </container-interceptors>
  |         </container-configuration>
  | 
  | 
  | 
  | <enterprise-beans>
  |       <session>
  |         <ejb-name>SimpleSessionBean</ejb-name>
  |         <jndi-name>RetryTest/SimpleSessionBean</jndi-name>
  |         <configuration-name>Retry</configuration-name>
  |       </session>
  |     </enterprise-beans>
  | </jboss>
  | 

This the Interceptor



  | 
  | 
  | public class RetryInterceptor extends AbstractInterceptor 
  | 	{
  | 	   private static Log log = LogFactory.getLog(RetryInterceptor.class);
  | 	   
  |     @Override
  | 	   public Object invokeHome(final Invocation mi) throws Exception
  | 	   {
  | 
  | 	      System.out.println("INVOKE HOME retry INTERCEPTOR");
  | 	      
  | 	      Object o = null;
  |       	     //will wrap up with a retry loop 
  | 	      try{
  | 	    	  o = getNext().invokeHome(mi);
  | 	      }catch(Exception e){
  | 	    	  log.info("RetryInterceptor: retry got an exception "+e);
  | 	    	  e.printStackTrace();
  | 	      }
  | 	      
  | 	      return o;
  | 
  | 	   }
  | 
  |     @Override
  | 	   public Object invoke(final Invocation mi) throws Exception
  | 	   {
  | 	      System.out.println("INVOKE retry INTERCEPTOR");
  | 	      
  | 	      
  | 	      Object o = null;
  | 	     //will wrap up with a retry loop 
  | 	      try{
  | 	    	  o = getNext().invoke(mi);
  | 	      }catch(Exception e){
  | 	    	  log.debug("RetryInterceptor: retry got an exception "+e);
  | 	    	  e.printStackTrace();
  | 	      }
  | 	      
  | 	      return o;	      	     		
  | 	   }	
  | }
  | 

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4246426#4246426

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4246426



More information about the jboss-user mailing list