JPA invalid stream header: 32303138

I’m new with JPA / Hibernate with Spring Boot and I’ve been facing the same error for over 6hours now, this is driving me crazy.

Basically, it all start at my Controller here

public class RestPatientController {

    public static final Logger LOGGER = LoggerFactory.getLogger(RestPatientController.class);

    private PatientService patientService;


    @RequestMapping(value = "/patient/prises_en_charge/{id}", method = RequestMethod.GET)
    public ResponseEntity<List<PriseEnCharge>> listAllPrisesEnChargeByPatient(@PathVariable("id") long id) {

        Patient currentPatient = patientService.findById(id);"Récupération de toutes les prises en charges d'un patient avec id {}", currentPatient);
        List<PriseEnCharge> prisesEnCharge = patientService.findAllPrisesEnChargeByPatient(currentPatient);"Liste de prises en charge {} ({} elements)", prisesEnCharge, prisesEnCharge.size());
        if (prisesEnCharge.isEmpty()) {
            LOGGER.debug("La liste des prises en charge est vide");
            return new ResponseEntity(HttpStatus.NO_CONTENT);
            // You many decide to return HttpStatus.NOT_FOUND

        return new ResponseEntity<List<PriseEnCharge>>(prisesEnCharge, HttpStatus.OK);


where I catch the ID of the element I want more data for. I then call the DAO within my service

public class PatientServiceImpl implements PatientService {

    private PriseEnChargeDao priseEnChargeDao;


    public List<PriseEnCharge> findAllPrisesEnChargeByPatient(Patient patient) {
        return priseEnChargeDao.findPriseEnChargeByPatient(patient);


DAO being

public interface PriseEnChargeDao extends JpaRepository<PriseEnCharge, Long> {

    @Query("from PriseEnCharge where id_patient = :patient")
    public List<PriseEnCharge> findPriseEnChargeByPatient(@Param("patient") Patient patient);


No matter what I tried It keeps throwing exception “ invalid stream header: 32303138”. I honnestly don’t know anymore, I’m kinda despaired on that case.


I am going to make a guess here. If you interpret 32303138 as a 32 bit word in hexadecimal and “decode” it as ASCII characters, you get “2018”. That looks to me like the first 4 characters of a date string of some kind.

My guess is that something is attempting to deserialize a character string as if it was an object stream. That implies that there is a mismatch between the database schema and the hibernate mappings.

Leave a Reply

Your email address will not be published. Required fields are marked *