I have the same problem, but (strange to me) is that the problem only started occuring after changing our data source from local-tx to xa.
Using hibernate entity manager, I have the following
Code:
@Stateful
public class MyStatefulBean implements MyStateful {
@In
private User user;
@EJB
private LoggerBean loggerBean;
public void eventOccurred() {
if (user == null) { return; }
loggerBean.log(new MyEntity(user.getUserId(), "Description"));
}
}
The LoggerBean is stateless and has a log method that persists the entity (as initialized above) with entityManager.persist(theEntity)
The entity MyEntity has an Integer @Id with @GeneratedValue(strategy = GenerationType.IDENTITY) and the database uses an auto increment on the field, and a userId which is not nullable.
The exception is thrown because the userId is null at the time of the persist call.
Any ideas why this occurs when using an xa datasource?