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 209607 - sys/monitoring RESTful webservice being created
Summary: sys/monitoring RESTful webservice being created
Status: RESOLVED WONTFIX
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 7.1.1
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Tomas Zezula
URL:
Keywords:
: 210297 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-03-15 06:30 UTC by chase
Modified: 2015-09-17 11:16 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description chase 2012-03-15 06:30:13 UTC
After installing NetBeans 7.1.1 EE I add an Oracle 12c (zip distro) server.

The very first project I create is a Web Application. All defaults are used to create the project including the project name. After the project is created I see in the project:
*Web Pages
*Source Packages
*Libraries
*Configuration Files

Every additional web project I create has:
*Web Pages
*Source Packages
*Libraries
*RESTful Web Services
*Configuration Files

Notice the "RESTful Web Services". I have no idea why this is showing up in the project. Under "RESTful Web Services" I see "ApplicationResource [sys/monitoring]"

Doing diffs on the projects I can't find a single differences that would account for the non-functional web service showing up.

If I delete my .netbeans\7.1.1 directory the first project will again be missing the "RESTful Web Services" node but every additional project will have it.

I'm not importing anything from previous versions of NetBeans.
Comment 1 Denis Anisimov 2012-03-26 10:22:01 UTC
This is not a bug.
Your project classpath has some jars from WL installation.
There is a RESTful WS somewhere in these jar files ( java file annotated with JAX-RS WS annotation ) . NB detected this RESTful ws and shows REST node with 
found WS.
There is no difference in your projects. The difference is classpath ( WL related jars ).
Comment 2 chase 2012-03-27 03:45:48 UTC
When I say I did a diff on the projects I'm including the project.properties files and everything else.

I have two projects created seconds apart using exactly the same settings and server. The only difference is that one project is the first project created after installing netbeans (or deleting my .netbeans\7.1.1 dir)

If the first project is missing something something that *should* be there then please investigate that.

If the classpath is different on the first project created even though by all indicators they have the same classpath then investigate that.
Comment 3 Denis Anisimov 2012-03-27 06:04:26 UTC
So you don't care about RESTful service presence but you care about 
differences in the project's node with the same settings used.
Is it correct ?
Comment 4 Denis Anisimov 2012-03-27 06:40:04 UTC
I'm able to reproduce the issue exactly as described: the very first created Web
project with WL target server doesn't have RESTful node.
Any following project has this node.
Both 7.1.2 dev and 7.2 dev has this issue.
Comment 5 Denis Anisimov 2012-03-27 08:07:32 UTC
The root cause of the behavior is :
ClassIndex.getElements() returns empty set for the very first project with 
referenced handle @javax.ws.rs.Path  ( first method argument ) and EnumSet.of(SearchKind.TYPE_REFERENCES),
                EnumSet.of(SearchScope.SOURCE, SearchScope.DEPENDENCIES) as second and third argument.

Here are details how it works :
org.netbeans.modules.websvc.rest.nodes.RestServicesNodeFactory.RestNodeList schedule a task "restModelTask" to find model created around REST annotations.
That's the RestServices model interface with org.netbeans.modules.websvc.rest.model.impl.RestServicesImpl as an implementation.
The latter model is created via J2EE metamodel framework and uses RestServiceProvider as ObjectProvider<RestServiceDescriptionImpl>.
There is a method "createInitialObjects" that is called on getObjects() method 
( delegated by sizeRestServiceDescription() ).
The methods are called when model is created ( runReadActionWhenReady method is used ).
"createInitialObjects" method calls number of "findAnnotation" method with different arguments. The very first call has mentioned @javax.ws.rs.Path as first argument and Class as required type.

Please note : all mentioned methods are called in any case.
"findAnnotation" tries to search class via annotation scanner class :
org.netbeans.modules.j2ee.metadata.model.api.support.annotation.AnnotationScanner.
Method "findAnnotations" is used .
This method calls 
final Set<ElementHandle<TypeElement>> elementHandles = getHelper().
            getCompilationInfo().getClasspathInfo().getClassIndex().getElements(
                searchedTypeHandle,
                EnumSet.of(SearchKind.TYPE_REFERENCES),
                EnumSet.of(SearchScope.SOURCE, SearchScope.DEPENDENCIES));
and its result is empty set. 

Some additional notes:
- Exactly the same calls lead to non-empty set for any subsequent project creation.
- The issue exists in both 7.1.2 dev and 7.2 dev so it doesn't relate to background scan changes.
- This is very specific corner case : I'm able to reproduce it only when NB is started with fresh userdir and only on the very first Web project creates.
As I already said : all subsequent projects doesn't have the problem.
Comment 6 Denis Anisimov 2012-03-27 08:10:37 UTC
One more important notion: the ApplicationResource class which should be found
as result of the search is binary class somewhere in the project's compile
classpath.
Comment 7 Denis Anisimov 2012-03-29 08:02:17 UTC
See also issue #210297.
Comment 8 Denis Anisimov 2012-03-29 11:27:23 UTC
*** Bug 210297 has been marked as a duplicate of this bug. ***
Comment 9 Martin Balin 2015-09-17 11:16:02 UTC
Report from old NetBeans version. Due to code changes since it was reported likely not reproducible now. Feel free to reopen if happens in 8.0.2 or 8.1.