Second Hackcamp Wolfsburg – December 2014

Last Saturday our second Hackcamp Wolfsburg in 2014 took place. In the run-up to the Hackcamp I had suggested to use the NeosIT office as the event location. @stevenschwenke agreed to that and so I prepared our office on Friday evening. Before the event I expected a team programming session but in the end I explained (too?) much about the Spring Framework and showed samples, use cases and technical approaches to solve different problems with the framework.

Nevertheless it was an enjoyable circle consisting of Steven, Karsten, Sven, Nikolai, Daniel, Kevin, Tobse and me. Besides the usual software development topics we talked about TV series and net political issues. For lunch time we had ordered pizza and Steven bought a lot of juice and fruit. And certainly we had a lot of Club Mate available.

I am really looking forward to the next Hackcamp in 2015 – thank you for the participation and patience ;-)

Mission accomplished: 17 weeks of Freeletics

Four month ago I decided to start Freeletics for gaining more power in preperation for bouldering and to gain back my sixpack I lost with 16. The first three weeks I had ongoing sore muscles: I did sports every day, switching between running, biking and Freeletics. Thankfully to my self-motivation and the fine weather I never thought about giving up.

After three weeks I tried to motivate some of my friends to join but my attempts were not successful and so I did almost every training on my own. Due to my flexible work time I scheduled most of the training sessions in the morning.

The first time I *really* sweared about Freeletics was during my first Kentauros session in mid September. We had almost still 30°C and I did the workout in the burning sun. I never sweated as much as I did until this workout.

A week later my first hell week started. Three workouts a day sounds like much but the two days pause between the hell days allowed me to regain my power.

After the hell week I changed my location from the parking area of VW Bad and Schillerteich to the parking area right in front of the new Vfl stadium. This place is lighted in the morning and there is enough space for doing sprint sessions. Another location I moved to was our office where I did most of the Hades and MAX sessions excluding Pull-Ups. That said I must admit that Pull-Ups are my nemesis.

One week before my final hell week started, my wife and I had flied to Teneriffa for a one week vacation. I had planned to prepare my hell week during the vacation and took my sport clothes with me. Unfortunately I got a bad cold after three days and so I had to pause the training for more than a week. Considered afterwards during the forced pause my body regained the power I lost in the weeks before and in most of the hellweek workouts I got PBs.

And then the hell week began. 12 workouts on 7 days. During the vacation my sleep pattern had dramatically changed and so I started the first hell week day on 3:30 am in the morning. During the rest of the week I had sleep deprivation. During the night I woke up and thought about the next workout. It was a crazy week with few sleep, only thinking about workouts, light lasting sore muscles and always being hungry. On monday morning at 8 am I started the last three workouts at the Schillerteich. It was gusty, around 3°C cold and I had to defeat Kronos in the first place. The Push-Ups, Situps, Squats and Leg Levers were easy, but …100 Pull-Ups? Half of the time of Kronos I spent doing the Pull-Ups. But it even got worse. After Kronos I had to do two Poseidons. In total 100 Push-Ups and another set of 100 Pull-Ups. My body was full of endorphins during the last 10 Pull-Ups and I finished my first 17 weeks Freeletics with a big smile.

In my opinion it was worth the effort. I don’t have any before/after images but I can assure that my body has visibly changed. All in all it was a crazy experience. I plan to do the MAX workouts during the winter and start again with Freeletics as soon as it is cozy and sunny.

Some new tools in our toolbox: Slack, JIRA for sales and marketing processes, Spring Data JPA, Justinmind

In the first days at work after my vacation I got in touch with some new tools and ideas which I want to share

Slack

We were searching for an internal chat solution for my former and current employee since years. Most of the self hosted chat solutions don’t have clients for the smartphone or don’t provide features like syntax highlighting of pasted code. Slack is a hosted chat, the provided free plan suffices our needs.

You might ask why the hell we need an internal chat, so let me explain it:

  • communicate with team members sitting directly at the customer
  • share ideas like images or presentations between the team
  • decrease the sound level in the office
  • don’t interrupt your coworkers so they must leave their “tunnel”

Additional to that we connected our JIRA instance to Slack so we receive issue changes from JIRA inside our project room inside the Slack chat.

JIRA for sales and marketing processes

In mid august a new coworker started in a position for sales and marketing. At this time we did not have decided which tool we want to use for supporting the sales and marketing processes. Our coworker responsible for JIRA administration built a new JIRA project which has different issue types for sales and marketing and maps the real process behind it to a JIRA workflow. The current status is visible on a JIRA Agile Kanban board. A really nice solution.

Spring Data JPA

