Nov 06, 2020
Java EE and OpenLiberty
This is just a rant, don’t take it too seriously.
Greenfield project, decided for Java 8, OpenLiberty, JUnit 5, etc.
The first thing I ditched was CDI.
Damn, that was all ok, put some annotations here and there and, boom, here’s your dependencies.
BUT how the fuck do I inject mock dependencies in unit tests?
Geez, I asked in my company where there are some people with a fair knowledge of java EE and they said they reimplemented a junit test runner to make this work.
Tried the reimplemented runner with no luck, so I just wrote a class to build dependencies. The project is small, so no problem going this way.
The anger level was about 5.
Fast forward to deployment. We always developed with mvn liberty:dev
that is the openliberty maven plugin command to pack and start your application
on openliberty and do the hot redeploy thing, compiling and redeploying
only changed classes. Cool.
BUT the hot redeploy thing does not work for everything: if you change,
for ex. src/main/java/liberty/server.env the server does nothing.
Apparently no one warns you about this, but, it’s somewhat no big deal,
is easy to figure out.
The thing that raised my anger level was the packaging thing.
Openliberty scarse documentation says that you can package
your application and the application server together in one executable jar,
like spring boot does.
I liked the approach and I planned to deploy our application
to our customer environments that way.
Except it didn’t work.
Got problems with JPA scanning: it didn’t find any entities.
Obviously our local environments ran just fine.
So, I had to download the openliberty zip from its website and change the deploy approach to a classical (for java) one.
In conclusion there are broken promises with those tools that can leave you angered and frustrated.
Beware.