Quartz integration in Spring

Why Quartz? motivation Spring comes already with an own timer and this is fine if we have very simple requirements and we don’t really care about state or on which pod the timer is actually running. To be more precise the timer/ job is running in each of our spring containers independently. Lets be honest,…

Reconnecting JMS listener

Problem In some projects we still may need to manually to reconnect to our JMS provider. For what ever reason the framework or the container cannot do the job for us. As so we have to ensure that an once registered JMS listener re-register itself if something bad happens. Note: Check first if your container…

Dates, DateTime, Timezone and the DB

TL;DR Summary Java Type DB Type Description SAVE Long NUMBER Just using a long as milliseconds, between the current time and midnight, January 1, 1970 UTC is the most secure way. SAVE Instant NUMBER Using in Java an Instant and converting it into a NUMBER to save it in the DB will also avoid any…

JEE 7 Activiti integration

Overview To enable Activiti in our JEE project the following steps are needed: Add the maven dependencies — include spring-context Add log4j configuration Add the activiti configuration for CDI integration activiti.cfg.xml Add your first activiti workflow Add an activiti compatible data source to your container Deploy and run it Git Project. Eclipse Plugin To install the…

JPA default entity listener

The problem Sometimes we want to register a default Entity Listeners which are called as soon an entity is persisted, without adding the @EntityListeners annotation to our classes, as in most cases we anyway provide interfaces so we can access data on the entity itself. The problem is, that we cannot annotate our entity listener with…

Android Fragments and Transactions

Problem Sometimes it is confusing how fragments work in Android and interesting side effects like: Why have Fragments empty constructors? Why shouldn’t I pass state variables like they are? Why do I need this Fragment transactions? What does addToBackStack mean and do I need it? Why is sometimes the Activity null in my fragment? Overview…

Java SSLContext and the SSLSocketFactory self-signed certificate

Problem Often we want to connect to create a secure SSL connection to an HTTPs endpoint which is secured by a self-signed Certificate. If we do so just with a simple call we usually face an nice exception like: Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested…

Spring Data MongoDB and JSR Validation using Lazy DBRef

The Problem Recently using MongoDB and Spring Data I encountered an interesting issue. Saving an Entity  which was loaded by @DBRef(lazy = true) wasn’t possible together with the activated ValidatingMongoEventListener. Each time the following error occurred: javax.validation.ConstraintViolationException at org.springframework.data.mongodb.core.mapping.event.ValidatingMongoEventListener.onBeforeSave(ValidatingMongoEventListener.java:65) at org.springframework.data.mongodb.core.mapping.event.AbstractMongoEventListener.onBeforeSave(AbstractMongoEventListener.java:144) at org.springframework.data.mongodb.core.mapping.event.AbstractMongoEventListener.onApplicationEvent(AbstractMongoEventListener.java:90) at org.springframework.data.mongodb.core.mapping.event.AbstractMongoEventListener.onApplicationEvent(AbstractMongoEventListener.java:33) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:163) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:136) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:381) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:335) at org.springframework.data.mongodb.core.MongoTemplate.maybeEmitEvent(MongoTemplate.java:1633) at org.springframework.data.mongodb.core.MongoTemplate.doSave(MongoTemplate.java:986) at org.springframework.data.mongodb.core.MongoTemplate.save(MongoTemplate.java:933)…

Serialization Jackson vs Google Protocol Buffers

Where are many articles around comparing the serialization between different frameworks and of course different encodings. I came around recently the problem that I needed a very fast serialization for pretty simple objects but between different platforms (embedded device with C, Android Java, iOS Objective-C and Java Backend). Well first reaction, let us just take…