FortiSIEM
FortiSIEM provides Security Information and Event Management (SIEM) and User and Entity Behavior Analytics (UEBA)
aebadi
Staff
Staff
Article Id 390381
Description

This article explains that the error occurs when the Java Persistence API (JPA), implemented by Hibernate, attempts to retrieve a User entity using a specified primary key (e.g., 180843976), but no matching record is found in the database.

 

Note:
The primary key value referenced in the error may differ depending on the specific instance and context within each cluster.

Scope FortiSIEM.
Solution

This often happens when:

  • The referenced user has been deleted.

  • The data is corrupt or out of sync.

  • The code assumes the user ID always exists without checking for null or absence.

 

Initial investigation:

  1. Search for the error in phoenix.log:

 

cat /opt/phoenix/log/phoenix.log | grep -i 180843976

2025-05-02T01:00:03.001009-07:00 [http-listener-2(23)] ERROR com.ph.phoenix.ws.rest.h5.H5RestResource - [PH_APPSERVER_REST_H5_ERROR]:[phCustId]=1,[eventSeverity]=PHL_ERROR,[phEventCategory]=3,[procName]=AppServer,[className]=org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$JpaEntityNotFoundDelegate,[methodName]=handleEntityNotFound,[lineNumber]=163,[errReason]=Unable to find com.ph.phoenix.model.cmdb.User with id 180843976,[phLogDetail]=HTML5 REST error

 

This confirms the REST API attempted to retrieve a non-existent user with ID 180843976:

 

  1. Review the Java stack in server.log /opt/glassfish/domain/domain1/logs. The server log will include a full stack trace that ends in:

 

javax.persistence.EntityNotFoundException: Unable to find com.ph.phoenix.model.cmdb.User with id 180843976

 

This shows that the exception originated in a backend service through the EJB container and REST endpoint.

 

Root Cause:

The error occurs when Hibernate attempts to eagerly load a reference to a user ID that doesn’t exist in the database, typically through a @ManyToOne or @OneToOne mapping (e.g., manager_id pointing to a user that has been removed). 

 

Recommended Fix:

  1. Check if the user exists in the DB:

 

 psql phoenixdb phoenix -c 'select * from ph_user;' | grep -E " id |180843976"

 

ph_user tableph_user table

 

This confirms whether the user exists and where the ID might be referenced (e.g., in the manager_id field).

 

  1. Clear references to the missing user: In Step 1 of the recommended fix,  the missing user ID is associated with the manager_id field. To resolve this, set manager_id to NULL for any records referencing the deleted user. This will prevent EntityNotFoundException errors when loading entities that reference the missing user.

 

psql phoenixdb phoenix -c "update ph_user set manager_id=NULL where manager_id=180843976;"
UPDATE 1

 

Summary:

This issue stems from a missing database record being accessed as though it exists. The fix involves:

  • Identifying the reference.

  • Cleaning up invalid foreign keys.

  • Ensuring future code accounts for possible missing entities.

Contributors