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 199956 - Deploying and running an application that uses table generation and a SEQUENCE table for PK generation gives phantom deployment failures
Summary: Deploying and running an application that uses table generation and a SEQUENC...
Status: VERIFIED FIXED
Alias: None
Product: serverplugins
Classification: Unclassified
Component: GlassFish (show other bugs)
Version: 7.0
Hardware: All All
: P1 normal (vote)
Assignee: Vince Kraemer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-07 19:38 UTC by ievans
Modified: 2011-07-16 16:48 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
server.log file from GlassFish 3.1.1 b10 (89.32 KB, text/plain)
2011-07-07 19:39 UTC, ievans
Details
Project that shows bug (24.51 KB, application/x-java-archive)
2011-07-07 20:14 UTC, ievans
Details
diff that applies to release701 branch (949 bytes, text/plain)
2011-07-12 17:55 UTC, Vince Kraemer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ievans 2011-07-07 19:38:12 UTC
Product Version = NetBeans IDE 7.0 (Build 201104080000)
Operating System = Windows XP version 5.1 running on x86
Java; VM; Vendor = 1.6.0_24
Runtime = Java HotSpot(TM) Client VM 19.1-b02
GlassFish version : 3.1.1 b10

For a Java EE app that uses EclipseLink's drop-and-create table generation in persistence.xml:
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
And uses the default automatic primary key generation strategy of a SEQUENCE table, NetBeans will incorrectly give a deployment failure if the SEQUENCE table already exists (which triggers a warning from EclipseLink):
In-place deployment at C:\working\javaeetutorial\examples\jaxrs\rsvp\build\web
Initializing...
deploy?DEFAULT=C:\working\javaeetutorial\examples\jaxrs\rsvp\build\web&name=rsvp&force=true failed on Java EE 6 SDK u3 
 
PER01003: Deployment encountered SQL Exceptions:
	PER01000: Got SQLException executing statement "CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT DECIMAL(15), PRIMARY KEY (SEQ_NAME))": java.sql.SQLException: Table/View 'SEQUENCE' already exists in Schema 'APP'.
C:\working\javaeetutorial\examples\jaxrs\rsvp\nbproject\build-impl.xml:721: 
The module has not been deployed.
	at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:187)
	at org.netbeans.modules.j2ee.ant.Deploy.execute(Deploy.java:106)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
	at sun.reflect.GeneratedMethodAccessor293.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
	at org.apache.tools.ant.Task.perform(Task.java:348)
	at org.apache.tools.ant.Target.execute(Target.java:390)
	at org.apache.tools.ant.Target.performTasks(Target.java:411)
	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
	at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
	at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
	at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:284)
	at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:539)
	at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:154)
BUILD FAILED (total time: 8 seconds)

In my domain's server.log file, you can see the warning, but the application is successfully deployed:
INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
INFO: EclipseLink, version: Eclipse Persistence Services - 2.3.0.v20110604-r9504
INFO: file:/C:/working/javaeetutorial/examples/jaxrs/rsvp/build/web/WEB-INF/classes/_rsvpPU login successful
WARNING: Multiple [2] JMX MBeanServer instances exist, we will use the server at index [0] : [com.sun.enterprise.v3.admin.DynamicInterceptor@b1cb25].
WARNING: JMX MBeanServer in use: [com.sun.enterprise.v3.admin.DynamicInterceptor@b1cb25] from index [0] 
WARNING: JMX MBeanServer in use: [com.sun.jmx.mbeanserver.JmxMBeanServer@5629d] from index [1] 
WARNING: PER01000: Got SQLException executing statement "CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT DECIMAL(15), PRIMARY KEY (SEQ_NAME))": java.sql.SQLException: Table/View 'SEQUENCE' already exists in Schema 'APP'.
INFO: Portable JNDI names for EJB StatusBean : [java:global/rsvp/StatusBean, java:global/rsvp/StatusBean!rsvp.ejb.StatusBean]
INFO: Portable JNDI names for EJB ConfigBean : [java:global/rsvp/ConfigBean, java:global/rsvp/ConfigBean!rsvp.ejb.ConfigBean]
INFO: Portable JNDI names for EJB ResponseBean : [java:global/rsvp/ResponseBean!rsvp.ejb.ResponseBean, java:global/rsvp/ResponseBean]
INFO: WELD-000900 ${parsedVersion (osgiVersion})
INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
INFO: Initializing Mojarra 2.1.3 (FCS b01) for context '/rsvp'
INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
INFO: WEB0671: Loading application [rsvp] at [/rsvp]

