This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Created attachment 135468 [details] Application demonstrating the issue. This is a bit of a convoluted issue, so I'll try to be as meticulous as I can. In Java EE 7, a feature was added to drop and re-create a database schema on deploy. This feature works fine if I deploy/run the application the first time or do a manual undeploy and run. If I simply run the application once, shut down the server (without doing an undeploy) and then re-run, the feature no longer works (it does not matter if I do a code change or not). The GlassFish folks think this is because an actual deploy isn't happening the second time I do a run without doing a manual undeploy first. I am not sure this is correct since NetBeans seems to indicate that it is doing a deploy each time an application is run. The application is attached so you guys can try it out. Please advise and thanks in advance.
Now you need to specify what to do with the attachment in order to reproduce your problem. In steps -- i.e., step 1, open the project in the IDE. What are the next steps?
And what does "a feature was added to drop and re-create a database schema on deploy" mean? Where do we see that in the attachment?
Here is how you can reproduce the issue: * Open the (attached) project up in NetBeans (it is a Maven project). * Clean and build * Run (this will succeed) * Stop GlassFish (don't undeploy) * Run again (make a code change if you want) - the deployment will fail. To make things work, just do a manual undeploy before re-running. The schema generation feature in question is described here: https://blogs.oracle.com/arungupta/entry/jpa_2_1_schema_generation.
I am really not sure this is a NetBeans issue at all. I just tried a redeploy via the admin GUI and that fails too (no NetBeans involved at all).
NetBeans, or to be more correct, the NetBeans GlassFish plugin, is doing an incremental redeployment on consequent Run(s) - only changed files are redeployed. I'd think that if a changed (and redeployed) file has no impact on the DB schema then GlassFish should not re-create database schema. And vice versa. The point of incremental redeployment is to be quick and to not restart whole application. Reza, could you elaborate please why would you want the schema to be recreated upon any application change you do? Passing to NetBeans GF team to evaluate. Short term workaround is to use Clean & Build following by Run - Clean should perform undeploy first.
OK, I should explain the use case - it's not per se the schema I'm interested in wiping on run, but the data... On application start, I generate some sample data for demo purposes. Once I shut down or make a change, I generally don't want any data changes I made to hang around. That's why I really want the schema dropped and recreated whenever I hit run. This isn't too unusual of a requirement IMO. It's basically the reason most people use the drop-and-create schema generation feature. The Clean & Build every time method didn't work, principally probably because I don't think the issue I have right now is a NetBeans issue at all. Anyways, Shreedhar asked me to close this and file a GF bug. Thanks anyways though.
Closing in favor of a GF bug: https://java.net/jira/browse/GLASSFISH-20616