Could not write JSON: (was java.lang.NullPointerException)

It was a dirty exception I faced few weeks back. I was trying to to consume a REST API call using postForEntity.

Unfortunately my ID variable was in primitive long instead of Long. I hit with the following error. I had been roaming around without a clue.

org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: (was java.lang.NullPointerException)

Ref: https://stackoverflow.com/questions/24805043/org-springframework-http-converter-httpmessagenotwritableexception-could-not-wr

I shot this soft white sand beach at Coney Island recently

I shot this soft white sand beach at Coney Island recently

Advertisements

Failed to read auto-increment value from storage engine

One after another – This was a strange exception I received today. I am not sure if this is a bug of JPA or underlying MySQL.


SQL Error: 1467, SQLState: HY000

Failed to read auto-increment value from storage engine

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.orm.jpa.JpaSystemException: could not execute statement; nested exception is org.hibernate.exception.GenericJDBCException: could not execute statement] with root cause

java.sql.SQLException: Failed to read auto-increment value from storage engine

I was pretty much surprised, what else!

Server version: 10.1.36-MariaDB

Spring Boot :: (v2.1.7.RELEASE)

I tried this.


ALTER TABLE `feed_item_info` AUTO_INCREMENT =1

It does not help me.

Later –

ALTER TABLE `feed_item_info` ORDER BY `index`

It throws the following warning.

Warning: #1105 ORDER BY ignored as there is a user-defined clustered index in the table ‘feed_item_info’

But it was working.

Ref:https://stackoverflow.com/questions/17690926/failed-to-read-auto-increment-value-from-storage-engine-error-number-1467

I shot this recently, at the seashore which borders Singapore and Malaysia

I shot this recently, at the seashore which borders Singapore and Malaysia

detached entity passed to persist

I am in mid of a crud operation. This exception hit me today, when I updated an entity with @ManyToOne(cascade = CascadeType.ALL) relationship.

org.hibernate.PersistentObjectException: detached entity passed to persist: org.grassfield.feed.entity.Feed

To solve this bidirectional consistency problem, I need to change CascadeType.ALL to CasecaseType.MERGE.

Recently I shot this pretty lady (or mighty gentleman?) at Coney Island. This has no relation with this post anyway.

Recently I shot this pretty lady (or mighty gentleman?) at Coney Island. This has no relation with this post anyway.