Mockito – easily test your application
Posted by StephanBeutel in Java on 2012/04/20
Who didn’t know that? As developer you have to test your application with some unit tests, but how to test a service which uses a session object for example. Now we can easily mock this object to test our function successfully. As example I use very small code snippets to show you how to use [...]
Convert milliseconds to formatted String with Java
Posted by StephanBeutel in Java on 2011/10/07
Since 1.5 there is the java.util.concurrent.TimeUnit class, use it like this: String.format(“%d min, %d sec”, TimeUnit.MILLISECONDS.toMinutes(millis), TimeUnit.MILLISECONDS.toSeconds(millis) – TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis)) );
Monitoring Tomcat 7 with JMX
Posted by StephanBeutel in Java on 2011/07/15
Enabling JMX on Tomcat Enabling JMX without Authentication JMX is enabled by setting some Java properties in the command used to start an application. You will need to set the CATALINA_OPTS environment variable so the correct properties get set for to Tomcat when it starts. Furthermore, the properties you set will determine if application can [...]
Socket creation problem with Java on Linux
Posted by StephanBeutel in Java on 2011/07/04
Sometimes a problem occurs while trying to open a socket connection with Java on a Linux system. Mostly this is a problem with server settings. It happens if you’ve enables IPv4 and IPv6 on the system. To make shure Java uses only IPv4 every time a connection is created, just put a new entry in [...]
Using classes from external jars in GWT project
Posted by StephanBeutel in GWT, Java on 2011/04/27
For an introduction in GWT please see GWT tutorial. The following describes how to use external jars or Java projects within your GWT project. The standard approach in Java is to have separated projects for separate purposes. For example the domain model of the application is usually defined in its own project. One way of making these [...]
Persist detached entity
Posted by StephanBeutel in Hibernate, Java on 2011/03/03
Sometimes you have to store an object in a database. I run into the problem that I got this error: org.hibernate.PersistentObjectException: detached entity passed to persist It’s realy easy to solve this problem, just ensure to create the object to be saved after beginning the transaction. In my case I just created a constructor like [...]
Problem including dispatcher servlet with spring security
Posted by StephanBeutel in GWT, Spring on 2011/02/18
First of all here’s my way to integrate the dispatcher servlet: 1. Create a controller class to handle the RCP requests:
Perform release with Maven
Posted by StephanBeutel in Maven on 2011/02/17
1. Remove Snapshot dependencies in pom.xml files 2. Change version numbers of dependencies if necessary
Create Branch with Maven
Posted by StephanBeutel in Maven on 2011/02/17
Creating a branch involves the following release phases: Check that there are no uncommitted changes in the sources Change the version in the POMs if you want to change it in the branch (you will be prompted for the versions to use)