I had this problem too and this wass the reason:

I create the newtonworld in my main function, but I think it is not guaranteed that entity actions run AFTER the main function. so there are crashes because the newtonworld is not created yet.

wait (1) should do in this case.