A few months ago I found Lightadmin which dynamically generates administration web interfaces for Spring Data JPA entities without the need of writing any line of HTML. The project is really awesome: you get a CRUD administration interface for your Spring Data JPA entities with minimal effort.

The problem is that you can not easily customize the interface for the customer because this is not the target of the project. Because of this reason I decided to start a new project which adapts the techniques Lightadmin uses. But instead of generating the interface dynamically at runtime, the interface and backend code will be statically generated by Xtext. After the code generation the artifacts can be customized by our developers.

I am working on the project only for a few days and I am impressed what Spring Data JPA and it’s subprojects offer. I implemented a paginated list view with jQuery Datatables and a search for entities with Predicates / Specifications in five or six hours. Writing all the SQL/JQL code by hand would have kill me.

Justinmind

I am a really bad designer. From a technical point of view I know CSS, HTML and their friends really well  – but putting it together for getting a nice looking and intuitive interface is a race I will never ever win. I was glad when Twitter Bootstrap reached the light.

Whatever: Justinmind is a really nice tool for prototying interfaces. You can choose between different GUI components, bind them to events and fill it with test data. We are still in the phase of evaluating it, but this seems one of the best tools for easy prototyping. For a design-douche like me the tool is a revelation.

My four weeks summer vacation in 2014

Instead of the usual tech stuff I am writing I want to summarize my vacation. Jenny and I started our vacation on the same day. Our first week was consisted of finishing stuff we had lying around in the last months. I did a lot of running, have been bouldering two times in Braunschweig and canoed with one of my workmates.

In the second week we prepared our wedding ceremony. We had a lot of stress on thursday and friday because our supplier of dry ice had not received our order but we got an order confirmation. The dry ice was needed for the ice cream cake. In the end we got it managed and had an awesome ceremony in the Planetarium Wolfsburg. Our friend Sophie was a fantastic wedding speaker. After the ceremony we went to the Awilon: the food was excellent, our inaugural dance was really funny and we partied hard ’til sunday morning. The hangover on sunday was bad, but it was worth them. I was glad that a friend and other relatives of mine I havent seen for a few years joined our wedding day.

On monday in the third week we met again with my friend and his fiancee for dinner It was funny and we are looking forward to their wedding in the next year. A day later I started with sports again and began a new side project, too. The side project is written in old-school PHP and manages sport workouts. On friday I began the first Freeletics workout together with Julian. I was really relieved that my running and climbing sessions of the last months prepared me good enough and so the muscle hangover the next days kept within a limit.

In my last week I did only Freeletics with Tino and Thomas – Julian was unable to continue – and further work on my workout tool. The weather was – like the three weeks before – excellent. Most of the days it has been sunny which motivated me for sports or just relaxing outside.

Wrapping it up:

  • Finished watching Lost. NOW I understand the last season.
  • Prepared and cleaned up the Wolfsburger Ruderregatta
  • Ran 82 kilometers in the four weeks of vacation
  • Canoed on the Allersee with Timo
  • Made delicious cheeseburger with Bison meat
  • Watched Transformers 3 – worst movie for years
  • Watched Drachenzähmen leicht gemacht 1 & 2 – funny!
  • Will never order again ice cake and dry ice
  • Had an awesome wedding ceremony and wedding party with my wife, our family and friends
  • Met one of my friends again after eight years
  • Regained my motivation to do some programming in my spare time
  • Made a Spring MVC/REST architecture template
  • Started writing my workout app in PHP
  • Finished reading Marc Elsberg – Blackout
  • Finished reading Tom Hillenbrand – Drohnenland
  • Started reading Markus Orths – Alpha & Omega
  • Barbecued on some evenings
  • Got a sunburnt belly, brest, arms, legs – but only on the front ;-)

Review Hackcamp Wolfsburg June 2014

Yesterday the first Hackcamp Wolfsburg took place at the Schiller 40. Steven Schwenke did a great job to organize and prepare the event. Despite the fact that only 5 persons, including myself, attended the event it has been a great success. Beneath my coworkers Kevin and Niko from NeosIT and Steven from MSG, Carsten from Eves IT was involved.

Steven started with his JavaFX workshop which gave us a good introduction what can be done with JavaFX. I was working with JavaFX the first time and realized that the framework is cool but there are some drawbacks: Inconsistent APIs, no easy option to import own components in Scene Builder, a missing marketplace for FX components, no reflection of bean properties inside the scene builder and so on. Nevertheless, it gave me a really good start. During lunch time we ordered pizza @Joeys and watched some very funny videos of Joko and Klaas. Being pigged out I started my Xtext talk with a small presentation I hacked together during lunch. It was not the first time I hold a presentation about this topic and the reactions are almost every time the same if the listeners are developers without experience in code generation or modelling: “WTF is he talking about?”. Sooner or later I must prepare an easy introduction presentation, but it is not so easy at all to give a methodical valuable start.

