Installing OpenJDK 11 on macOS (again)

I have started to use SDKMan to simplify my life with installing and updating many software that I use regurlarly. Java is one of them. It is the simplest thing to install java with sdk man:

sdk i java 11.0.8.hs-adpt

As simple as that.

I can just use Java 11 from that point on. You can also install Java 8 and switch between both. Convenient when you have to maintain older software.

If I want to update to a new release, I simply have to type:

sdk ug java

Can it really get any easier?

I use the SDKMan on my linux laptop as well and it easily works on both.

I also manage gradle, spring-boot and spark with SDKMan so most of my coding tools are kept up to date with the same tool.

Learning Kotlin 1/10000

It is a nice language to learn but I am not dedicating enough time right now to make the progress I would like.

Little thing I learned last night was the repo for use the Anko “library” in my code.

maven { url "" }

Sometimes the simplest thing takes you an hour to figure out. All the examples for Anko that I looked at were partial so they showed the dependency line to add:


I guess that I have to be happy that I figured something out.

Back to coding a micro-service with Spring Boot and Kotlin…

A Not acceptable Rest with Spring

Trying to come up with a clever title for a blog post is not easy.

This problem caused me headaches for 2 days and as much as I have resolved it I have no idea why and how it happened.

I have done REST application with Spring many times in the past and it easy. At one point in the process for this one I was creating REST application with STS just to confirm that it was a no brainer, which helped and puzzled me.

The simplest class that worked for me was something like this:

