Skip to content
Advertisement

No serializer found for class org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor

When i try to navigate to an endpoint i get the following error

JavaScript

I checked all my models and all the attributes have getters and setters. So what’s the problem ?

I can fix that by adding spring.jackson.serialization.fail-on-empty-beans=false but i think this is just a work around to hide the exception.

Edit

Product model:

JavaScript

PagedResponse class :

JavaScript

RestResponse Class :

JavaScript

In my controller i’m returning ResponseEntity<RestResponse<PagedResponse<Product>>>

Advertisement

Answer

I came across this error while doing a tutorial with spring repository. It turned out that the error was made at the stage of building the service class for my entity.

In your serviceImpl class, you probably have something like:

JavaScript

Change this to:

JavaScript

Basically getOne is a lazy load operation. Thus you get only a reference (a proxy) to the entity. That means no DB access is actually made. Only when you call it’s properties then it will query the DB. findByID does the call ‘eagerly’/immediately when you call it, thus you have the actual entity fully populated.

Take a look at this: Link to the difference between getOne & findByID

Advertisement