Results 1 to 4 of 4

Thread: Internal error processing annotated request parameter

  1. #1
    Join Date
    Dec 2011
    Posts
    3

    Default 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 at 01:07 PM. Reason: Added [CODE] tags.

  2. #2
    Join Date
    Aug 2006
    Location
    Brooklyn
    Posts
    556

    Default

    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.

  3. #3
    Join Date
    Dec 2011
    Posts
    3

    Default

    Quote 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.

  4. #4
    Join Date
    Aug 2006
    Location
    Brooklyn
    Posts
    556

    Default

    Quote 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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •