Below you will find pages that utilize the taxonomy term “Java”
Reactive Streams Talk
Of all the regular conference speakers on the Java circuit Venkat is my favorite. He has the ability to break down complex topics and make them very simple to understand. In addition to all of that he also shows you why you should care, and how whatever he is presenting can make your development life better. I always hope that when I am explaining something that I can do it 1/10th as good as he does as then it will probably come across pretty fairly understandable to the person that I am talking to.
Go lang
It has been a crazy few months in startup land. The interesting thing for me about startups is no matter how crazy it is compared to corporate work, I find myself really content amidst the chaos. The big change here is we have decided to build our backend architecture in Go instead of Java. Having done Java for 19 years this is a big change, but for business decisions we decided that the trade offs with Go were better for our long term business needs than the trade offs with Java. Now that I have been using it for a few months I figured I would discuss some of the differences between the languages and what I like and dislike about each.
Serverless and Spring Cloud Function
We have been discussing going to a more serverless architecture at work and so I decided that I should do some research to see where that stuff is now. When I was at Choose we used AWS Lambda to implement the backend of an abandoned shopping cart service. We would then use that data to drive an email campaign to encourage the users to come back and finish purchasing an energy plan. It had a huge effect in driving conversion rates and we were able to implement the service in about 25 lines of vanilla java code. I opted not to use Spring as I judged the startup times to be too slow for it to be worth it. To manage libraries we used the maven shade plugin in our build process to build a fat jar.
Java 10, already!
Java 9 we hardly knew ye, yet here we are and today was the GA release of Java 10. This is especially true for those of us using Spring boot as we just got official Java 9 support a couple of weeks ago and now 10 is out. From my standpoint the big features of the release are the Root Certificates. Java 9 shipped without root certificates if you used OpenJDK which in my mind makes it less useable as now you have to with that, you can’t just run it and go. That is what was keeping me on Oracle’s releases of Java. Now in Java 10 there is no difference with the oracle JDK and the OpenJDK so I will probably just deploy my apps on OpenJDK in the future. That simplifies Linux installation as now you can just run apt-get install and go. Before I used to have to add the ppa for Oracles and install it and then deal with the strong crypto policy files. All those old pain points are gone.
Java 9 Upgrade
After upgrading my test app to Spring Boot 2.0 yesterday I decided to see how difficult the Java 9 upgrade was from there. I am happy to report that it was fairly trivial. I upgraded my maven pom to set the Java version to 9 and did a mvn clean install.
Immediately I see some no class def exceptions around javax.transaction.Transaction. I did some quick google searching and discovered the problem seems to be in the Maven Surefire plugin. I found a work around that said to set the version to 2.20.1 and added a command line flag of –add-modules javax.transaction. After doing that I was seeing errors around java.xml.bind. Doing some more searching I then added a second –add-modules java.xml.bind. This fixed the issue. In the course of doing so I found a link to the issue on apache’s website. Reading through the comments I ended up with a final configuration of 2.21.0 with the following options:
Upgrading to Java 9
Upgrading to Java 9
Ever since Java 9 was released last fall, I have been wanting to upgrade our software at work to the new platform. I am not interested in the new module stuff, mostly I just want the convenience methods like List.of(), and the platform improvements. I think G1 by default looks good, the new representation for strings to save memory looks like a huge win, and all the performance numbers that I have seen show it to be a big win. Unfortunately this is not as straight forward as one should hope.
TIL: default hashCode() in Java
I came across this blog post today which I thought was really good. It is a deep dive into the default hashCode() implementation in java. To me the most amazing outcome of the piece is that if a given class is going to be accessed by multiple threads you really need to override hashCode otherwise biased locking is disabled. All in all it is an interesting look in the guts of the JVM and worth a read: default hashCode
AWS Lambda or should I call them nano services?
Recently at work I worked on a project using Amazon AWS Lambda. This is a cool concept. Amazon calls it serverless computing, but really what it is, is abstracting the server so that you can just focus on a small task that needs to run.
In this case we had a rest endpoint that just stores some data in a database. If we think about a traditional Spring Boot Microservice we would probably do Spring Data JPA, point it at a mysql DB, and then have some rest controllers that talk to a service tier which persists the data. With Spring Boot this isn’t much code, but you still have some embedded Tomcat Server and a fair amount of ceremony for doing something very simple. After building the app you will need to deploy it to Elastic Beanstalk instance or else an EC2 Nano Instance or something similar. That is a lot of DevOps overhead to do something very simple. With Lamdba we can create a simple class that takes a pojo java object (Jackson style). With Lambda you don’t have Hibernate, you are just dealing with raw JDBC but when you are just inserting 1 Row into a Database you don’t really need am object relational mapping. You then use Amazon’s API gateway to send any requests to an endpoint to the lambda function and you are all good to go.
MacOS Sierra Slowdown update
I have an update on my slowdown issues on Sierra. It appears the real problem lies in the AWS Java SDK. After talking to the spring boot people via github they were able to narrow it down to an Amazon issue. I opened an issue on github with Amazon and they responded that the version of the SDK that ships in the current spring cloud has this issue in it, and it has been fixed in a newer version of the SDK. One of the big value propositions of Spring Boot to me and the release train concept of Spring Cloud or Spring Data is that it is a collection of dependencies that have all been tested together, which lowers my risk of using them together. So I opened a request with Spring Cloud AWS to upgrade their SDK. Unfortunately they don’t seem very timely in responding to issues as I notice it looks like there are no responses on any of the issues raised in the last 2 weeks.
Spring Boot and Security using Spring Data JPA for authentication
Recently one of my friends was working on a Spring Boot project and he was having trouble finding an example of how to configure user login for his site with Spring Boot using JPA. I had mentioned that there is some mention of configuring security in Greg Turnquist’s book Learning Spring Boot
. He had just purchased
Spring Boot in Action
and I don’t think he was rushing to grab another book, but he hadn’t been able to find a good online tutorial.
JavaMug Spring Boot Discussion
I attended JavaMug last Wednesday as the speaker was Craig Walls author of Spring Boot in Action. When I heard about the book I had planned on purchasing it, but was disappointed there was no kindle version on Amazon. It does state if you purchase the print edition they will give you the kindle one for free, but I am trying to move away from paper books in general.
Overall the talk was pretty good. It is nice that there is a Pivotal employee local to the area so we can get a talk like this done. For most of the talk Craig just sort of demonstrated examples of what you can do with Spring Boot since there were people of varying degrees of experience with it. It was held at Improving in Addison which I had never been to, but they had some nice beer on tap (Kentucky Bourbon Barrel Ale). In a talk like this where you are just trying to introduce the concept to people it is hard to get as deep of a dive as I would like. But I did enjoy the part of the demo playing around with the metrics. That is something I haven’t really played around with, but of course got me immediately thinking about how much I would like to use that at work. I think maybe this year I will attempt to convert our legacy app to Spring Boot. It will be painful, but it just seems like more and more the benefits are so good that is what we should be doing. Hopefully I can find the time at work.
Field injection is not evil
I am a big fan of the work Oliver Gierke has done in Spring Data. It is a framework I use daily at work and it really is amazing. A while back Greg Turnquist had posted something on Twitter against field injection. So I asked what was wrong with field injection and he pointed me to this post that Oliver had written about it.
This post is going to be my attempt to argue against Oliver’s position on the subject. It may wind up an epic failure, but if nothing else I figured it would help me think through my thoughts and assumptions on the issue and see if I can make an argument in favor of it. First head over to Oliver’s post on the topic and read it before you continue on.
Cassandra Days in Dallas 2015
I may have mentioned this before, but I love going to software conferences. When I got the email mentioning that Cassandra Days was coming to Dallas with a free 1 day conference on all things Cassandra, I signed up immediately. The event was sponsored by Datastax who sells a commercial version of Cassandra called Datastax Enterprise. They had 2 tracks an introductory track for people who are just exploring Cassandra, but haven’t yet taken it to production, and track 2 which was a deeper dive for people with experience with Cassandra.
Kegs & code
I attended the kegs & code last night. It was a code challenge and party with cash prizes that was hosted by Saltt Ventures. I had never attended a code challenge or hack-a-thon or anything like that, but I figured it is good to get out of your comfort zone every now and then and try something new. Plus when they have free beer that is a pretty big perk. The beer was supplied by BrainDead Brewery which I hadn’t had prior to this event. The event started out as a happy hour with pizza and beer and then at some point we setup and the challenge began. It was a race to solve 10 problems in the quickest amount of time with first place getting $500, second $250 and third $100.
AspectJ Maven Plugin update
I am happy to report that after much delay the Mojohaus team has finally fixed the Aspectj Maven plugin to allow disabling the annotation processing by the aspectj compiler. It will be fixed in version 1.8 of the plugin. You may recall that back in April I was forced to fork the project to fix this and move on so I could do our Spring 4.1 upgrade. I look forward to switching back to the community version and at that point I will probably delete my github repository as I never wanted to maintain my own version to begin with. Now back to some programming on my new Cassandra layer…
Java 8 lambdas and streams
I just finished up the Java 8 lambda’s and streams class. I finished a little later than I wanted to because I decided to upgrade to Windows 10 last week which was an epic failure. I used the media download tool to upgrade prior to my machine coming up in the queue and all the upgrade ran normally and things appeared to work fine. At the end it booted up and presented a login screen. I attempted to login and the machine sat there spinning for about a minute and then rebooted. After coming back the same. At that point I realized I made a mistake trusting the upgrade and my normal windows procedure is to buy a new drive, do a clean install and then bring my data over. (That was last Wednesday.) So Thursday at noon I ran over to Microcenter and bought a new drive. Then over the weekend I did a clean install of 10 and copied my data from the old drive. I am not up and running on 10 and I would have to say I like it more than Windows 7. It seems fast on my old machine, the UI improvements are great, but I haven’t yet had a chance to test any of my games on Steam to see how it handles video gaming. A coworker tried to upgrade his Windows 7 laptop which also failed but his automatically rolled back. My nephew was able to successfully run the upgrade from Windows 8.1 so it seems like 8 is a safer OS to upgrade from.
I'm back
After a month long hiatus I have returned. I have been traveling for most of the last month so the blog sort of fell to the side. Now that I am done with my summer travel I hope to be back to the weekly posting schedule. That being said I don’t have a lot of updates as I have been vacationing and not doing a lot of work so it was recharge time and not explore new technologies. However today there is a new MOOC starting that people may be interested in, it is the Java 8 Lambda and Streams Intro class. I plan on going through this class to try to improve my way of thinking to be more functional when solving problems in Java. I am hoping to do some work to push a container upgrade at work in the next couple of weeks which will allow us to go to Java 8 in production in the following month so with any luck I will be using these new constructs come fall in my projects.
Clover and Wikitree
Good news this week. Our purchase of Clover was approved and we will have our license keys in a matter of days. As of tomorrow it is going into our build and Cobertura is getting ripped out. You may recall I previously wrote about my issues with Cobertura. One problem was the latest version at the time 2.0.3 didn’t work with Powermock, even though 1.9.4.1 did. And the second issue I was having with it was the lack of Java 8 support since we are close to upgrading on our project at work. Well oddly enough early in this week I saw Cobertura had a new maven plug and a new release 2.1.1. I immediately updated to the 2.7 plugin to give it a go and it promptly failed on Powermock like 2.0.3. So I didn’t feel bad at all when 2 days later I found out our Clover purchase request had been approved.
JHipster
I was reading the Spring Blog the other day and I came across this story. I was intrigued because I found the name funny so I read the post and watched the embedded youtube video and was completely blown away. Take all the excitement I had for Spring Boot after SpringOne and multiply it by 10. Not only does this build on top of Spring Boot it integrates in all the trendy front end technologies that are in use today. All the pain of bootstrapping and setting up a full on website is taken away while they do all the work for you.
Getting crushed by SonarQube
I have been upgrading our Sonar server from 4.5 to 4.5.2 and restructuring our project. I initially was planning on upgrading to SonarQube 5.0, but the upgrade process can’t seem to handle our database. After I upgraded to 4.5.2, I was restructuring. Initially we had each of our libraries setup as a separate project at work and there was a separate sonar project for each one. At one point we decided it was much better to consolidate them all under 1 git repository and make 1 maven master pom with each other project as a module in maven. When we did that we never got around to consolidating our Sonar project to 1 project with sub projects. After we upgraded to intelliJ we found that we couldn’t sue the sonar plugins to integrate with our environment as our project didn’t match our sonar project.
Code Coverage
In my current position one of the metrics we track is code coverage for our unit tests. When I started at the company we were using JUnit with Mockito and JaCoCo. This was a pretty good setup we got good coverage reports and Mockito makes the testing writing much easier.
One of the limitations of Mockito is that you can’t mock private methods or static methods. This presented an issue for us in reaching our desired level of coverage. We initially worked around some of the private method issues using reflection, but it wasn’t always ideal. The decision was made to use PowerMock. PowerMock solved all of our Mockito issues immediately. It was compatible with Mockito but gave us some new powerful features to allow us to get much better unit test coverage. Then we ran our Jacoco reports and found that the reporting no longer worked. Due to the way PowerMock uses byte code manipulation in order to mock static methods it is not compatible with JaCoCo and there is no plan for them to support measuring that.
Spring 4.1 / AspectJ Progress
My coworker discovered that the new version of AspectJ already has the flags built in to turn off the annotation processing. If we can do that we can continue using the Maven Processor Plugin to generate the Hibernate Metamodel data and not have to abandon this. The problem at this point is the AspectJ Maven plugin doesn’t support passing those flags along to AspectJ. So the next step is to get a patch in to that plugin and hopefully we can make the jump to Spring 4.1 at the start of the new year. After that I am going to focus on updating our container so we can finally make the move to Java 8 at work.
SpringOne2GX 2014 Java8 Language Capabilities
I was fortunate enough to attend SpringOne this year and I attended a talk by Venkat Subramaniam on Java 8. I have to say before attending this talk I have always been sort of meh on the functional features brought into the language, but this really got me excited about them. This is the first talk on functional programming that I have ever heard that wasn’t boring, but really engaged the listeners. I strongly recommend people check it out:
Maven Compiler Plugins, AspectJ, and the Hibernate Metamodel generator
For a while now I have been avoiding upgrading the maven java compiler plugin. We are running 2.5.1 at work. The problem is, in the 3.x version, they seemed to have rewritten it, and it doesn’t want to play nice with the maven-processor-plugin that we used to run the hibernate meta model generator. So far it was like cool, I just won’t upgrade to the new version.
Then AspectJ came out with 1.8.2 and the new AspectJ compiler plugin which also seems to be built like the new compiler plugin. At this point I was like well then I might as well update both since Spring 4.1 wants at least AspectJ 1.8.2. But I still have the whole thing fall apart at that meta model step. I found a flag for the maven compiler about forceJavacCompilerUse but even that didn’t solve the problem for me. A coworker said basically AspectJ seems to be doing what we were using the maven-processor-plugin for and generating the meta models for the entities, so he disabled that plugin. However for some reason instead of dumping the generated files in the target directory it is putting them in whatever directory you are in for the build and we can’t seem to find a way to get it to drop them in the target folder.
Intellij Navigation Features
I came across this blog post today which is the best thing I have read. Basically it is just a short cut list for the best different navigation features in IntelliJ. I didn’t know most of these and they are huge time savers so I wanted to share in case people missed the original post which was amazing.
G1GC String Deduplication of a simple Spring Boot Webapp
I was messing around with some of the settings in the Java 8 VM. I have been playing around with Spring Boot lately. So I have a minimal webapp in Spring boot, that has a couple of entities, and services and controllers. I have it configured to run as a standalone jar with an embedded tomcat 8 server. When I do a java -server -jar myapp.jar
Spring boot launches my app and when it finishes loading the java process is sitting at 870,160K of memory.
The road to Spring Framework 4.1
Earlier this year Spring Framework 4.1 was released. I was excited to try out the new features in our project at work and having previously upgraded us from Spring 3.1 to Spring 3.2 and from Spring 3.2 to Spring 4.0 I was expecting this to be another routine Spring update, but alas that was not to be.
One of the first things I do when looking to do a major version upgrade is to check all the dependency versions for the libraries to make sure all of our libraries are new enough to do the upgrade. In this case I discovered that Spring 4.1 requires Jackson 2.x and we were running Jackson 1.9.x.