I'm trying to pass an object to another class using Spring (I'm not sure I'm using the right terms, I'm very new to Spring) this way:
TestServicesUtils.getTemplate().postForLocation(
     "http://"
     + serverConfig
     + ":"
     + port
     + "/test/rest/TestResultService/insertTestResult/",
    results); 
When I ran the program it gets to that line and it trows an Exception:
log4j:WARN No appenders could be found for logger (org.apache.commons.httpclient.HttpClient).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
org.springframework.web.client.HttpClientErrorException: 404 Not Found
        at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:76)
The class that's trying to connect to:
@Service("TestRestImpl")
@Path("TestResultService")
@Produces("application/json")
public class TesttRestImpl implements TestResultRest 
{ 
    ...
    @POST
    @Override
    @Path("/insertTestResult")
    @Consumes("application/xml")
    public void insertTestResult(TestRestCollection list) {
        testresultservicedao.insertTestResult(list.getListOfResults());
    }
}
The path seems to be fine, I don't know why it can't find the method. Do I need to register the path?
Your path is not correct. If you have a correct path and still get an error then is a mapping error. But in this situation you have 404 error which means that path doesn't exist.
Change your path to : @Path("/test/rest/TestResultService/insertTestResult/")
Then if you have an error again you have to register your path to mapping conf.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With