Announcement Announcement Module
Collapse
No announcement yet.
HttpMediaTypeNotAcceptableException When dot in request. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • HttpMediaTypeNotAcceptableException When dot in request.

    Hi all, I have this code in server side :

    Code:
    	
    @RequestMapping(method=RequestMethod.DELETE,value="/{id}/blabla/{name:.*}")
         public @ResponseBody PersonnalObjectResponse delete(@PathVariable(value="id") String id,@PathVariable(value="name") String name, HttpServletRequest request, HttpServletResponse response) throws Exception {
    		//SOME DELETE CODE who throw exception
    		return new PersonnalObjectResponse();
    
    	}
    
    
    @ExceptionHandler(Exception.class)
    	public @ResponseBody PersonnalObjectResponse handleException(Exception ex, HttpServletRequest request, HttpServletResponse response) {
    		response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    		return new PersonnalObjectResponse();
    	}
    when i call /someID/blabla/file => My DELETE CODE throw EXCEPTION => My Exception Handler Catch this and return a PersonnalObjectResponse => response is correctly send in JSON.

    when i call /someID/blabla/file.txt => My DELETE CODE throw EXCEPTION => My Exception Handler Catch this and return a PersonnalObjectResponse => HttpMediaTypeNotAcceptableException ?!?.

    piece of log :

    Code:
    TRACE [http-8080-2] (InvocableHandlerMethod.java:135) - Method [handleException] returned [.X.X.PersonnalObjectResponse @2a24ed78]
    TRACE [http-8080-2] (HandlerMethodReturnValueHandlerComposite.java:78) - Testing if return value handler [org.springframework.web.servlet.mvc.method.annotation.ModelAndViewMethodReturnValueHandler@5e6276e5] supports [class .X.X.PersonnalObjectResponse]
    TRACE [http-8080-2] (HandlerMethodReturnValueHandlerComposite.java:78) - Testing if return value handler [[email protected]6be4cc] supports [class .X.X.PersonnalObjectResponse]
    TRACE [http-8080-2] (HandlerMethodReturnValueHandlerComposite.java:78) - Testing if return value handler [org.springframework.web.servlet.mvc.method.annotation.ViewMethodReturnValueHandler@697a1686] supports [class .X.X.PersonnalObjectResponse]
    TRACE [http-8080-2] (HandlerMethodReturnValueHandlerComposite.java:78) - Testing if return value handler [org.springframework.web.servlet.mvc.method.annotation.HttpEntityMethodProcessor@4e5ced83] supports [class .X.X.PersonnalObjectResponse]
    TRACE [http-8080-2] (HandlerMethodReturnValueHandlerComposite.java:78) - Testing if return value handler [org.springframework.web.method.annotation.ModelAttributeMethodProcessor@191c0b76] supports [class .X.X.PersonnalObjectResponse]
    TRACE [http-8080-2] (HandlerMethodReturnValueHandlerComposite.java:78) - Testing if return value handler [org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor@347cdb] supports [class .X.X.PersonnalObjectResponse]
    TRACE [http-8080-2] (ServletInvocableHandlerMethod.java:126) - Error handling return value [type=.X.X.PersonnalObjectResponse] [value=.X.X.PersonnalObjectResponse@2a24ed78]
    HandlerMethod details: 
    Controller [.X.X.ItemController]
    Method [public .X.X.PersonnalObjectResponse .X.X.controllers.ExceptionItemController.handleException(java.lang.Exception,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)]
    
    org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation
    	at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:126)
    	at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:90)
    Spring version : 3.2.1.RELEASE

    Nothing special in config files :

    Code:
    	<context:annotation-config />
    	
    	<context:component-scan base-package="X.X" />
    
    	<mvc:annotation-driven />
    	
    	<mvc:default-servlet-handler />
    dispatcher :

    Code:
    	<bean
    		class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
    		<property name="exceptionMappings">
    			<props>
    				<prop key="java.lang.Exception">error</prop>
    			</props>
    		</property>
    	</bean>
    
    	<bean id="viewResolver"
    		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    
    		<property name="prefix">
    			<value>/WEB-INF/views/</value>
    		</property>
    		<property name="suffix">
    			<value>.jsp</value>
    		</property>
    	</bean>
    
    	<!-- Configure the multipart resolver -->
    	<bean id="multipartResolver"
    		class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
    	</bean>
    I Just find this issue who seems near my problem :
    https://jira.springsource.org/browse/SPR-9980

    thanks for anyone who can help.
Working...
X