Results 1 to 2 of 2

Thread: Reflection problem with a REST call

  1. #1
    Join Date
    Feb 2013
    Posts
    6

    Default Reflection problem with a REST call

    I have a web service where the client request a file to be created through a SOAP request. When the file is ready the client will download it through REST:

    Code:
    @Controller("servicesX")
    public class ServicesXImpl implements ServicesX { 
    
        [...]
    
        @Override
         @RequestMapping(value="/downloads/{id}",method=RequestMethod.GET)
        public Object getFile(@PathVariable UUID id) throws Exception {
    
            return new ServletContextResource(context,getFilePath(id));
        }
    
        [...]
    But I get the following error:

    Code:
    java.lang.IllegalArgumentException: object is not an instance of declaring class
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
    Earlier I had this error, but I solved it removing the @Transactional annotation from this class.

    Now the error came back, and I don't know why or how to solve it. I'm able to call the method successfully if the method is static, so the problem isn't the UUID parameter. So the problem is probably the wrong instance of this class being used for reflection.

    Does anyone have a clue?

    Thanks!!
    Last edited by luccotta; Mar 6th, 2013 at 02:58 PM.

  2. #2
    Join Date
    Feb 2013
    Posts
    6

    Default

    I did the following modifications, but the problem persists:

    Code:
    @Controller("servicesX")
    public interface ServicesX extends Remote {
    
        @RequestMapping(value="/downloads/{id}", method=RequestMethod.GET)
        @ResponseBody
        @ResponseStatus(value = HttpStatus.OK)
        Object getFile(@PathVariable UUID  id)  throws Exception;
    
    }
    Code:
    @Component
    public class ServicesXImpl implements ServicesX { 
    
        [...]
    
        @Override
        public Object getFile(@PathVariable UUID id) throws Exception {
    
            return new ServletContextResource(context,getFilePath(id));
        }
    
        [...]
    Last edited by luccotta; Mar 8th, 2013 at 10:55 AM.

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
  •