Tag Archives: spring

spring boot tomcat jsp is downloaded not rendered

Questions: I am bootstrapping my spring application to spring boot and I have the problem that the embedded tomcat is not rendering the jsp files instead the file will be downloaded. I have googled and tried everything what I have found so far but I still do anything wrong. I have the following dependencies in… Read More »

Unable to decrypt config property in Spring Cloud config using asymmetric encryption

Questions: I am trying to load the decrypted config property from config server but failing with below error: 2018-08-07 09:58:26.534 WARN 20400 — [nio-8888-exec-3] o.s.c.c.s.e.CipherEnvironmentEncryptor : Cannot decrypt key: password (class java.lang.IllegalStateException: Cannot load keys from store: class path resource [server.jks]) This error happens when server.jks is placed in the classpath. But when placed in… Read More »

How to disable Spring/Hibernate/Hazelcast joint cache?

Questions: We use Hazelcast as our Hibernate 2nd level cache manager and we have some configurations for it in our Spring context files. Our code is also instrumented by Spring @Cacheable annotations (for business level cache) and we configured it to use Hazelcast. The problem is that in development environment we have multiple database instances… Read More »

spring data fetch mapped object in order

Questions: We have Spring Boot 2.x, Spring Data and PostgreSQL as database. In our application we have Driver class as below @Data @Entity public class Driver { private String id; private String name; private String licenseNo; } Now a car can be driven by many drivers. So we have Car class as below. @Data @Entity… Read More »

Spring JDBCTemplate issue

Questions: i have a method to update multiple rows in my oracle database using jdbc template. before updating the application has some processings to do, if these processings are successfully completed it goes on for the update. HashMap<String, Object> mapUpdate = new HashMap<String, Object>(); mapUpdate.put(“ID_REF_STATUT”, IConstants.Status.GEN); mapUpdate.put(“DATE_REGLEMENT”, new Date()); managerTransactionDao.updateListValeur(listValeurs, mapUpdate); HashMap<String, Object> mapUpdateBord =… Read More »

How to deserialize Spring Boot actuator environment

Questions: I would like to deserialize the Spring Boot Environment object returned by: http://hostname:port/actuator/env I’m using Jackson’s ObjectMapper: private static final ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); … ClientResponse clientResponse = resource.type(MediaType.APPLICATION_JSON).get(ClientResponse.class); InputStream is = clientResponse.getEntityInputStream(); org.springframework.core.env.Environment e = mapper.readValue(is, org.springframework.core.env.Environment.class); The code above fails with the following error, which makes sense: com.fasterxml.jackson.databind.JsonMappingException: Can not… Read More »

Force Spring @WebMvcTest to initialize spring internal controllers

Questions: I am using @WebMvcTest to test the API of my application. It is working just fine when I test my custom controllers. However, I’d like to write tests that are testing Spring-internal controllers. Specifically, EncryptionController provided by spring-cloud-config, but the question is also applicable to spring-actuators. Example code: @RunWith(SpringRunner.class) @WebMvcTest public class ApiTest {… Read More »

Spring, JPA and Rest and Duplicate entry for key 'PRIMARY'

Questions: I’m just starting to learn Spring and JPA and I’ve run into a bit of a wall trying to figure out what is causing my app to try and insert cascaded values in multiple times. I have the following structure: pom.xml <?xml version=”1.0″ encoding=”UTF-8″?> <project xmlns=”http://maven.apache.org/POM/4.0.0″ xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”> <modelVersion>4.0.0</modelVersion> <groupId>com.test</groupId> <artifactId>core</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging>… Read More »

SpringBoot 2 transaction propagation NESTED not supported

Questions: I have a SpringBoot 2 project and i’m using spring data jpa with hibernate with MySQL5.7 I have problems with the following use case: i have a service method that calls another service’s method. If second service’s method generates a runtime exception, also the first method is marked as rollback and i cannot commit… Read More »