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.

Bug 230882 - GlassFish schema generation does not work on redeploy
Summary: GlassFish schema generation does not work on redeploy
Status: RESOLVED INVALID
Alias: None
Product: serverplugins
Classification: Unclassified
Component: GlassFish (show other bugs)
Version: 7.4
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: TomasKraus
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-06 21:48 UTC by Reza_Rahman
Modified: 2013-06-07 00:49 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Application demonstrating the issue. (310.05 KB, application/x-zip-compressed)
2013-06-06 21:48 UTC, Reza_Rahman
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Reza_Rahman 2013-06-06 21:48:32 UTC
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.
Comment 1 Geertjan Wielenga 2013-06-06 22:06:25 UTC
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?
Comment 2 Geertjan Wielenga 2013-06-06 22:07:03 UTC
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?
Comment 3 Reza_Rahman 2013-06-06 22:12:22 UTC
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.
Comment 4 Reza_Rahman 2013-06-06 22:42:38 UTC
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).
Comment 5 David Konecny 2013-06-06 22:58:50 UTC
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.
Comment 6 Reza_Rahman 2013-06-07 00:29:38 UTC
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.
Comment 7 Reza_Rahman 2013-06-07 00:49:16 UTC
Closing in favor of a GF bug: https://java.net/jira/browse/GLASSFISH-20616