After the presentation with lot of Meta in it we implemented a small project I prototyped together with a customer. As we went along with the coding, the attendees got the idea of code generation and modelling and realized the possibilites what can be done with Xtext. I *really* like this moment ;-) I pointed Steven towards XtendFX and we did talk a lot about possibile applications. I was really surprised that the session took longer than I expected. Thanks for listening and the very interesting discussion!

At the end Karsten showed us JBoss Forge. At a first glance it looked like Spring Roo. I have to take a further look the next days.

After eight hours of hacking and talking I was really wasted but in a good way. I am looking forward to the next Hackcamp and want to thank all participants for making it such a good event!

Doing integration tests with Arquillian and real mocked EJBs

Our current project uses JSF and CDI for the presentation layer. The business logic is encapsulated inside EJB with no-interface view as proposed by Adam Bien and others. I evaluated different alternatives for integration testing and ended up with Arquillian. For JSF/CDI based applications Arquillian is the best fit.

As I digged a little bit deeper into Arquillian one big problem occured: The usage of no-interface EJBs did not allow me to inject some CDI alternatives through the @Alternative annotation. @Alternative expects an interface which I did not have. In addition I had to use the @EJB annotation in the JSF backing bean because our target application server was WebSphere. Since the EJB container, for example JBoss for integration testing, expects all fields annotated with @EJB to be resolved and deployed, I would have to deploy the EJB with all its dependencies. In the end the whole application had to be deployed including database access and without being able to manipulate the result of the EJB methods.
Our data access layer uses JPA/Hibernate but can not make use of “plain” JQL because we had to access legacy stored procedures of an already existing Oracle database – in-memory testing with H2 or Derby was not possible. Another problem would have been the total duration of the integration tests. Our application has a certain complexity and with proceeding project progress the integration tests could not be executed any longer in an acceptable time span.

The only option would have been to switch from no-interface EJBs back to traditional @Local EJBs/interfaces. In the integration tests I would define a stub which implements the interface and deploy the stub with Arquillian. Nevertheless, dynamically controlling the behavior of this stub is not directly possible and I had to write a lot of stubs.

The whole situation did not make me happy. Doing integration tests with Arquillian should force me to change the architecture and introduce more complexity? This was an option I was unwilled to choose and so I searched for alternatives. Surprisingly, Google did not provided any solution. I thought about the problem again and had an idea: I could modify the Java bytecode of the EJB class before it is deployed. The modified EJB would only act as a facade and delegates every method call to an inner mock which has the same class methods as the facade.
After doing some research Javassist seemed to be the best tool for doing the bytecode manipulation. During the implementation of the desired bytecode modifier I struggled with some odd behavior of the application container but in the end I suceeded.

EjbMocker allows you to deploy a bytecode modified version of your EJB to be injected by Arquillian into your application server. You can completely control the behavior of the EJB with help of Mockito. Every method of the EJB is forwarded to an internal mocked instance with the same class signature.

An example project can be found at https://github.com/schakko/arquillian-warp-mocked-ejb. The EjbMocker contains usage instructions so I won’t repeat it here.

Things I have learned in the last few months

A few weeks  ago I had a talk with one of my co-workers in which he said he had not evolved technically and personally in the past months. Aside from the fact that I had a different view it made me think of my own current situation. Which insights did I achieve in last few months? Take this post as a personal retrospective of the last few months.

Seeing myself

Not doing sports makes me feel uncomfortable

I had to take a break for a few days which made me feel real uncomfortable. On the one hand I felt really anxious, on the other hand I had the feeling that I had not accomplished anything. Doing sports almost every day and then having to take a break is a situation I can hardly deal with. It has been written by SpOn that doing sports regularly it pushes you into a addiction. Having smkoed cigarettes for years I can confirm that sports has replaced cigarettes as my addicted-to-drug.

 

Having money is nice, but…

I have always been the person who uses his clothes and tools until they fall apart. This attitude started in my teenager years. Listening a lot to punk rock music and going to concerts could be one for reason for my behavior, I am not really sure about this. During this time I had a real good friend who supported me mentally and financial by donating me without ever wanting a reward. She always said making a gift to other people makes her feel better than buying something for herself. 12 years later I remembered her words again and determined that buying myself something new just for having something new without real usage does not make me happy. Instead I want to pass on the attitude of spending some useful things to people who are really happy about donations. I started my project this month by donating some money to Stratum0 and endowing Mike Pfingsten for his visit at the Entwicklerstammtisch Wolfsburg. My plan is to do one or two smaller donations every months for people or projects inside the IT community.

