Hibernate Search with Spring Data on Pivotal CF revisited

About a year ago I published an article called Running Hibernate Search with Elasticsearch on Pivotal CF. In several projects I use Hibernate Search. If you’re already have Hibernate-JPA-Entities in your project and you need a full text index for some of them, its really easy to add a Lucene based index by just using some simple annotations in addition to your standard JPA annotations. I also have a post on that topic, check Hibernate Search and Spring Boot: Simple yet powerful archiving.

You can now run Hibernate Search against a local disk based Lucene index as well as against the full blown Elasticsearch index. Together with Spring Data JPA repositories it’s a really valuable tool.

Back in September, Sanne announced the general availably of Hibernate Search 5.8, read it here. It now supports an even broader range of Elasticsearch and also introduces the nice feature of using a Simple Query String.

While upgrading the EuregJUG archive, I ran into two little problems. One got fixed nearly immediately after I reported it (see HSEARCH-2883) and the other one was more on my site.

The EuregJUG site runs on Pivotal Cloud Foundry using an Elasticsearch instance from the marketplace. The PaaS gives me the connection URL including user name and password in the form of user:password@host which is perfectly valid. Sadly that isn’t supported by Hibernate Search anymore.

In the process of splitting the environment variable I have I came across Springs EnvironmentPostProcessor interface. This interface can be used to change the environment after all possible property sources have been evaluated. To make this work, you have to declare it in META-INF/spring.factories. You’ll find the relevant parts here (the declaration to make Spring load this instance early) and the actual implementation (not fancy, just splitting a string). I really like the notion of the Environment post processor. I have every property ready to use and can force some of them to be in a format expected for a third party tool. Could be useful in a starter as well.

With that little change I have a nice search system in place, look for example for everything Spring and Mark. This is how simple the snippet from the extended Spring Data repository looks:

Thanks for the very nice work, Sanne, Yoann and Ales!

| Comments (0) »


September wrap-up

As the keen reader may have noticed, there hasn’t been an August summary about the work on Spring Boot Buch. There have been several reasons: At the end of July I gave in the manuscript for lecturing at dpunkt.verlag. After that, I took all holiday I had left at my current company and went on family vacation to Hamburg and Norway, which was really great.

End of August, I met with my new colleagues from innoQ in Edinburgh, my first “innoQ weit-weg-event”. That was quite something. 3 days of discussing all kinds of staff in an open space format. I probably was much quieter than my usual self because I was pretty impressed by this knowledge around.

Regarding my book, I had the chance to review the reviews together with Eberhard Wolff at the innoQ event and incorporate some of it into the manuscript. Thanks a lot for that 🙂 In fact, that was a huge part of what I’m doing right now: Reworking some stuff based on the reviews and reworking much more stuff that just got merged in to the master branch of Spring Boot 2.0 and is available in milestone 4, mainly autoconfiguration for Security and a lot of changes to the Actuator endpoints, including support for Micrometer. Madhura Bhave has published a blog about the changes regarding Spring Boot Security 2 and Stéphane Nicoll wrote about the new infrastructure for Actuators.

Spring Boot takes automagic away for the first time: It’s doing less autoconfiguration for Spring Security and even that backs off completely if you add your own customization. I think in this area that is a pretty good idea, but will lead to interesting upgrades.

Actuator endpoints changes a lot, too. Contentwise, facing monitoring tools and stuff, but also internal. That builds the foundation for technology agnostic implementation: Actuators can now be reactive as well, being based on JAX-RS or as one is used too, based on Spring Web MVC.

The metrics support through Micrometer is going to be awesome and will add value for many apps.

All those topics will be covered in my book. Right now I’m polishing the index, updating my examples to the latest milestones. After that, the manuscript gets out to spell checking and stuff. When the result is processed, all examples are hopefully based on a release candidate so that everything can go into layout. The book will be out not much later than January next year. I In any case, I’ll have it with me when I speak about Spring Boot internals at JavaLand next year.

| Comments (0) »


JDK 9 EA on macOS

The release date for Java 9 is getting closer and it’s about time to get your hands dirty with the early-access builds. Those are available here.

