Category Archives: Java

Error handling in Apache Camel

Scenarios When coding an integration with Apache Camel, we need to be able to deal with many different kinds of error: Bug / error in our own code, before we have communicated with the remote service. Getting a connection to … Continue reading

Posted in Camel, Java | Tagged , | Leave a comment

Gradle incremental tasks and builds

One of the things that makes a build efficient is when it can run incrementally. i.e. If you have already run one build, and you change things and run another, the second build should only have to rerun some tasks … Continue reading

Posted in Gradle, Java | Tagged | Leave a comment

Gradle Release Plugin

Gradle has a release plugin that mimics the Maven release plugin behaviour. i.e. you specify a snapshot version in your build and the plugin can update the version to a released version, commit and push that. The plugin is not … Continue reading

Posted in Gradle, Java | Tagged , | Leave a comment

Dependencies and Configurations in Gradle

What is a Gradle configuration? In Maven dependencies can be assigned to a given scope: compile – available on all classpaths and propagated to dependent projects provided – will be provided by your container runtime test Gradle has a much … Continue reading

Posted in Gradle, Java | Tagged , | Leave a comment

Type conversion and NoTypeConversionAvailableException in Apache Camel

In Camel, type conversion of a message body can be done using the tag: <convertBodyTo type=”com.something.SomeClass”/> Camel docs on type converter: https://camel.apache.org/manual/type-converter.html Type converters are loaded from the classpath, so the imports of your OSGI module will affect what converters … Continue reading

Posted in Camel, Java | Tagged , | Leave a comment

Using test fixtures in Gradle and Maven

In Maven if you want to reuse text fixtures from one module in another module, you use the jar plugin and build a test jar. You have to specify what classes and other resources to include. Gradle has a dedicated … Continue reading

Posted in Gradle, Java | Tagged , | Leave a comment

Memory leak with Spring integration test context caching

I’ve recently had to debug another out of memory with our Spring integration tests. The tests are configured to create a heapdump on out of memory so I loaded it up with the Eclipse Memory Analyser and this is what … Continue reading

Posted in Java, Spring, Testing | Tagged , , | Leave a comment

Enforcing Spring role based security with a custom PMD rule

Spring makes it easy to have role based security with its @PreAuthorize annotation. But how do you make sure that developers remember to add a security annotation? I like using PMD to do static analysis checks on our code and … Continue reading

Posted in Java, PMD, Spring, Static Analysis | Tagged , , , | Leave a comment

Hibernate Best Practices – using sequences for bulk inserts

For many database tables, an auto increment column is used for the primary key. This is fine for inserting single values, but if you want to bulk insert hundreds or thousands of values and you need to refer to the … Continue reading

Posted in Hibernate, Java, Uncategorized | Tagged , | Leave a comment

Java XML processing with JAXB and special characters

When processing XML, it is important to understand that there are two kinds of special characters: Characters that are permitted, but must either be escaped or inside a CDATA block. Control characters that are not permitted at all. Characters that … Continue reading

Posted in Java, XML | Tagged , | Leave a comment