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.
Build: NetBeans IDE Dev (Build 201209040001) VM: Java HotSpot(TM) 64-Bit Server VM, 23.2-b09, Java(TM) SE Runtime Environment, 1.7.0_06-b24 OS: Windows 7 User Comments: jskrivanek: To reproduce: - create web project with GlassFish 3.1.2.2 server - open new file wizard - choose Web Services|RESTful Web Services from Database and click Next - select sample data source - select e.g. Manufacturer table and click Next - provide package name and click Next Stacktrace: java.lang.NullPointerException at org.netbeans.modules.websvc.rest.wizard.EntityResourcesSetupPanel$FinishEntityPanel.read(EntityResourcesSetupPanel.java:139) at org.netbeans.modules.websvc.rest.wizard.AbstractPanel.readSettings(AbstractPanel.java:89) at org.openide.WizardDescriptor.updateStateOpen(WizardDescriptor.java:849) at org.openide.WizardDescriptor.updateState(WizardDescriptor.java:799) at org.openide.loaders.TemplateWizard.updateState(TemplateWizard.java:746) at org.netbeans.modules.project.ui.NewFileWizard.updateState(NewFileWizard.java:124)
Created attachment 123851 [details] stacktrace
Please try to reproduce it with fresh userdir. The mentioned NPE is the consequence of the absence WebRestSupport instance in the project's lookup. It means either problem in the lookup functionality or issue with current and cached binaries interference .
Reproducible even with empty userdir.
I still cannot reproduce with the recent sources and fresh userdir. NPE is a result of method call on result of project.getLookup().lookup(WebRestSupport.class). WebRestSupport subclass is registered in the project's lookup via ProjectServiceProvider annotation.
I tried the latest daily build 201209040947 and it works. Probably some changesets were not propagated from web-main.
*** Bug 218188 has been marked as a duplicate of this bug. ***
Happened again (see bug 218188).
*** Bug 218342 has been marked as a duplicate of this bug. ***
*** Bug 218440 has been marked as a duplicate of this bug. ***
Why ads believes this is bug in Lookup?
*** Bug 218516 has been marked as a duplicate of this bug. ***
(In reply to comment #10) > Why ads believes this is bug in Lookup? You can read the comment : >NPE is a result of method call on result of >project.getLookup().lookup(WebRestSupport.class). >WebRestSupport subclass is registered in the project's lookup via >ProjectServiceProvider annotation.
*** Bug 220354 has been marked as a duplicate of this bug. ***
Lots of duplicates - sounds like a P2. So where does this belong?
Created attachment 126642 [details] stacktrace RESTful service from patterns in Maven web project.
Denis, can you try to reproduce again?
More observations: 1. This happened to me when I created the REST service immediately after creating the Maven project. The workaround is to expand the project node first - after that it does not happen. 2. Looking at the code in the read(...) method, there are some weird things: - on line 179 there is a check for restSupport != null, but this check is not there on line 180 - line 191 says: if (restSupport instanceof WebRestSupport) - does this make sense? Isn't the else branch unreachable?
*** Bug 220940 has been marked as a duplicate of this bug. ***
(In reply to comment #17) > More observations: > 1. This happened to me when I created the REST service immediately after > creating the Maven project. The workaround is to expand the project node first > - after that it does not happen. > > 2. Looking at the code in the read(...) method, there are some weird things: > - on line 179 there is a check for restSupport != null, but this check is not > there on line 180 > - line 191 says: if (restSupport instanceof WebRestSupport) - does this make > sense? Isn't the else branch unreachable? That's the outdated rudimentary code which I've forgot to correct when I've changed the type of restSupport from super type of WebRestSupport. I'm going to correct the code but it is minor issue which doesn't introduce any incorrect behavior.
(In reply to comment #17) > More observations: > 1. This happened to me when I created the REST service immediately after > creating the Maven project. The workaround is to expand the project node first > - after that it does not happen. > Thank you very much Petr for exact steps to reproduce. Finally I'm able to reproduce it too. This is exactly the issue: not-expanded Maven project is not able to find in its lookup WebRestSupport instance. But it is able to find it right after project node is expanded. As I already mentioned WebRestSupport subclass is registered via @ProjectServiceProvider (see org.netbeans.modules.maven.jaxws.MavenProjectRestSupport). So as I said from the very beginning this is a lookup issue. But I'm not sure is it general lookup issue or some JEE Maven project specific. I reassign it to JEE Maven project component. Please evaluate and reassign it if needed.
(In reply to comment #20) > This is exactly the issue: not-expanded Maven project is not able to find > in its lookup WebRestSupport instance. > But it is able to find it right after project node is expanded. > As I already mentioned WebRestSupport subclass is registered via > @ProjectServiceProvider (see > org.netbeans.modules.maven.jaxws.MavenProjectRestSupport). This has nothing to do with maven (it was reproduced for ant based project as well). It is broken since you have pushed the change-set web-main #788245f71835 where you have changed the lookup usage (instead of trying to find RestSupport.class in the project lookup, you are now looking for WebRestSupport.class which isn't registered via @PSP annotation). You can either add WebRestSupport.class to the @PSP registration (for both MavenProjectRestSupport and WebProjectRestSupport) or change the code to use only abstract RestSupport (can't say whether this is possible without deeper knowledge of that code).. > So as I said from the very beginning this is a lookup issue. But I'm not sure > is it general lookup issue or some JEE Maven project specific. > I reassign it to JEE Maven project component. Please evaluate and reassign it > if needed. Evaluated --> Reassigning back.
(In reply to comment #21) > (In reply to comment #20) > > This is exactly the issue: not-expanded Maven project is not able to find > > in its lookup WebRestSupport instance. > > But it is able to find it right after project node is expanded. > > As I already mentioned WebRestSupport subclass is registered via > > @ProjectServiceProvider (see > > org.netbeans.modules.maven.jaxws.MavenProjectRestSupport). > > This has nothing to do with maven (it was reproduced for ant based project as > well). It is broken since you have pushed the change-set web-main #788245f71835 > where you have changed the lookup usage (instead of trying to find > RestSupport.class in the project lookup, you are now looking for > WebRestSupport.class which isn't registered via @PSP annotation). You can > either add WebRestSupport.class to the @PSP registration (for both > MavenProjectRestSupport and WebProjectRestSupport) or change the code to use > only abstract RestSupport (can't say whether this is possible without deeper > knowledge of that code).. Please describe the exact reason why WebRestSupport can be found in the following cases : 1) Ant based project has exactly the same @PSP registration. WebRestSupport is always found in the project's lookup. 2) WebRestSupport is in the project's lookup after project node is expanded. It is not in the project's lookup ONLY if project node is not expanded. From your explanation I see that WebRestSupport mustn't be in the project lookup at all.
Denis may I ask you why are you still reassigning the issue to me? Your changeset (web-main 788245f71835) was propagated on the 2012-09-01.. this issue is here since the 2012-09-04 ..nothing has been changed in j2ee maven area for weeks. It is quite obvious that you have made this regression. I'll glad to help you with evaluation and explanation of the problem, but this super-fast reassigning just to get rid of the issue is a little annoying..
(In reply to comment #22) > Please describe the exact reason why WebRestSupport can be found in the > following cases : > 1) Ant based project has exactly the same @PSP registration. > WebRestSupport is always found in the project's lookup. That's not true, it was reproduce by jirka in web project as well. > 2) WebRestSupport is in the project's lookup after project node is expanded. > It is not in the project's lookup ONLY if project node is not expanded. Don't know.. I wouldn't expect this either. As much as I know, @PSP doesn't work with respect to inheritance tree. If you register some interface in @PSP, you shouldn't be able to lookup the concrete implementor. So I wouldn't expect this work even after project node is expanded, but I don't have deep knowledge of how the @PSP is processed (that's a question for someone else) > From your explanation I see that WebRestSupport mustn't be in the project > lookup at all. Well it would be ideal. It's a good practice to use an interface instead of concrete class. Of course, I know it's not possible in every situation that's why it's legal to register both (interface and implementor), but you need to be aware of the issue 205151 (if a LookupMerger is registered for that class type, it might caused some problems)
There is definitely some inconsistency in the lookup but I'm tired to argue against it. I will rewrite the code on rest side.
web-main#8e45a1be9baf
Integrated into 'main-golden', will be available in build *201210300001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-golden/rev/8e45a1be9baf User: Denis Anisimov <ads@netbeans.org> Log: Fix for BZ#217775 - NullPointerException at org.netbeans.modules.websvc.rest.wizard.EntityResourcesSetupPanel$FinishEntityPanel.read
The correct fix is: @ProjectServiceProvider(service={ WebRestSupport.class, RestSupport.class }, projectType="org-netbeans-modules-maven/war") you need to enumerate all the interface you want an implementation to be initially found for. Otherwise it may or may not be found depending on whether somebody else asked for RestSupport.class sooner or not.
(In reply to comment #28) > The correct fix is: > > @ProjectServiceProvider(service={ WebRestSupport.class, RestSupport.class }, > projectType="org-netbeans-modules-maven/war") > > you need to enumerate all the interface you want an implementation to be > initially found for. Otherwise it may or may not be found depending on whether > somebody else asked for RestSupport.class sooner or not. Finally this is the explanation the observed behavior.
web-main#7005950a8426
Integrated into 'main-golden', will be available in build *201211020001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-golden/rev/7005950a8426 User: Denis Anisimov <ads@netbeans.org> Log: Fix for BZ#217775 - NullPointerException at org.netbeans.modules.websvc.rest.wizard.EntityResourcesSetupPanel$FinishEntityPanel.read