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 129197 - project.getLookup().lookupAll method fails to lookup all registered instances of Lookup
Summary: project.getLookup().lookupAll method fails to lookup all registered instances...
Status: RESOLVED WORKSFORME
Alias: None
Product: platform
Classification: Unclassified
Component: Lookup (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Jaroslav Tulach
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-04 23:15 UTC by Prashant Ponnala
Modified: 2008-12-22 12:11 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
nbms needed for install (78.39 KB, application/x-compressed)
2008-03-06 00:33 UTC, Prashant Ponnala
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Prashant Ponnala 2008-03-04 23:15:48 UTC
project.getLookup().lookupAll method fails to lookup all registered instances of Lookup.

I am running into ClassLoading issues with the call project.getLookup().lookupAll() method.
There are 2 netbeans modules, one registers a Lookup and the other finds all registered lookup objects.

I created a lookup using createAdditionalLookup as below:

   public Lookup createAdditionalLookup(Lookup baseContext) {
       mLogger.info("CreateAdditionalLookup called in OracleOTDLookupProvider");
       Project project = baseContext.lookup(Project.class);
       OracleOTDLinks otdLinks = new OracleOTDLinks(project);
       return Lookups.fixed(new Object[] {otdLinks});
   }

When I try to get a list of Lookup classes registered, the list does not contain OracleOTDLinks.
However, the behavior is random, if I restart netbeans several times, sometimes the list appears correctly.

This is how I lookup the registered objects.

       public OTDTableModel(Project project) {
           otdLinksCollection = project.getLookup().lookupAll(OTDLinks.class);
       }

The module which registers Lookup has the following entry in its layer.xml

    <folder name="Projects">
        <folder name="org-netbeans-modules-j2ee-ejbjarproject">
            <folder name="Lookup">
                <file name="com.sun.soabi.otdimport.model.OTDLinkLookupProvider.instance"/>
            </folder>
     </folder>

This used to work in earlier versions of Netbeans API. (prior to recent API changes in 6.1)
Comment 1 Jaroslav Tulach 2008-03-05 18:35:17 UTC
I am sorry, I cannot reproduce your problem. Write a unit test that I can execute. Adding Miloš on CC, maybe he has 
some clue of what you are talking about.
Comment 2 Milos Kleint 2008-03-05 18:48:03 UTC
What recent API change? if it's the j2ee.common friend api introduction, you should reassign the issue there I suppose.

Is your createAdditionalLookup() method being called?
Do you get any result when calling project.getLookup().lookup(OTDLinks.class) or is it failing to return anything as well?
Comment 3 Prashant Ponnala 2008-03-05 18:52:11 UTC
createAdditionalLookup() method does get called when netbeans loads the module.
However, the Collection returned by the call lookupAll() does not contain anything.
There are 3 modules which register lookup() and none of them are returned.

Comment 4 Prashant Ponnala 2008-03-06 00:33:01 UTC
Created attachment 57840 [details]
nbms needed for install
Comment 5 Prashant Ponnala 2008-03-06 00:46:34 UTC
Sent email separately as files are too big to attach to the issue here.
Comment 6 David Simonek 2008-03-06 09:09:45 UTC
P1 is reserved for crashes and data lost, lowering to P2.
Comment 7 Milos Kleint 2008-03-06 11:22:35 UTC
jardo, check the org.netbeans.spi.project.support.LookupProviderSupport class in projectapi for what additional work we
do in projects (to incorporate LookupMergers) but it's mostly good old ProxyLookup.
I'm not aware of any work in this area for 6.1. The ejbjar project seems to be written correctly..


Comment 8 Jaroslav Tulach 2008-03-18 12:32:03 UTC
I've sent Prashant Ponnala email, asking for more detailed way to reproduce this. Without it things seem to work for 
me.