git push deploy to docker

Bin ziemlich zufrieden, mit dem jetzt erreichten Setup, für das automatisierte Deployment unserer Serveranwendungen. Jeder im Team kann jetzt via Jenkins eine aktuelle Version der Anwendungen deployen.

Dazu haben wir über die letzten Monate die verschiedenen bisherigen Artefakte (war, jar) in Docker Images verpackt, docker-compose Konfigurationen für die verschiedenen Installationsumgebungen erstellt (Test, Produktion, Intern, …) und zuletzt noch git repositories mit Hooks eingerichtet, die bei einem Push das Deployment anstoßen.

Read more →

Java ist in den letzten Monaten wieder viel populärer geworden

Laut aktuellem TIOPE Index hat Java den Vorsprung auf die am zweitmeisten verbreitete Programmiersprache C wieder stark vergrössert (um fast 6%). Das wundert mich - was hat dazu beigetragen dass Java gerade in den letzten Monaten wieder so populär geworden ist?

Zuerst habe ich gedacht da zählt auch Groovy und Scala mit rein, aber die werden extra gelistet.

Gut zu sehen auch, dass sich Swift verdient von Platz 25 auf 14 vorgeschoben hat. Am meisten hat Groovy dazu gewonnen - von Platz 82 vor auf 17.

Read more →

Grails 2.2.x and the problem with inner classes

We have been using Grails 2.2.x in some of our projects since it came out last year. Last week when I tried to upgrade another project because it was time to develop some new features I ran into a strange problem after upgrading from 2.1.3 to 2.2.1:

org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error processing GroovyPageView: Error executing tag : Error executing tag : java.lang.VerifyError: (class: com/troii/project/tags/SomeTag$Info, method: getSession signature: ()Ljavax/servlet/http/HttpSession;) Incompatible object argument for function call
	at com.googlecode.psiprobe.Tomcat70AgentValve.invoke(Tomcat70AgentValve.java:38)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:722)
Caused by: org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException: Error executing tag : Error executing tag : java.lang.VerifyError: (class: com/troii/project/tags/SomeTag$Info, method: getSession signature: ()Ljavax/servlet/http/HttpSession;) Incompatible object argument for function call

I had never seen a java.lang.VerifyError exception before and the second strange thing was that the exception only occured when deploying the war in a tomcat not when starting the app with grails run-app.

Read more →

Java Bean Getters/Setters

Many Java developers think they know everything about Java Beans and the correct getter/setter styles, but there are some hidden traps 😉

Let’s do a little quiz!

How should the correct and getter/setter for a property with the following field look like?

private String name;

This is an easy one:

public String getName() {
  return name;
}

public void setName(String name) {
  this.name = name;
}

Notice that the first letter of the field was made uppercase.

Read more →

What to ignore

With the latest improvements we made at troii to our development workflow, we discussed what should be committed to a source code repository and what files should be ignored. We already had the rule in place, that nothing should be put into the repository, that is generated from other sources (typically .class files, .war, .jar, …) – this rule is very common and agreed by almost every developer.

How to handle another set of files usually leads to a lot of discussion: IDE settings, e.g. Eclipse .settings, .project, .classpath or IDEA IntelliJ .iml and .idea directory). Up until a year ago we mainly used Eclipse and I used to store the IDE configuration files in the repository. With switching to IntelliJ and working more with git branches, I startet to think about this again, because I had the feeling that those settings files changed more frequently.

Read more →

The size of java.util.Calendar

A friend of mine asked me why his Java batch job reading a 23MB text file took over 300MB Memory. He read some text and date values and stored them in String an Calendar objects. A short web search brought up this blog post of Jason Rennie writing about the size of java.util.Calendar. He points out that a single instance of java.util.Calendar takes 432 bytes of memory. This was the explanation – 500000 calendar objects need 206MB memory! This was new to me …

Read more →

Tomcat remote debugging

Sometimes your web applications behave different when deployed to the application server although everything worked fine when running inside Eclipse on your workstation.

In this case it is helpful to remote debug the application. In case of using Tomcat as application server just add the following VM parameters to JAVA_OPTS:

-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n

I do this inside the file setenv.sh in the bin directory by adding a line JAVA_OPTS="…options…"

The paramete -Xdebug tells the VM to start in debug mode. -Xrunjdwp selects the protocol. Change the port 8000 to an appropriate value for your server (one that is not used by another process and is reachable). By setting the value `suspend=n``` the VM does not wait until a remote debugging session connects until starting.

Read more →

Java memory leaks

Today a colleague of mine found nice page with the story of a java memory leak hunter. This is a story out of real life - if you ever tried to find out why huge java (server) applications get an OutOfMemoryException you’ll know what this man is talking about. He found out some very interesting things.

On this page an Eclipse profiler is mentioned - looks nice, I’ll have to test it.

Read more →