Announcement Announcement Module
Collapse
No announcement yet.
ExceptionResolver not intercepting Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ExceptionResolver not intercepting

    Hi,
    My old Endpoint used to extend AbstractDomPayloadEndpoint. Since this class is deprecated, I've switched to use the @Endpoint annotation. However, after the change, my exceptionResolver does not intercept anymore, any ideas?

    My old Endpoint class looks like this:
    Code:
    public class GetCapabilitiesEndpoint extends AbstractDomPayloadEndpoint 
    {
    	public GetCapabilitiesEndpoint(IMyService myService)
    	{
                 ....some code.....
    	}
    
    	@Override
    	protected Element invokeInternal( Element requestElement,
    			Document responseDocument ) throws Exception
    	{
                ....some code..... 
    	}
    
    }
    My new Endpoint class:
    Code:
    @Endpoint
    public class GetCapabilitiesEndpoint 
    {
    
    	public GetCapabilitiesEndpoint(IMyService myService)
    	{
                 ....some code.....
    	}
    
    	@PayloadRoot(namespace = "http://someNamespace", localPart = "GetCapabilities")
    	@ResponsePayload
    	public Element handleGetCapabilitiesRequest(
    			@RequestPayload Element requestElement ) throws ServiceFaultException
    	{
                ....some code..... 
    	}
    
    }
    My old xx-servlet.xml (only partially shown):
    HTML Code:
    <bean id="endpointMapping" class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
    <property name="mappings">
       <props>
          <prop key="{http://someNamespace}GetCapabilities">getCapabilitiesEndpoint</prop>
    </props>
    </property>
    </bean>
    
    <bean id="exceptionResolver"
        	        class="com.hos.ws.exception.MyServiceExceptionResolver">
                <property name="defaultFault" value="SERVER"/>
                <property name="exceptionMappings">
                    <value>
        	    com.hos.ws.exception.ServiceFaultException=SERVER,A server exception was encountered.
                    </value>		
           	   </property>
     </bean>
                
    <bean id="getCapabilitiesEndpoint" class="com.hos.ws.endpoint.GetCapabilitiesEndpoint">  
            <constructor-arg ref="MyService"/>
    </bean>
    In my new xx-servlet.xml, I commented out the "endpointMapping" bean, and added:
    HTML Code:
    	<context:component-scan base-package="com.hos"/>
    
    	<sws:annotation-driven/>	
    Here's the code for my ServiceFaultException.java class (have not changed this):

    Code:
    @SoapFault(faultCode = FaultCode.CLIENT, faultStringOrReason = "A server exception was encountered", locale = "en")
    public class ServiceFaultException extends Exception
    {
    
    	private static final long serialVersionUID = 1L;
    	private String faultType;
    
    	public ServiceFaultException()
    	{
    		super( "ServiceFaultException" );
    	}
    
    	public ServiceFaultException(String errMsg)
    	{
    		super( errMsg );
    	}
    
    	public ServiceFaultException(String errMsg, Exception ex)
    	{
    		super( errMsg, ex );
    	}
    And the code for my MyServiceExceptionResolver.java class (have not changed):

    Code:
    public class MyServiceExceptionResolver extends SoapFaultMappingExceptionResolver
    {
    
    	@Override
    	protected void customizeFault( Object endpoint, Exception ex,
    			SoapFault fault )
    	{
    		logger.info( "Exception processed ", ex );
    		ServiceFaultException ee = null;
    		String faultXmlStr = "";
    		if( ex instanceof ServiceFaultException )
    		{
    			ee = (ServiceFaultException) ex;
    			String faultType = ee.getFaultType();
    			faultXmlStr = createFaultXmlStr( ee, faultType );
    		}
    		else
    		{
    			faultXmlStr = createFaultXmlStr( ex, "" );
    		}
    
    		addServiceFaultDetail( ee, faultXmlStr, fault );
    	}
    My new endpoint seems to be working properly because it can certainly parse the request, but the SOAP fault returned to the user has not been intercepted. I've placed breakpoints inside MyServiceExceptionResolver and it did not even get in. I have scratched my head over this for 2 days now, any help is greatly appreciated!

    Thanks,
    E.

  • #2
    I think I have figured out how to make it work, but still not sure why.

    If I comment out '<sws:annotation-driven/>' in my application context, then things work properly. But I thought I need this?

    Thanks,
    E

    Comment


    • #3
      Originally posted by eting View Post
      I think I have figured out how to make it work, but still not sure why.

      If I comment out '<sws:annotation-driven/>' in my application context, then things work properly. But I thought I need this?

      Thanks,
      E
      Thank you so much for this!

      I spent the last few hours trying to figure out why my ExceptionResolver was never triggered. Removed '<sws:annotation-driven/>' and it worked!

      Is this a bug? I thought I needed '<sws:annotation-driven/>' for my @Endpoint to work?

      Comment


      • #4
        Thanks, it helped me too.
        This looks like a major bug.

        At this moment I consider to go back to 1.5 - this is not the only problem I found in 2.0. I also have another serious problem with <sws:interceptors> tag details here.

        Comment


        • #5
          Hi,

          Can you please report this on Jira?

          Thanks,

          Tareq

          Comment


          • #6
            Hi Tereq,
            I don't have an access to spring-ws jira, I was looking for the ability to request/create an account but I didn't find it. Could you advise how to do it?
            Piotr

            Comment


            • #7
              Here's the link:
              https://jira.springsource.org/secure...p!default.jspa

              Comment


              • #8
                https://jira.springsource.org/browse/SWS-698

                Comment


                • #9
                  nice information

                  Thanks for great information about "ExceptionResolver not intercepting".:


                  Tavin

                  Comment


                  • #10
                    happy

                    Thanks a lot. This code is helping me a lot.


                    Any

                    Comment

                    Working...
                    X