Talk less, act more

Planning projects or designing processes is really funny but sometimes I am in the situation in which a topic is talked to dead. You know it from roasting a steak: At some point the steak is so tough that you can break someones bones with it but not eat it any longer. If hou have reached this point take the initative and act or nothing will change.

To be honest, in my personal life I follow this rule a little bit too often. This results often in “rollbacks” which cost everyones time. This is definitely one of my weak points which I am trying to reduce.

Procastrination is not always bad

I must admit, after finishing my study at the beginning of the last year I got really lazy with my personal projects, e.g. publishing Nostradamus/prophetr. It is a pity not to deliver my own product but I feel much better with playing some games, reading books or doing sports. Eventually your own state of mind is all that matters and currently I am feeling really balanced.

Delegate work

At some point of my work life I realized that I can’t handle everything and had to delegate tasks. In the first few weeks it was very hard. I had the feeling I had lost control. I had to learn that delegating work means having trust in somebody elses capabilities.

Seeing others

Follow your own rules

Making rules for others means you have to follow your own rules, too. Bending your own rules results in a loss of your authenticity and reliability.

Most people won’t change

Until a few years ago I had the confidence that people can change. Sadly, I must admit, this perspective had changed in the last years. I had to accept the fact that most people can’t or don’t want to change even if this would be the better option.

My motiviation is not your motivation

Having a lot of intrinsic motivation is really powerful. Apart from a few exceptions I am achieving most of my goals. Although I can taint other people with my motivation I can not expect them to have the same level of motivation I have.

Define the roles

Every team member should have a defined role. This role should be written down where everybody can look it up. I am the opinion having a defined role makes you stronger. You have a work identity and the responsibility to push your role topic forward.

Technically faults I made

Making a personal retrospective means admitting my own faults, too.

Using .local as a internal TLD domain

Eh… well.. I set up our company domain with the .local TLD two years ago. In retrospect this decision had led to so much problems like not being able to resolve DNS names because the .local TLD infers with Bonjour protocol. Switching the domain name inside a Windows network is not so easy. I regret the decision every day.

Commit the Eclipse settings to your Git project

I did know that this was probably a bad idea but I had the sligthly hope that it would work. Making things short: It did not work. Never ever ever store your IDE settings in the repository if you are working with other people.

Technically achievements I made

Making Xtext as one of my default tools

Xtext is one of the strongest tools in my developer toolbox. It helped me in various projects and saved a lot of time and money

Connecting JIRA with our own time tracking tool

Some of our customers have full access to their designated JIRA project instances. Being transparently means to track the work times in JIRA. For accounting we use another internal application so we had to track our times in two different systems. I hacked down a PHP script in a few hours which simply copies all JIRA entries to our internal tracking system. Small script, huge time saver.

Technically Lessons Learned

Spring Integration is powerful

We are using Spring Integration in one project for collecting XML files from multiple servers. Spring Integration fits exactly into our requirements and saved the customer a lot of money.

Java EE 6 is not so bad…

I am still not sure if I really like CDI or if I am troubling with Stockkolm syndrom. Using Dependency Injection without having a third party library like Spring or Guice is nice. One drawback is the different CDI implementations (Weld vs. OpenWebBeans) doesn’t necessarily produce the same result. Developing

… but JSF is

I worked with HTML, jQuery, knockout.js and other frontend technologies, like GWT, for years and I liked it because they are transparently in their behavior. Switching from those techniques to JSF is hard. Hard is an understatement. Awful seems to be better fit. JSF adds an additional layer of abstraction where the interaction between browser and client is no longer easy to understand. Besides the fact that different JSF implementations like Mojarra and MyFaces produces different output.

WebSphere is not so bad at all

From an administrative view, WebSphere must be the holy grail. But why the hell does it take so long to deploy a simple web application? Why does enabling security makes the whole WebSphere administration view so slow?

MSSQL: Database * already exists. Choose a different database name. Cannot attach the file * as database.

I am currently playing around with ASP.NET and its Entity Framework. At some point I wanted to execute all my migrations against a new local SQL Express database. After I had dropped the database in SQL Management Studio, the Update-Database command of the Entity Framework failed with the error “Database ‘$path.mdf’ already exists. Choose a different database name. Cannot attach the file ‘$path.mdf’ as database” (German translation: “Die ‘$path.mdf’-Datenbank ist bereits vorhanden. Wählen Sie einen anderen Datenbanknamen aus. Die Datei ‘$path.mdf’ kann nicht als ‘$path’-Datenbank angefügt werden.”).