I’m on a Mac running the latest version of macOS. It’s easy to change $JAVA_HOME in a shell through the various settings of you preferred environment. Sadly, $JAVA_HOME (or any other environmental variable, even it’s from a login shell) isn’t picked up by macOS for quite some time now.

So when I run /usr/libexec/java_home -V it gives me

    9, x86_64:	"Java SE 9"	/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home
    1.8.0_131, x86_64:	"Java SE 8"	/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home
    1.7.0_79, x86_64:	"Java SE 7"	/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home

and it picks the latest, which is 9. Several things break with this setting at the moment, for example NetBeans 8.2 doesn’t work.

There’s however a simple solution to the problem. Goto /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/ (i.e. in a terminal or even in finder) and move Info.plist to something else, like Info.plist.bak. The JDK is still fully functional and you can manually set $JAVA_HOME or configure your IDE to use it, but it won’t be picked up by the libexec-tool anymore.

| Comments (0) »


July: Manuscript completed, announcing job changes, JCrete and more

July was something between the 7th and 8th month of working on the Spring Boot Buch and by far the most crazy one. I started the first draft of an outline by late November and early December 2016, shortly before reaching out to publishers. After deciding for dpunkt.verlag I did some milestone planing and as of today, I reached them all in time which was quite assuring.

Manuscript for Spring Boot Buch completed

Last week I gave the complete manuscript in for review. I know that there are some real experts having a look at that stuff right now and I’m totally excited and anxious how that will turn out. The review should be completed by the end of August, than there’ll be another round of creative writing, than proofreading, typesetting and if everything works out, the thing will be out in December or January (though I really hope for December, in time with Spring Boot 2.0).

What will be in the package? It’s basically the outline I published in in January, but the part regarding microservices heavily reduced. There’s so much inside Spring and Spring Boot that isn’t about microservices but just about modern software development, that one cannot do justice to both in the same book. Good for the readers I myself have the awesome opportunity to review another book about microservices that will cover exactly that.

My book and the examples are all written agains the latest Spring Boot 2.0 milestones and I’ll make them sure that everything works with 2.0 final. I’ll cover “classic” Web MVC as well as Springs reactive story. You’ll learn a lot about database access as well.

To keep you updated on the progress I set up a website: Spring Boot – Moderne Softwareentwicklung im Spring Ökosystem. It goes hand in hand with the official twitter handle @springbootbuch.

Announcing job changes

After 15 years working for a small, Aachen based company, ENERKO INFORMATIK, I’m heading for new adventures. I’ll start as a senior consultant at innoQ Deutschland in October. My twitter exploded on that day:

Making the change at all and choosing between two great offers hasn’t been a decision made easily. ENERKO INFORMATIK is a good company and I wouldn’t be where I am right now without them, but it was the right decision to make. And trying to be a “consultant” is driven by the interest to get to know more projects, people and especially learn about a variety of topics I really don’t have a clue about. I’m quite sure that innoQ is a fabulous place to learn, discuss and grow. And regarding to naysayers in terms “you won’t be at home anymore” and stuff like that: Do you really think I haven’t thought and discussed through that? I’m already looking forward to a recap next just before next summers break.

Just before I leave before a well deserved summer holiday, one could say I’ve already been on vacation this year:

JCrete 2017: A once in a lifetime experience

In late 2016 I was chatting with @GeertjanW about #JCrete and what I have to do to get there: I’m neither a Java Champion nor has my book already been published. For whatever reason however @HeinzKabutz invited me to the special 2017 edition of JCrete with a bigger number of attendees.

I loved every single minute being part of an amazing unconference and even better, part of that community, but honestly: It wasn’t vacation at all. From early morning to late in the night surrounded by people that have something to say and with whom one can have a great discussion is rewarding but also exhausting. Discussions where really high level.

Those where all sessions conducted and I highlighted the ones I was in:

I have summarized them all at my foto-project site JCrete 2017, which will be available for two more weeks. More content is at JCretes official GitHub repository. Thanks to Rabea for curating all the content.


I stumbled about a post by Dan Lew: An Introduction to Functional Reactive Programming. If you’re unsure what’s all the fuss so many people are talking about, check it out!