public class Rest {
    @RequestMapping(value="/{something}", method=RequestMethod.GET, produces=MediaType.APPLICATION_JSON_VALUE)
    public String[] firstTry(@PathVariable String something){
        return new String[]{something, "testValue"};

I could quickly package it with Maven and run it on Wildfly and it would work as expected.

When I tried to do the same in IntelliJ I was getting a non working application that returned a 406, Not Acceptable, return code to all REST calls.

I compared the web.xml, the application context xml files, the pom files, everything I could thing of and the STS app would work with nothing special but the IntelliJ app would not.

Most articles I was finding were talking about bugs in some version of Spring and to make sure you had the element in your application context xml. I tried many version and adding the annotation driven did not fix the issue.

I finally found this article that explained that you needed to make sure you specified the jackson-databind library in your pom.xml otherwise you would get 406 answers. Once I added the jackson libraries to my project from IntelliJ I was able to get things to work as expected.

No Jackson libraries are specified in my STS generated project and they work so I am still puzzled as to why this was needed in the IntelliJ project.

Upgrading Groovy and Grails

I have started to learn what Groovy and Grails can do for web application development and I already faced a fun problem.

After I installed GGTS (from, I started a simple application and then wanted to upgrade the Groovy and Grails version to the latest.

Not as straight forward as I would have taught but I got everything working again.

First thing learned is that GVM is a useful tool to use to install Groovy and Grails and manage multiple versions. Doing it manually does not make sense.

I also learned from a stackoverflow article that you need to erase the .metadata directory in the GGTS workspace after upgrading. This will force you to re-import your projects but that is the only way I have found to recover the projects so it is a small inconvenience.

Back to learning!

Learning Groovy and GRails – 1 of X

I want to learn Groovy and Grails because I want to deliver applications faster and with better quality.

I am unsure if this is the right strategy but it is going to be a fun experiment. Learning is always fun.

I will start with a few videos and go from there:

I will also have to look at the documentation on the spring site to figure out all the static variables and built-in methods that can be used.

Quartz Scheduler Errors

We learned this week what this error message meant for us:

org.quartz.impl.jdbcjobstore.JobStoreTX.recoverMisfiredJobs [] Handling 1 trigger(s) that missed their scheduled fire-time.

This was happening because we had more jobs configured to run at certain time than we had threads configured to run.

We changed the spring servlet configuration file to specify more threads and more datasource connections.

<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
 <property name="triggers">
 <ref bean="somethingTrigger" />
 <ref bean="something2Trigger" />
 <ref bean="something3Trigger" />
<property name="applicationContextSchedulerContextKey"><value>applicationContext</value></property>
 <property name="overwriteExistingJobs"><value>true</value></property>
 <property name="quartzProperties">
 <prop key="org.quartz.scheduler.instanceName">InstanceNameX</prop>
 <prop key="org.quartz.scheduler.instanceId">AUTO</prop>
 <prop key="org.quartz.threadPool.class">org.quartz.simpl.SimpleThreadPool</prop>
 <prop key="org.quartz.threadPool.threadCount">20</prop>
 <prop key="org.quartz.threadPool.threadPriority">5</prop>
 <prop key="org.quartz.jobStore.misfireThreshold">60000</prop>
 <prop key="org.quartz.jobStore.class">org.quartz.impl.jdbcjobstore.JobStoreTX</prop>
 <prop key="org.quartz.jobStore.driverDelegateClass">org.quartz.impl.jdbcjobstore.PostgreSQLDelegate</prop>
 <prop key="org.quartz.jobStore.useProperties">false</prop>
 <prop key="org.quartz.jobStore.dataSource">myDS</prop>
 <prop key="org.quartz.jobStore.tablePrefix">QRTZ_</prop>
 <prop key="org.quartz.jobStore.isClustered">true</prop>
 <prop key="org.quartz.jobStore.clusterCheckinInterval">20000</prop>
 <prop key="org.quartz.dataSource.myDS.driver">${db.driver}</prop>
 <prop key="org.quartz.dataSource.myDS.URL">${db.url}</prop>
 <prop key="org.quartz.dataSource.myDS.user">${db.username}</prop>
 <prop key="org.quartz.dataSource.myDS.password">${db.password}</prop>
 <prop key="org.quartz.dataSource.myDS.maxConnections">23</prop>
 <prop key="org.quartz.dataSource.myDS.validationQuery">select 1</prop>

We have not seen the error since we have made these changes.

It also means that we will have to increase the number of thread as we have more bean scheduled with Quartz.

JSON API with Spring 3.1.2 and Jackson 2.2.0

It took me a few hours to get everything working but I am quite happy at how simple it really is.

I read this blog post that had most of the instructions on how to do it: Spring MVC with JSON via Jackson 2.0

Norris mentions that you need to make sure that you have the jackson-databind dependency otherwise you will get a 406 error. I was getting a 406 error even with the jackson databind because I did not have the mvc:annotation-driven specified. I assumed I had it and was surprised that it was not there (lost an hour to something so trivial).

I was also not sure how to submit a JSON post to the API that I was creating to validate that it worked. I found a few example but the one that worked for me was this answer on stackoverflow: Parsing JSON into Java objects in spring-mvc.

The other testing I needed to do was what the JSON message format was to send to Spring. I tried something like:

{ objectName: [ {“field1”: “value”, “field2”: “value”} ] }

But that was giving me 400 errors.

The JSON message format that works is:

{ “field1”: “value1”, “field2”: “value2” }

Note that I am submitting only 1 object at a time to the API.

The last error that I encountered is that I had an internal class for the status (return object on submission) that was private. I got a 500 error when the spring bean was trying to access it so I switched to a protected class and everything is working.

I like the short code that Spring allows me to write to get this to work. Should make it quite easy to maintain.

Spring 3.1 and Rest headaches

To get the rest interfaces I planned to work in my Spring application were a bit of a headache because I did not do many things correctly.

First thing I was not aware was the changes to the web.xml:



These lines were added right after the DispatcherServlet. Without these lines I was getting errors on the DELETE method saying that the POST method was not implemented.

I also had a lot of trouble trying to generate a dynamic URL for the Rest calls. I could not get code similar to this to work:

<form:form action="<%= formUrl%>" method="delete">
	<input type="submit" value="Delete"/>

I tried the construct to generate the URL and it would not accept a string concatenated with a property from an object.

I add to declare a variable to do the concatenation:

String formUrl = "/admin/something/" + something.getId();

At least everything is working right now but that is a few hours lost to figuring out what works and why. Coding fun!

Spring Data JPA and the id field

When you make mistakes you learn more. Since this is true I can tell you that I am learning a lot every day.

Today I learned that your id field type in the entity need to be the same as the generics in the interface that implements the Spring Repository (CrudRepository in my case).

My entity has some code similar to this:

public class Table {

    private Long id;
    // more fields

And the code for the Repository is something similar to this:

public interface TableRepository extends CrudRepository<Table, Long> {

My mistake today was that my id field in the Table class was a int. My Spring application was returning this generic error message:

Could not execute JDBC batch update; SQL [insert into Table (name, id) values (?, ?)]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update

Bonus: I also learned that it will throw the same error if you try to insert twice the same name value.