1 Reply Latest reply on Mar 31, 2010 6:58 AM by Joseph Miller

    Webservice client timeout exception handling gone very wrong!

    Joseph Miller Newbie

      I've got a JAX-WS 2.1 (Java6) webservice client, which I'm using in a Seam component, and I want to catch request timeouts, and (eventually) display a warning message on the page.


      However, it seems that something in Seam is noticing the exception as well as my code, and causing an error and subsequent rollback.


      Running Seam 2.1.2, running on GlassFish 2.1.1


      My component looks like:


      @Name( "lotusNotesService" )
      @AutoCreate
      public class LotusNotesWebServiceClient
              implements Serializable, LotusNotesService {
          @Create
          public void create()
                  throws RemoteServiceException {
           final URL wsdlLocation = new URL( _configurationService.getLotusNotesServiceWSDL() );
           final BookITAppointmentService appointmentService = new BookITAppointmentService( wsdlLocation, new QName( "urn:DefaultNamespace", "BookITAppointmentService" ) );
                  _appointmentServicePort = appointmentService.getDomino();
                  final BindingProvider bindingProvider = (BindingProvider) _appointmentServicePort;
                  final Map<String, Object> context = bindingProvider.getRequestContext();
                  context.put( "com.sun.xml.ws.connect.timeout", 5000 );
                  context.put( "com.sun.xml.ws.request.timeout", 2000 );
          }
      
            public List<AdviserCommitment> getAppointments( final Collection<Adviser> advisers, final Interval interval )
                  throws RemoteServiceException {
                  try {
                      _log.debug("making call");
                      //THE ACTUAL SERVICE CALL
                      appointmentArray[ 0 ] = _appointmentServicePort.getallappointments( adviserIdHolder, start, end );
                  }
                  catch( Exception e ) {
                      _log.debug("Caught Exception");
                      return new ArrayList<AdviserCommitment>();
                  }
      
            }
      }



      You would think that a timeout (which is a SocketTimeoutException wrapped in a WebserviceException) would be caught and swallowed. but I see the following:



      [#|2010-03-19T11:34:43.422+1100|FINE|sun-appserver2.1|bookit.service.lotusnotes.LotusNotesWebServiceClient|_ThreadID=20;_ThreadName=httpSSLWorkerThread-8080-1;ClassName=bookit.service.lotusnotes.LotusNotesWebServiceClient$$M$cb1abada;MethodName=getAppointments;_RequestID=4a8c2875-3b1b-4b4c-a094-168a564b6598;|Caught Exception|#]

      [#|2010-03-19T11:34:43.431+1100|WARNING|sun-appserver2.1|org.jboss.seam.jsf.SeamPhaseListener|_ThreadID=20;_ThreadName=httpSSLWorkerThread-8080-1;_RequestID=4a8c2875-3b1b-4b4c-a094-168a564b6598;|uncaught exception, passing to exception handler
      java.lang.IllegalStateException: Could not commit transaction
           at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:625)
           at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:604)
           at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsAfterPhase(SeamPhaseListener.java:345)
           at org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:245)
           at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:196)
           at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:175)
           at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:114)
           at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
           at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:333)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
           at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
           at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
           at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
           at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
           at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:313)
           at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:287)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:218)
           at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
           at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
           at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
           at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:222)
           at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
           at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
           at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
           at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1093)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:166)
           at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
           at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
           at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
           at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1093)
           at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:291)
           at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:666)
           at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:597)
           at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:872)
           at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
           at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
           at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
           at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:264)
           at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
      Caused by: javax.transaction.SystemException: org.omg.CORBA.INVALID_TRANSACTION:   vmcid: 0x0  minor code: 2  completed: No
           at com.sun.jts.jta.TransactionManagerImpl.commit(TransactionManagerImpl.java:321)
           at com.sun.enterprise.distributedtx.J2EETransactionManagerImpl.commit(J2EETransactionManagerImpl.java:1029)
           at com.sun.enterprise.distributedtx.J2EETransactionManagerOpt.commit(J2EETransactionManagerOpt.java:398)
           at com.sun.enterprise.distributedtx.UserTransactionImpl.commit(UserTransactionImpl.java:197)
           at org.jboss.seam.transaction.UTTransaction.commit(UTTransaction.java:52)
           at org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:613)
           ... 55 more
      |#]



      So you can see that I'm catching and handling my the exception (this example is simplified, I can detect that it's a timeout, and handle accordingly in my full code), but something in the SeamPhaseListener is grabbing it as well, and wrecking everything.


      If I change the service call to a line that simply throws a new exception, then everything works fine.


      What the heck is going on? This has been doing my head in, help!