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 214441 - Cannot deploy REST web service from database
Summary: Cannot deploy REST web service from database
Status: VERIFIED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Persistence (show other bugs)
Version: 7.2
Hardware: All All
: P1 normal (vote)
Assignee: Tomas Zezula
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-19 11:43 UTC by Jiri Skrivanek
Modified: 2012-06-25 11:50 UTC (History)
7 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Server log. (14.56 KB, text/plain)
2012-06-19 11:43 UTC, Jiri Skrivanek
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jiri Skrivanek 2012-06-19 11:43:57 UTC
Created attachment 121046 [details]
Server log.

It is not possible to deploy REST web service from database. To reproduce:

- create java EE6 web project with GlassFish server
- open new file wizard
- select "Web Services|RESTful Web Services from Database" and click Next
- choose jdbc/sample data source and add all tables
- click Next
- provide package name and finish the wizard
- call Deploy on project node but it fails (see server log)

Product Version: NetBeans IDE 7.2 RC1 (Build 201206182200)
Java: 1.7.0_06-ea; Java HotSpot(TM) 64-Bit Server VM 23.2-b05
System: Mac OS X version 10.7.4 running on x86_64; US-ASCII; en_US (nb)
Comment 1 Jiri Skrivanek 2012-06-19 11:52:40 UTC
Maybe some problem in persistence. Reproducible also when you create just entity class and persistence unit.
Comment 2 Sergey Petrov 2012-06-19 12:35:25 UTC
yes, looks like persistence issue, and/or compile&save issue,
as after build I see empty persistence.xml file in 'build' location, and it cause deployment failure
Comment 3 Sergey Petrov 2012-06-19 12:53:15 UTC
currently it seems more like scanning/compile&save issue to me, as even local history do not contain completely empty persistemce.xml, it seems to start scanning right after file creation (it's created with FileUtil.copyFile() with initial content). It's first part of issue, and second one file isn't updated when content  is changed later, this part may have issues on persistence side if it use some api to update in unsupported way.
Comment 4 Marian Mirilovic 2012-06-19 13:16:21 UTC
Stopper for 7.2
Comment 5 Petr Jiricka 2012-06-19 13:27:11 UTC
Is this a recent regression, or was this broken a long time ago?
Comment 6 Sergey Petrov 2012-06-19 13:33:00 UTC
simple steps:
-create web project on glassfish 3.x server with all defaults
-invoke 'New|Entities from database'
-select jdbc/sample
-select DISCOUNT_CODE and press Next
- specify a package and Finish
- invoke deploy
deployment fails
you'll see empty persistence.xml in build/web/WEB-INF/classes/META-INF/.

contrary if invoke 'Build' persistence.xml will not be empty.
Comment 7 David Konecny 2012-06-20 03:08:30 UTC
I had a look at this issue and found few strange things happening. Honza/Tomas might explain them easily.

Finishing 'New|Entities from database' wizard creates besides other things also src/conf/persistence.xml file. This file is not under Java Source root yet if you search under <your-userdir>/var/cache/index you will find there something like

  ./s42/java/14/classes/META-INF/persistence.xml

(Do this on empty userdir otherwise there might be too many entries.) And the file has length of 0. I wonder why is this file there in first place? It is not Java. Other thing is why is it empty?

During build process the persistence.xml file gets copied into build directory but compilation target which runs afterwards rewrites the file with empty one from var/cache/index.

At this point there are two ways to get rid of the deployment problem:

#1) restart IDE and try to deploy your project again and you will notice that file in var/cache/index folder gets updated with proper non-empty content of persistence.xml and project deployment will work.

#2) edit in IDE src/conf/persistence.xml and save. That again will make deployment to start working yet corresponding file under var/cache/index stays empty. What I do not understand in this case is that var/cache/index has empty persistence.xml yet it does not copy it to build dir now for some reason???
Comment 8 Sergey Petrov 2012-06-20 06:06:52 UTC
Tomas is looking into the issue, may be will add comments later
Comment 9 Sergey Petrov 2012-06-20 06:16:33 UTC
>why is this file there in first place? 
it's here for annotation processor to work properly
Comment 10 Tomas Zezula 2012-06-20 06:58:58 UTC
There are 2 problems involved:

The first one is that CopyResourcesIndex copies resources (persistence.xml) to java index without using APIs. The java infrastructure does not know anything about these files. Fixing this is non trivial task. It will require either removing need of CRI, which is a workaround anyway, but it's a bigger change into Web|J2EE project. Or it will require complete rewrite of CRI. It may be needed later on if we decide to store classes in CND DoubleFileStorage but it's still questionable and probably will not happen in near future.

The second one is introduced by a fix of issue #213608. Easier to fix.

Fix of any of the above problems will resolve this issue.
As the second one is a smaller change I am voting for it.
Comment 11 Tomas Zezula 2012-06-20 07:17:29 UTC
Fixed jet-main 00279c0bcfc1
Comment 12 Svata Dedic 2012-06-20 13:05:47 UTC
Patch reviewed, OK.
Comment 13 Jiri Skrivanek 2012-06-20 14:02:23 UTC
Patch verified in custom build. It works well.
Comment 14 Tomas Zezula 2012-06-20 14:05:00 UTC
Thanks Jirko!
Comment 15 Tomas Zezula 2012-06-21 12:12:58 UTC
Transplanted into 7.2
releases fa954f7a33c4
Comment 16 Quality Engineering 2012-06-22 04:21:05 UTC
Integrated into 'releases', will be available in build *201206212341* or newer. Wait for official and publicly available build.
Changeset: http://hg.netbeans.org/releases/rev/fa954f7a33c4
User: Tomas Zezula <tzezula@netbeans.org>
Log: #214441:Cannot deploy REST web service from database
Comment 17 Quality Engineering 2012-06-22 04:50:37 UTC
Integrated into 'main-golden', will be available in build *201206220002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/00279c0bcfc1
User: Tomas Zezula <tzezula@netbeans.org>
Log: #214441:Cannot deploy REST web service from database
Comment 18 Jiri Skrivanek 2012-06-25 11:50:38 UTC
Verified.

Product Version: NetBeans IDE 7.2 RC1 (Build 201206242201)
Java: 1.7.0_06-ea; Java HotSpot(TM) 64-Bit Server VM 23.2-b05
System: Windows 7 version 6.1 running on amd64; Cp1250; en_US (nb)