Announcement Announcement Module
Collapse
No announcement yet.
Internal error processing annotated request parameter Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Internal error processing annotated request parameter

    In Spring Framework 3.1.0, I have an annotated controller like this:

    Code:
    @Controller
    public class RestAdministrationController
    {
    	private UserDAO userDAO;
    	public void setUserDAO(UserDAO userDAO) { this.userDAO = userDAO; }
    	
    	@RequestMapping( value="**/user", method=RequestMethod.GET)
    	public @ResponseBody User getUser(@RequestParam("userid" ) String id )
    	{ return userDAO.loadById(Long.parseLong(id)); }
    		
    	@RequestMapping(value="**/userlist", method=RequestMethod.GET)
    	public @ResponseBody UserList getUserList()
    	{ return userDAO.list(); }
    	
    }
    I have jackson-all-1.9.3.jar on the classpath.

    The userlist method works as expected. http://localhost:8080/ebp2w/rest/adm...ation/userlist returns valid JSON.

    http://localhost:8080/ebp2w/rest/adm...ion/user?foo=1 results in "The request sent by the client was syntactically incorrect ()" which is correct.

    However http://localhost:8080/ebp2w/rest/adm.../user?userid=1 results in status 500 "The server encountered an internal error () that prevented it from fulfilling this request." There is no error recorded in the log4j log (which is set to level "debug"). Running the code in Eclipse indicates it is never reaching my method.

    I have <mvc:annotation-driven/> and for some non-annotated controllers I have:

    Code:
    <bean id="handlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    		<property name="interceptors">
            	<ref bean="localeChangeInterceptor" />
        	</property>
        	<property name="mappings">
                <value>
                    /index.html=loginController
                    /home.html=homeController
                    /accessDenied.html=accessDeniedController
                    /adminHome.html=adminHomeController
                </value>
            </property>
    </bean>
    I have searched and cannot find any report of a similar problem. I have experimented with different parameter types on the method and using PathVariable instead of RequestParam but nothing seems to make a difference. I am out of ideas. Any suggestions please?
    Last edited by Rossen Stoyanchev; Jan 5th, 2012, 01:07 PM. Reason: Added [CODE] tags.

  • #2
    500 most likely means an exception bubbled up. You need to get a stack trace or add a Java exception breakpoint in your IDE (Eclipse has it for sure) and then get the exception to print the stack trace.

    Without further qualifications, the scenario you describe is pretty basic (@RequestParam args don't work). Try to create a very basic example that reproduces the issue. You could do it in the Spring Framework issues repository.

    Comment


    • #3
      Originally posted by Rossen Stoyanchev View Post
      500 most likely means an exception bubbled up. You need to get a stack trace or add a Java exception breakpoint in your IDE (Eclipse has it for sure) and then get the exception to print the stack trace.
      Thanks but how can I get stack trace or set a breakpoint in the IDE when my code is never reached?

      Without further qualifications, the scenario you describe is pretty basic
      You bet. It doesn't give a very warm feeling that I cannot get it to work.

      Comment


      • #4
        Originally posted by dogwatch View Post
        Thanks but how can I get stack trace or set a breakpoint in the IDE when my code is never reached
        For starters, tweak your log settings till you get more output. In Eclipse there is a way to set breakpoints when exceptions occur. Other IDEs probably have it too.

        Comment

        Working...
        X