PowerMock and Java8 Streams

Recently I was writing some units tests, as all good developers should, and ran into an issue with a test that made use of the IntStream of(int t) method. The test execution failed and throw the following exception:

java.lang.IllegalStateException: Failed to transform class with name com.readlearncode.ServiceTest. Reason: javassist.bytecode.InterfaceMethodrefInfo cannot be cast to javassist.bytecode.MethodrefInfo

After googling for the solution I found that others had had the same issue. A StackOverflow question and answer gave me the solution. As this is issue could cause someone quite a lot of pain I thought I would reproduce it below:


PowerMock has a dependency on javassist, exclude the transitive dependency in my POM and include the dependency separately.

Here is the POM snippet:








Error: No package erlang available.

If you are trying to install Erlang on CentOS/7 you might be presented with the following errors:

Screen Shot 2016-05-03 at 17.11.57

These errors mean you don’t have the updated RHEL EPEL Repo from which to fetch Erlang builds. You update your repo as follows:

Screen Shot 2016-05-03 at 17.33.13

Screen Shot 2016-05-03 at 17.33.32

Screen Shot 2016-05-03 at 17.33.47

Retry installing Erlang.

Screen Shot 2016-05-03 at 17.37.17

For centos 5 and 6 visit this blog post.

Thanks to jake_morrison from Reddit who posted this response.

The Erlang packages in the distro are not kept up to date, and go stale pretty quickly with the pace of Erlang development.

It’s better to use the packages from ESL: https://www.erlang-solutions.com/downloads/download-erlang-otp

Relevant Ansible tasks:

- name: install esl key
  rpm_key: state=present key=http://packages.erlang-solutions.com/rpm/
  become: true

- name: install esl repo
  copy: src=etc/yum.repos.d/erlang-solutions.repo dest=/etc/yum.repos.d/
    erlang-solutions.repo owner=root group=root mode=0644
  become: true

- name: install erlang
  yum: name=erlang state=latest update_cache=yes
  become: true

See original reply here.

Configure Tomcat 9 for HTTP/2

One of the most significant advancements in JavaEE 8 is support for HTTP/2. Three server vendors currently support servlet 4.0, Apache Tomcat 9.0.0.M4, Jetty 9 and WildFly 10.0.0.Final. Lets have a look at how to configure Tomcat 9 to support HTTP/2.

I often post about Servlet 4.0 on Twitter. Follow me here

Java EE Revisits Design Patterns

This and subsequent posts are a write up of my Java EE revisits design patterns talk at jDay Sweden 2016.

The slides to the presentation are viewable here: Java EE Revisits Design Patterns and a video of the presentation will be made available as soon as jDays publish it.

The book that accompanies this talk is available from Amazon.

qMaster Java EE design pattern implementation to improve your design skills and your application’s architecture

Professional Java EE Design Patterns is the perfect companion for anyone who wants to work more effectively with Java EE, and the only resource that covers both the theory and application of design patterns in solving real-world problems. The authors guide readers through both the fundamental and advanced features of Java EE 7, presenting patterns throughout, and demonstrating how they are used in day-to-day problem solving.

The talk has been divided up into the following sections.