Last week I was in Kassel, not only to meet with my longtime friend Jan, but also to speak yet again about database centric application, this time at the Jug Hessen. It’s great to see such in interest in SQL again. I really think implementing stuff in a way I suggest in my talk is of value in many situations. Not only when someone suddenly shows up and asks for a report, but for example as separate read and write models, too.

To come to an end: August will be more quiet, I have to recharge a lot. Plans for the next 2 months are now: Reviewing a book, taking a that summer holiday and than one more month of cleaning up stuff, doing documentation and so on… I cannot believe that the first half of 2017 is already over. It have been 7 exhausting but tremendously rewarding months so far and I’m looking forward to the next.

| Comments (0) »


June Wrap up

June was a very though month. I did quite some traveling and thus had hardly time for biking. Cycling wise worst June ever, below 300km in total.

Spring Boot Buch

Two weeks ago I received several drafts for the cover and I’m quite happy with them and already decided for one.

(By the way, I have banners, too…)

      __...--~~~~~-._   _.-~~~~~--...__
    //               `V'               \\ 
   //                 |                 \\ 
  //__...--~~~~~~-._  |  _.-~~~~~~--...__\\ 
 //__.....----~~~~._\ | /_.~~~~----.....__\\
Spring Boot Buch on 2.0.0.M2.

I finished the whole messaging chapter, wrote some short paragraphs how to use email sender and started working on my examples for the reactive chapter. I think they quite nice and I’m looking forward to describe them. The chapter about reactive programming is the last to finish.

I’m really happy that I was able to estimate the timeframe of that project relatively good. Next month’s gonna be disrupted, though. First there’s JCrete in two weeks (and I hope that AirBerlin stays in business until I’m back) and then there will be some changes in my life I have to organize, so lets see how this will turn out.

Spring Datasource Proxy

On my way to the location of the third topic of this post, I stumbled upon this post by Arnold Galovics.

He uses datasource-proxy for logging statements. That’s nice if you don’t use JPA for example, which can do it on a different layer. In his post Arnold describes a bean post processor to replace Spring Boots auto configured database (or any other for that matter).

In Spring Boot Buch I describe a different way. In this I use the incredible useful Spring Boot class DataSourceProperties. If you have the spring-boot-starter-data-jpa on the path, configuration properties matching the prefix spring.datasource are automatically mapped to an bean instance of this class. It provides a convenient builder method that even takes care of replacing pool specific configuration with Springs values (for example, HikariCP has some different properties than Tomcat pool).

The properties can be used like this in your configuration:

public DataSource dataSource(DataSourceProperties dataSourceProperties) {
    final DataSource originalDataSource = 
    return ProxyDataSourceBuilder

And that’s it. Spring Boots auto configuration gives your configuration precedence. So you don’t wait for spring-boot-starter-data-jpa to provide a datasource but use the same mechanism like it does to get a datasource only in the scope of the bean method, proxy it and return the proxy.

This works also with Vlad Mihalceas Flexypool for example.

You’ll find this and many more tipps in the upcoming Spring Boot Buch, planned to be published by the end of the year! Follow the progress at @springbootbuch.

That brings me to:

Another installment of bootiful databases and a premiere

Earlier this year I discovered that you can get to Cluj in Romania for just a few Euros via Wizz Air. I reached out to my friend Vlad.

Vlad does awesome work for Hibernate and wrote a great book about high performance Java persistence. We made plans about speaking together and luckily that worked out at the 59th meet up of the Transylvania JUG. They had a full room in a Hotel just for us. Amazing.

The audience was great, we both got good questions and feedback. Sadly, I forgot to take pictures, but I saw someone with a camera.

The day after, a premiere: Accesa booked me for a Spring Boot Workshop. Apart from my terrible cold that went pretty smooth. That stuff was arranged as a test driven introduction to the different slices of a Spring Boot application and I felt comfortable with it. Sadly, half of the audience already had worked with Boot, but that’s just how it is.

If you’re interested in the topic, here is the repository: ws-20170627-cluj. The last commits are an outlook how to integrate Spring Cloud and easily create docker container for your services. If you have interest in that, we should get into contact.

| Comments (0) »