SQL Server Management Studio did not longer show the database as present. A manually executed DROP DATABASE SQL statement only showed that there was not such a database. After checking some other possible error sources (machine.config, web.config and so on), I ended up with downloading sseutil from http://www.microsoft.com/download/en/details.aspx?DisplayLang=en&id=3990 and dropped the database by hand:

> sseutil -s \.SQLEXPRESS -l # shows all databases in the local SQL Express instance
1. master
2. tempdb
3. model
4. msdb
5. $failed_database

> sseutil -s \.SQLEXPRESS -d name=$failed_database
Failed to detach '$failed_database'

Although I received the detachment error, the database was no longer registered and I was able to execute the Update-Database statement without any problems

Why JPAs persistence.xml sucks

Have you ever tried to develop an Java 6 EE application on different application servers? In production we are forced to use WebSphere AS. I like the configuration interface but that’s all. WAS is not usable during development because the deployment cycles are way too long. Because of this we use JBoss AS 7.1.1 in our development environment. Our application uses Java 6 EE features in service (EJB, CDI) and presentation (JSF, CDI) layer but still uses a DAO layer which is managed by Spring. The DAOs get injected by SpringBeanAutowiringInterceptor. For consistency I had planned to port the Spring DAO layer to Java 6 EE.

First of all our Spring configuration uses the correct database connection settings (Hibernate transaction manager, JNDI name) by a simple environment switch which can be set in the application server. By default, the production configuration for WebSphere is used. If you populate an environment key jndi-jboss, the JBoss settings are loaded on startup. This approach introduced a new architectural complexity but fits exactly our needs. Using JPAs persistence.xml and reaching the same goal should be doable, right?

Well… no. First of all, the JPA configuration is simply not designed to handle different environments. This would not be a problem if an application server specific file like jboss-persistence.xml or ibm-persistence.xml would be used by JBoss repsectively WebSphere. On application startup the application server would load the designated persistence.xml and everything is fine.
My approach was to write a simple parser for properties inside persistence.xml which can be evaluated against system properties, like

 		<!-- Remove the hibernate.transaction.manager_lookup_class setting -->
 		<property name="?(applicationserver.runtime=jboss)hibernate.transaction.manager_lookup_class" value="" />
 		<!-- Overwrite the setting -->
 		<property name="?(applicationserver.runtime=jboss)jta.UserTransaction" value="java:comp/JBossUserTransaction" />

Writing and testing the parser was an easy task so I tried to integrate it in the startup process. JPA has no InitializePersistenceContext handler or something else which is executed on startup. The only possibilty was to extend the Hibernate persistence provider and define my own provider inside the persistence.xml. The idea seemed good but did not work. Persistence providers must be deployed in the application server. JBoss only threw an Persistence Provider not found exception. While I was searching for an easier solution (which probably does not exist – you must deploy the provider inside the application server, at least in JBoss) I came upon a blog post which said, that it is not possible to reference a data source in persistence.xml through a res-ref-name resource. Huh? I do need this, otherwise I am not able to specify the JNDI entry independently from my application server. My jboss-web.xml contains a reference to the JBoss data source while the original web.xml holds the reference to the WebSphere data source.
I reached the point where I decided not to go with a pure Java EE 6 implementation and keep the Spring backend. The only solution is adjusting our Maven build process and creating different EAR artifacts for JBoss and WebSphere, which does not solve the problem to easily deploy the application through Eclipse into one of the application servers.

Update (2014-01-29): I opened a feature request in JBoss’ JIRA (https://issues.jboss.org/browse/WFLY-2816) and put a message on the mailing list. A solution for this problem is to add a check for a jboss-persistence.xml in favour of the original persistence.xml.

Hibernate uses wrong schema during schema validation

Recently I struggled upon the same problem, this guy described. Our Oracle database instance contains multiple schematics with almost the same structure. Every developer has it’s own schema for unit and integration tests. On application startup the Hibernate schema validator calls the DatabaseMetaData.getTables() for every linked entity. The method returns the first table which could be found in any schema. The returned tables are by default ordered by schema name. Side node: I would expect that the home schema of the current user would be prefered. This leads to situation that sometimes the validation fails: a user has already migrated his own schema (schema name app_user_unittest) but the schema for the build server (schema name app_build_unittest) still has the old schema version.

Overwriting DatabaseMetaData.getTables() method is not possible as it resides in the Oracle JDBC driver. Instead, you can use the environment variable hibernate.default_schema which points to to prefered schema. Depending on your development environment, the variable could be set during application startup by the application itself or by a system property through your application server.