spring-4

Spring 4 websockets causing tons of exceptions

徘徊边缘 提交于 2019-12-11 08:14:06
问题 Ever since we started using websockets in Spring 4, our logs are littered with this exception: 3 ERROR MessageBrokerSockJS-1 handler.XhrStreamingTransportHandler$XhrStreamingSockJsSession:276 - Terminating connection after failure to send message to client. This may be because the client has gone away (see https://java.net/jira/browse/SERVLET_SPEC-44) Feb 15 12:05:16 apmgui i-04e9bc6a: ClientAbortException: java.net.SocketException: Broken pipe Feb 15 12:05:16 apmgui i-04e9bc6a: at org.apache

Ehcache concurrent modification exception using + Spring + Struts application

[亡魂溺海] 提交于 2019-12-11 04:46:44
问题 In my application the ehcache is configured as below. AppDataRegion.java //import statements. public class AppDataRegion{ //Variable for region identifier. private String appRegionId; // constructor sets the appRegionId; //obtained from the system current time. public AppDataRegion(){ appRegionId = String.valueOf(System.currentTimeMillis()); } //Variable for cachemanager // injected by spring DI from context xml Private CacheManager appCacheMngr; //necessary getter / setter methods for

Spring MVC with JAXB, List response based on a Generic class

十年热恋 提交于 2019-12-11 04:06:52
问题 I am working with Spring 4, together with Spring MVC. I have the following POJO class @XmlRootElement(name="person") @XmlType(propOrder = {"id",...}) public class Person implements Serializable { … @Id @XmlElement public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } … } If I want return a list of Person through Spring MVC in XML format, I have the following handler @RequestMapping(value="/getxmlpersons/generic", method=RequestMethod.GET, produces=MediaType

How to run update query in Spring JPA for quartz job

删除回忆录丶 提交于 2019-12-11 03:38:30
问题 I have a quartz job in spring 4 and I am using JPA hibernate to update database value through quartz job but I am getting javax.persistence.TransactionRequiredException: Executing an update/delete query I don't understand what kind of configuration is missing in quartz job. I referred to SpringBeanAutowiringSupport example still update is failing but select is working fine. Below is my code @Configuration @ComponentScan("com.stock") public class QuartzConfiguration { @Autowired private

Post Array of String values as request body using curl in Spring MVC

谁都会走 提交于 2019-12-10 22:13:07
问题 Not able to post Array of string ids to Spring mvc controller using curl as it is throwing 400 status. Controller Method: @RequestMapping(value="/evidencesbyIds",method = RequestMethod.POST) @ResponseBody public Map<String, Object> getEvidenceByIds(@RequestBody String[] ids){ // body here } CURL Commands: curl -H "Content-type: application/json" -X POST -d '{"ids":["1","2"]}' http://localhost:8080/vt/evidencesbyIds curl -H "Content-type: application/json" -X POST -d "{"ids":["1","2"]}" http:/

Is Mybatis supported with Spring 4.x?

安稳与你 提交于 2019-12-10 19:39:27
问题 I tried mybatis-spring 1.2.2 with mybatis 3.2.5 and Spring version 4.1.0.Release and it appears like it is not supported. mybatis-spring 1.2.2 spring contains org.springframework.core.MethodParameter class however, getContainingClass() is not present. I am getting the exception: java.lang.NoSuchMethodError: org.springframework.core.MethodParameter.getContainingClass() Any idea is I could use Mybatis with Spring 4x at all? (even ibatis seems to be unsupported) 回答1: Looking in the pom.xml of

Spring 4 recommended replacement of JpaTemplate

南笙酒味 提交于 2019-12-10 18:35:39
问题 I have a legacy project which was using Spring 3.0.x and made use of the JpaTemplate implementation provided by Spring. However, after upgrading to Spring 4.0.x I learned that JpaTemplate was deprecated as of Spring 3.2 I have seen suggestions to simply refactor out the use of JpaTemplate with EntityManager . However, replacing JpaTemplate with EntityManager is not sufficient as I discovered this project was wrapping the JpaTemplate calls in a JpaCallback , which in turn used entitymanager. I

How to use OAuth2RestTemplate + Spring 4?

橙三吉。 提交于 2019-12-10 17:12:41
问题 I'm trying to understand how to use a OAuth2RestTemplate object to consume my OAuth2 secured REST service (which is running under a different project and let's assume also on a different server etc...) f.e. my rest service is: https://localhost:8443/rest/api/user -> Accessing this URL generates an error as I am not authenticated To request a token I would go to: https://localhost:8443/rest/oauth/token?grant_type=password&client_id=test&client_secret=test&username= USERNAME &password= PASSWORD

How to inject a bean into a Spring Condition class?

放肆的年华 提交于 2019-12-10 15:51:56
问题 I am defining conditions that I will check to dynamically load one of the two implementations of my service interface later. @Component public class IsPolicyEnabled implements Condition { @Autowired private MyProperties props; @Override public boolean matches(ConditionContext arg0, AnnotatedTypeMetadata arg1) { return props.isPolicyEnabled(); } } And @Component public class MyProperties {...} And @Service @Conditional(IsPolicyEnabled.class) public class ServiceA implements Service {...}

How to handle client abort during request upload?

丶灬走出姿态 提交于 2019-12-10 15:37:40
问题 Given the following application, based on a Spring Initializr template @SpringBootApplication public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } public static class Payload { public String field1; public String field2; } @RestController public static class MyController { @RequestMapping("/echo") public ResponseEntity<Payload> echo(@RequestBody Payload payload) { return new ResponseEntity<>(payload, HttpStatus.OK); } }