EclipseLink only warns you if SEQUENCE exists already, as this is not a fatal error. If SEQUENCE already exists, the application will simply use the next number in the table for new entity primary keys. And because multiple application may use the same SEQUENCE table, SEQUENCE is not removed on undeployment. NetBeans is apparently catching the SQLException in this case and incorrectly reporting that the deployment failed.
Comment 1 ievans 2011-07-07 19:39:38 UTC
Created attachment 109301 [details]
server.log file from GlassFish 3.1.1 b10
Comment 2 Vince Kraemer 2011-07-07 19:57:05 UTC
Got a sample project that you could attach?
Comment 3 ievans 2011-07-07 20:14:17 UTC
Created attachment 109302 [details]
Project that shows bug
Comment 4 ievans 2011-07-07 20:14:55 UTC
Steps to reproduce using attached project:
1. Open rsvp project in NetBeans 7.x configured with GlassFish 3.1.1.
2. Run rsvp project.
3. Clean project (this undeploys rsvp but keeps the SEQUENCE table).
4. Run rsvp project again. This will trigger the deployment error, but if you look in GlassFish 3.1.1's Applications list you'll see rsvp deployed.
Comment 5 Vince Kraemer 2011-07-07 21:42:30 UTC
I can replicate.  it is a plugin or server issue... not related to the javaee/persistence support of the ide...
Comment 6 Vince Kraemer 2011-07-07 22:13:43 UTC
it looks like there was a change in the way the deploy 'commands' return value is computed in 3.1 vs 3.1.1...

in the 3.1 FCS, the return from the second deploy was "SUCCESS" and in 3.1.1 it is "WARNING".

The fix is pretty trivial for 7.1.
Comment 7 Vince Kraemer 2011-07-08 16:35:38 UTC
forgot to mark as started
Comment 8 Vince Kraemer 2011-07-11 18:32:23 UTC
this is more significant than p3...
Comment 9 Petr Jiricka 2011-07-12 09:43:52 UTC
Looks serious, should be fixed for 7.0.1. Already fixed in trunk: http://hg.netbeans.org/web-main/rev/4977b072464c
Comment 10 Petr Hejl 2011-07-12 10:02:03 UTC
I'm not really sure how well the equalsIgnoreCase() deals with equality in diferrent Locales. Perhaps this would be more safe:

if (outputCode == null || !"FAILURE".equals(outputCode.toUpperCase(Locale.ENGLISH))) { // NOI18N

Otherwise fix looks good.
Comment 11 Tomas Danek 2011-07-12 13:50:59 UTC
i'd like to understand this a little bit: 
- deployment failed because of sql exception caused by existing table, which was by server notified as WARNING (previously by SUCCESS)?
- do i understand correctly that this will happend every time user runs some app in Glassfish, then cleans project, and tries to deploy again?  Is this specific only to this project type and library combination? (I'm trying to figure out how many users would be impact by this)
Comment 12 Quality Engineering 2011-07-12 14:19:14 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/4977b072464c
User: Vince Kraemer <vkraemer@netbeans.org>
Log: #199956 : server started sending WARNING messages... surprise.
Comment 13 Vince Kraemer 2011-07-12 14:44:38 UTC
(In reply to comment #11)
> i'd like to understand this a little bit: 
> - deployment failed because of sql exception caused by existing table, which
> was by server notified as WARNING (previously by SUCCESS)?

The deployment was successful on the server, but the IDE claims that it failed, since the IDE did not get "SUCCESS" as the exit code.

> - do i understand correctly that this will happend every time user runs some
> app in Glassfish, then cleans project, and tries to deploy again? 

This will happen when the user does multiple deployments of an app that uses generated PKs and the like... not every app ever, but a fairly sizable subset.

> Is this
> specific only to this project type and library combination? (I'm trying to
> figure out how many users would be impact by this)

This would affect any Java EE project type that deploys onto GlassFish 3.1.1 that uses generated IDs
Comment 14 Vince Kraemer 2011-07-12 17:17:57 UTC
(In reply to comment #10)
> I'm not really sure how well the equalsIgnoreCase() deals with equality in
> diferrent Locales. Perhaps this would be more safe:
> 
> if (outputCode == null ||
> !"FAILURE".equals(outputCode.toUpperCase(Locale.ENGLISH))) { // NOI18N
> 
> Otherwise fix looks good.

great catch. integrated http://hg.netbeans.org/web-main/rev/e4ca1213b3ca
Comment 15 Vince Kraemer 2011-07-12 17:55:55 UTC
Created attachment 109402 [details]
diff that applies to release701 branch

here is what would be applied to release701 branch in the releases repo...
Comment 16 Quality Engineering 2011-07-13 13:59:10 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/e4ca1213b3ca
User: Vince Kraemer <vkraemer@netbeans.org>
Log: #199956 : server started sending WARNING messages... surprise.  Now l10n safe for folks running in a Turkish locale.
Comment 17 Vladimir Riha 2011-07-13 15:53:22 UTC
I can verify this, I have tried to reproduce it the way described in comment #4 and it works fine.

Product Version: NetBeans IDE Dev (Build 201107130600)
Java: 1.7.0; Java HotSpot(TM) Client VM 21.0-b17
System: Windows XP version 5.1 running on x86; Cp1252; en_US (nb)
Comment 18 Tomas Danek 2011-07-13 16:56:44 UTC
thanks Lado! 
Please go on with integration to releases 701 branch.
Comment 19 Vince Kraemer 2011-07-13 18:18:38 UTC
http://hg.netbeans.org/releases/rev/04b8324fff00 fix into release701 branch
Comment 20 Quality Engineering 2011-07-16 16:48:00 UTC
Integrated into 'releases'
Changeset: http://hg.netbeans.org/releases/rev/04b8324fff00
User: Vince Kraemer <vkraemer@netbeans.org>
Log: #199956 : server warning triggers false deployment failed result in IDE