Tag Archives: rest

Can't start google web app in eclipse, Security restrictions will not be completely emulated

Questions: When I try to run the auto generated code in my google web app project using GAE I get the following error: Mar 19, 2014 5:21:28 PM com.google.appengine.tools.development.agent.AppEngineDevAgent premain SEVERE: Unable to load the App Engine dev agent. Security restrictions will not be completely emulated. java.lang.RuntimeException: Unexpected exception during cast. at com.google.apphosting.utils.clearcast.ClearCast$CasterImpl.cast(ClearCast.java:385) at com.google.apphosting.utils.clearcast.ClearCast.staticCast(ClearCast.java:252)… Read More »

Spring-Data-Rest Validator

Questions: I have been trying to add spring validators to a spring-data-rest project. I followed along and setup the “getting started” application via this link: http://spring.io/guides/gs/accessing-data-rest/ …and now I am trying to add a custom PeopleValidator by following the documents here: http://docs.spring.io/spring-data/rest/docs/2.1.0.RELEASE/reference/html/validation-chapter.html My custom PeopleValidator looks like package hello; import org.springframework.validation.Errors; import org.springframework.validation.Validator; public class… Read More »

How to generate WADL for Spring REST Service

Questions: Hi I am working with Spring 3.5.0.Release. I want to generate a WADL for my spring rest service. Is their any functionality in Spring by which i can easily generate the WADL. Answers: Spring REST does not come with out of the box WADL generator like JERSEY However it should be pretty easy to… Read More »

Getting “Deadlock found when trying to get lock; try restarting transaction”

Questions: My Application(java spring-core) has several threads running concurrently and accessing db, I am getting exception in some peaktime 07:43:33,400 WARN [org.hibernate.util.JDBCExceptionReporter] SQL Error: 1213, SQLState: 40001 07:43:33,808 ERROR [org.hibernate.util.JDBCExceptionReporter] Deadlock found when trying to get lock; try restarting transaction 07:43:33,808 ERROR [org.hibernate.event.def.AbstractFlushingEventListener] Could not synchronize database state with session org.hibernate.exception.LockAcquisitionException: could not insert: [com.xminds.bestfriend.frontend.model.Question]… Read More »

How to consume Page<Entity> response using Spring RestTemplate

Questions: I’m using spring data (mongoDb) and I’ve got my repository: public interface StoriesRepository extends PagingAndSortingRepository<Story, String> {} Then i have a controller: @RequestMapping(method = RequestMethod.GET) public ResponseEntity<Page<StoryResponse>> getStories(Pageable pageable) { Page<StoryResponse> stories = storiesRepository.findAll(pageable).map(StoryResponseMapper::toStoryResponse); return ResponseEntity.ok(stories); } Everything works fine, but I can’t consume my endpoint using RestTemplate getForEntity method: def entity = restTemplate.getForEntity(getLocalhost(“/story”),… Read More »

Spring Restfull Jax-RS annotation support

Questions: I have following class and web.xml files. Does spring framework supports jax-rs annotation such as @PATH, and @PUT, @Consumes…etc. In other word can I use @PATH instead of @RequestMapping Java: import org.springframework.stereotype.Controller; import javax.ws.rs.PUT; import javax.ws.rs.Path; @Controller @Path(“/register”) public class RegisterServices { @PUT @Path(“/create”) @Consumes(MediaType.APPLICATION_JSON) @Produces({“application/json”}) public Response create(@Context HttpServletRequest requestContex, @HeaderParam(“Authorization”) String authorization,… Read More »

ClassCastException: RestTemplate returning List<LinkedHashMap> instead of List<MymodelClass>

Questions: I’m trying to access getter methods on my MyModelClass but my code is returning List<LinkedHashMap> instead of List<MyModelClass>. This is my code. List<MyModelClass> myModelClass=(List<MyModelClass>) restTemplate.postForObject(url,mvm,List.class); System.out.println(“Response= ” + myModelClass); I tried to print the response and I got the JSON Response that I’m expecting. but when I tried to run this code. System.out.println(“Response= “… Read More »

Spring-batch @BeforeStep does not work with @StepScope

Questions: I’m using Spring Batch version 2.2.4.RELEASE I tried to write a simple example with stateful ItemReader, ItemProcessor and ItemWriter beans. public class StatefulItemReader implements ItemReader<String> { private List<String> list; @BeforeStep public void initializeState(StepExecution stepExecution) { this.list = new ArrayList<>(); } @AfterStep public ExitStatus exploitState(StepExecution stepExecution) { System.out.println(“******************************”); System.out.println(” READING RESULTS : ” + list.size());… Read More »

Spring 4.0.0 basic authentication with RestTemplate

Questions: I am currently working on integration of a third party application with our local reporting system. I would like to implement REST calls with basic authentication but facing issues in Spring 4.0.0. I have a simple solution what works nicely: final RestTemplate restTemplate = new RestTemplate(); final String plainCreds = “username:password”; final byte[] plainCredsBytes… Read More »