Wednesday, September 5, 2012

Spring REST web service Test

We can test the Spring REST web service by following :

1. By java Junit class.
2. By SoapUI.
3. By Firefox browser plugin REST CLIENT.
4. By Chrome browser plugin POST MAN.


1. By java Junit class :
We can write the java junit class to test REST service. its simple test class in ur maven web application.



2. By SoapUI : We can test by using Open Source SoapUI tool, it very simple configure and test the web services.
http://www.soapui.org/REST-Testing/getting-started.html

3. By Firefox browser plugin REST CLIENT : we can use REST CLIENT plugin
https://addons.mozilla.org/en-US/firefox/addon/restclient/

4. By Chrome browser plugin POST MAN: we can use POST MAN plugin
https://chrome.google.com/webstore/detail/fdmmgilgnpjigdojojpjoooidkmcomcm

WARN (DefaultHandlerExceptionResolver.java:183) - Request method 'POST' not supported. For Spring REST


When Spring RESTful web service post call are throwing following exception, then we need to check 'Content-type' is set in the header/request.

set the content-type in the testing client like SoapUI.
if the REST controller request/response of 'json' then set the content-type as
"Content-Type" : "application/json"
in the request headers.

Monday, September 3, 2012

java.lang.classnotfoundexception org.springframework.web.context.contextloaderlistener / ClassNotFoundException when running a Spring + Maven2 project on Tomcat from within Eclipse

I had a similar problem when running a spring web application in an Eclipse managed tomcat. I solved this problem by adding maven dependencies in the project's web deployment assembly.

1) Open the project's properties (e.g.right-click on the project's name in the project explorer and select "Properties")
2) select "Deployment Assembly"
3) Click the "Add..." button on the right margin
4) Select "Java Build Path Entries" from the menu of Directive Type and click "Next"
5) Select "Maven Dependencies" from the Java Build Path Entries menu and click "Finish".
You should see "Maven Dependencies" added to the Web Deployment Assembly definition.