I was having the same problem but with the little difference that mine was caused by attempting to downgrade glassfish from version 5.0.1 to 5.0. I had deployed my application using 5.0.1 but some issues with the jdbc drive occurred so I need to downgrade to Glassfish 5.0 and then this appears "The project does not have the target server properly... ", I checked the run properties and everything was all right.
In order to solve: first go to "project properties" and then to "Run" in the server option select apply changes, restart netbeans, open again and change the server again to glassfish