Bug 250437 - [fiximprove]: Error searching for devices
Summary: [fiximprove]: Error searching for devices
Status: CLOSED FIXED
Alias: None
Product: MTJ (Archived)
Classification: Tools
Component: MTJ projects (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P1 critical (vote)
Target Milestone: 0.9   Edit
Assignee: Gustavo de Paula CLA
QA Contact:
URL:
Whiteboard:
Keywords: api, core
Depends on:
Blocks:
 
Reported: 2008-10-10 10:09 EDT by dzw CLA
Modified: 2008-10-15 09:21 EDT (History)
5 users (show)

See Also:


Attachments
Picture for screen shot (29.96 KB, image/x-png)
2008-10-10 10:11 EDT, dzw CLA
no flags Details
Error details (9.11 KB, image/x-png)
2008-10-10 12:26 EDT, dzw CLA
no flags Details
Import WTK (22.48 KB, image/x-png)
2008-10-10 23:04 EDT, dzw CLA
no flags Details
eclipseme.feature_1.7.9_site works fine (17.24 KB, image/x-png)
2008-10-10 23:10 EDT, dzw CLA
no flags Details
^_^ Suggest add an option for not Search for Javadoc (17.95 KB, image/x-png)
2008-10-12 01:30 EDT, dzw CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description dzw CLA 2008-10-10 10:09:14 EDT
Overview: (More detailed restatement of summary)

Steps to Reproduce: (Minimized, easy-to-follow steps that will trigger the bug)

    1)Import Devices
    2)Error searching for devices

Actual Results: (What MTJ did after performing the above steps)

S40_5th_Edition_SDK_Feature_Pack_1
S60_3rd_MIDP_SDK_FP1
Sun Java (TM) Wireless Toolkit 2.5.2 for CLDC

All these SDK above cannot be imported.

"Error searching for devices"


Expected Results: (What MTJ should have done, were the bug not present)



Build Date & Platform: (update with the correct values from your workspace)
 
 Installation : Eclipse Platform Version: 3.4.1 Build id: M20080911-1700

 MTJ install  : Runtime | SDK | Examples
 java.runtime : Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
 os.name:     : Windows XP Professional, Service Pack 3

Additional Builds and Platforms: (Whether or not it occurs on other platforms)

S40_5th_Edition_SDK_Feature_Pack_1
S60_3rd_MIDP_SDK_FP1
Sun Java (TM) Wireless Toolkit 2.5.2 for CLDC

Additional Information: (Any other useful information)
Comment 1 dzw CLA 2008-10-10 10:11:49 EDT
Created attachment 114793 [details]
Picture for screen shot
Comment 2 Gustavo de Paula CLA 2008-10-10 10:26:00 EDT
this issue associated with xp (sp3) usually happens because xp (sp3) usually blocks the emulator executable and since that mtj is not able to runs the emulator to identify and import the devices.

can you please double check on windows firewall to see if the emulator executables are on the exclude list?

thanks,
gustavo
Comment 3 dzw CLA 2008-10-10 11:00:46 EDT
It is ok when I use eclipseme,I can import the devices correctly.

I have no firewall opened including windows firewall.
Comment 4 dzw CLA 2008-10-10 11:12:06 EDT
eclipseme.feature_1.7.9_site is OK with
Eclipse 
Version: 3.3.2
Build id: M20080221-1800
Comment 5 dzw CLA 2008-10-10 11:20:31 EDT
With 
Eclipse Platform Version: 3.3.2 Build id: M20080221-1800 and 
eclipseme.feature_1.7.9_site

I can import all the 3 SDK to IDE.
Comment 6 Gustavo de Paula CLA 2008-10-10 11:50:22 EDT
thanks for the additional information

can you past the details of the error message? is a log generated on the workspace? if yes, can you also attached

gustavo

(In reply to comment #5)
> With 
> Eclipse Platform Version: 3.3.2 Build id: M20080221-1800 and 
> eclipseme.feature_1.7.9_site
> 
> I can import all the 3 SDK to IDE.
> 

Comment 7 dzw CLA 2008-10-10 12:26:49 EDT
Created attachment 114816 [details]
Error details
Comment 8 Diego Madruga Sandin CLA 2008-10-10 12:51:26 EDT
Hi,

This error you reported seems similar to the one reported in the user list http://dev.eclipse.org/mhonarc/newsLists/news.eclipse.dsdp.mtj/msg00279.html,
and its related to the javadoc importer. This feature is not available in Eclipseme (only mtj), thats why the import works fine when you are using EclipseME.

We are trying to evaluate this error but I can't reproduce the behavior reported, may you provide which MTJ Build you're using (Build id)? 

Comment 9 dzw CLA 2008-10-10 13:07:45 EDT
dsdp-mtj-runtime-incubation-N20081007
dsdp-mtj-runtime-incubation-0.9RC1

They hava the same problem whenever which version of eclipse I use.
Comment 10 dzw CLA 2008-10-10 22:18:27 EDT
Revision 328 
    private IRunnableWithProgress getDeviceSearchRunnable(
            final File[] searchDirectories) {
        // The runnable to do the device search
        return new IRunnableWithProgress() {
            public void run(IProgressMonitor monitor)
                    throws InvocationTargetException, InterruptedException {
                try {
                    getShell().getDisplay().asyncExec(new Runnable() {
                        public void run() {
                            deviceList.clear();
                        }
                    });

                    for (int i = 0; i < searchDirectories.length; i++) {
                        DeviceFactory.findDevices(searchDirectories[i],
                                deviceList, monitor);
                    }

                    getShell().getDisplay().asyncExec(new Runnable() {
                        public void run() {
                            deviceViewer.refresh();
                            deviceViewer.setAllChecked(true);
                        }
                    });
                } catch (CoreException e) {
                    throw new InvocationTargetException(e);
                }
            }
        };
    }


Revision 474


    private IRunnableWithProgress getDeviceSearchRunnable(
            final File[] searchDirectories) {
        // The runnable to do the device search
        return new IRunnableWithProgress() {
            public void run(IProgressMonitor monitor)
                    throws InvocationTargetException, InterruptedException {
                try {
                    getShell().getDisplay().syncExec(new Runnable() {
                        public void run() {
                            deviceList.clear();
                        }
                    });

                    for (File element : searchDirectories) {
                        DeviceFactory.findDevices(element, deviceList, monitor);

                    }

                    getShell().getDisplay().syncExec(new Runnable() {
                        public void run() {
                            deviceViewer.refresh();
                            deviceViewer.setAllChecked(true);
                        }
                    });
                } catch (CoreException e) {
                    throw new InvocationTargetException(e);
                }
            }
        };
    }
Comment 11 dzw CLA 2008-10-10 22:28:04 EDT
dsdp-mtj-runtime-incubation-I20080813
 is ok
Comment 12 dzw CLA 2008-10-10 23:02:03 EDT
sorry my mistake 
dsdp-mtj-runtime-incubation-I20080813 
has the same problem
Error searching for devices
Comment 13 dzw CLA 2008-10-10 23:04:40 EDT
Created attachment 114861 [details]
Import WTK
Comment 14 dzw CLA 2008-10-10 23:10:29 EDT
Created attachment 114862 [details]
eclipseme.feature_1.7.9_site works fine
Comment 15 Gustavo de Paula CLA 2008-10-11 20:30:07 EDT
gang,

if you have sometime, can you please take a look at this bug? it is related to the import javadoc feature. in some scenarios it is throwing a NPE, but it only happens in some machines. 

we are also investigating this issue here.

thanks,
:)
gustavo

(In reply to comment #14)
> Created an attachment (id=114862) [details]
> eclipseme.feature_1.7.9_site works fine
> 

Comment 16 dzw CLA 2008-10-12 01:30:15 EDT
Created attachment 114894 [details]
^_^ Suggest add an option for not Search for Javadoc
Comment 17 dzw CLA 2008-10-12 02:33:46 EDT
Find the Error Function
getDefaultDocRootDirectories

When I have "doc_location[1].pdf" file in "C:\" 
and I was importing "C:\Nokia\Devices\S40_5th_Edition_SDK_Feature_Pack_1" SDK
the error reproduced
Comment 18 dzw CLA 2008-10-12 02:37:07 EDT
name contains "doc" string
Comment 19 dzw CLA 2008-10-12 02:39:16 EDT
^_^ find the error Happy
Comment 20 dzw CLA 2008-10-12 02:57:14 EDT
in JavadocDetector.java

GenericLocalFSSearch

        private URL searchForLibraryDoc(File parentDir, final ILibrary library) {
            String libFileName = library.toFile().getName();
            int dotIdx = libFileName.lastIndexOf('.');
            final String libName;
            if (dotIdx > -1)
                libName = libFileName.substring(0, dotIdx);
            else
                libName = libFileName;

            File[] files = parentDir.listFiles(new FileFilter() {
                public boolean accept(File pathname) {
                    boolean accept = false;
                    // if the directory's name starts with the library's name
                    // or the library's name starts with the directory's name
                    // it is may be the library's javadoc directory, it is just
                    // a very simple strategy
                    accept = pathname.getName().startsWith(libName)
                            || libName.startsWith(pathname.getName());

                    // if not found and the library has configuration or profile
                    // API, deal with it specially
                    if (!accept
                            && (library.hasConfiguration() || library
                                    .hasProfile())) {
                        for (int i = 0; i < PROFILEJAVADOCDIRECTORIES.length; i++) {
                            if (pathname.getName().startsWith(
                                    PROFILEJAVADOCDIRECTORIES[i])) {
                                accept = true;
                                break;
                            }
                        }
                    }

                    return accept;

                }
            });

            if (files != null && files.length > 0) {
                try {
                    return files[0].toURI().toURL();
                } catch (MalformedURLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            } else {
                // Now recurse to sub directories
                File[] subdirectories = parentDir.listFiles(new FileFilter() {
                    public boolean accept(File pathname) {
                        return pathname.isDirectory();
                    }
                });
/////////////////////////////////////////////////////////////////////
                if (subdirectories!=null)  ////add this will be ok
                {   ////add this will be ok

	                for (int i = 0; i < subdirectories.length; i++) {
	                    return searchForLibraryDoc(subdirectories[i], library);
	                }
                } ////add this will be ok

//////////////////////////////////////////////////////////////////////

            }
            return null;
        }

///searchForLibraryDoc
Comment 21 Gustavo de Paula CLA 2008-10-12 20:39:28 EDT
congratulations!!!! and many thanks finally someone was able to find a root cause of the error.

i will check tomorrow if it there are other possible scenarios that we are not covering. another wasy to fix it is to change the getDefaultDocRootDirectories method.

        public File[] getDefaultDocRootDirectories(ILibrary library) {
            if (library == null)
                return null;

            ArrayList<File> docfiles = new ArrayList<File>();
            File parentDir = library.toFile().getParentFile();
            for (int i = 0; i < DEFAULTSEARCHDEPTH && parentDir != null; i++) {
                File[] tmpDocfiles = parentDir.listFiles(new FileFilter() {
                    public boolean accept(File pathname) {
                        // find the directory whose name contains "doc" string

                        /**************************************/
                        /* Also check if the file is a folder */
                        /**************************************/
                        return pathname.isDirectory() && pathname.getName().indexOf("doc") != -1;
                    }
                });
                for (File file : tmpDocfiles) {
                    docfiles.add(file);
                }
                parentDir = parentDir.getParentFile();

            }

            if (docfiles.size() > 0)
                return docfiles.toArray(new File[0]);
            else
                return null;

        }
    }

 

(In reply to comment #19)
> ^_^ find the error Happy
> 

Comment 22 Gang(Allen) Ma CLA 2008-10-12 22:39:58 EDT
Gustavo£¬
sorry for the late response, I think your fix is ok, I test it on my machine, everything looks fine and no NPE throws any more, thanks.

dzw,
thank you very much for your effort.

(In reply to comment #21)
> congratulations!!!! and many thanks finally someone was able to find a root
> cause of the error.
> i will check tomorrow if it there are other possible scenarios that we are not
> covering. another wasy to fix it is to change the getDefaultDocRootDirectories
> method.
>         public File[] getDefaultDocRootDirectories(ILibrary library) {
>             if (library == null)
>                 return null;
>             ArrayList<File> docfiles = new ArrayList<File>();
>             File parentDir = library.toFile().getParentFile();
>             for (int i = 0; i < DEFAULTSEARCHDEPTH && parentDir != null; i++) {
>                 File[] tmpDocfiles = parentDir.listFiles(new FileFilter() {
>                     public boolean accept(File pathname) {
>                         // find the directory whose name contains "doc" string
>                         /**************************************/
>                         /* Also check if the file is a folder */
>                         /**************************************/
>                         return pathname.isDirectory() &&
> pathname.getName().indexOf("doc") != -1;
>                     }
>                 });
>                 for (File file : tmpDocfiles) {
>                     docfiles.add(file);
>                 }
>                 parentDir = parentDir.getParentFile();
>             }
>             if (docfiles.size() > 0)
>                 return docfiles.toArray(new File[0]);
>             else
>                 return null;
>         }
>     }
> (In reply to comment #19)
> > ^_^ find the error Happy
> > 

Comment 23 Gustavo de Paula CLA 2008-10-13 10:01:04 EDT
since we haven't published 0.9 yet, i think it is good idea that we include this fix. anyone against that?

:)
gep

(In reply to comment #22)
> Gustavo£¬
> sorry for the late response, I think your fix is ok, I test it on my machine,
> everything looks fine and no NPE throws any more, thanks.
> 
> dzw,
> thank you very much for your effort.
> 
> (In reply to comment #21)
> > congratulations!!!! and many thanks finally someone was able to find a root
> > cause of the error.
> > i will check tomorrow if it there are other possible scenarios that we are not
> > covering. another wasy to fix it is to change the getDefaultDocRootDirectories
> > method.
> >         public File[] getDefaultDocRootDirectories(ILibrary library) {
> >             if (library == null)
> >                 return null;
> >             ArrayList<File> docfiles = new ArrayList<File>();
> >             File parentDir = library.toFile().getParentFile();
> >             for (int i = 0; i < DEFAULTSEARCHDEPTH && parentDir != null; i++) {
> >                 File[] tmpDocfiles = parentDir.listFiles(new FileFilter() {
> >                     public boolean accept(File pathname) {
> >                         // find the directory whose name contains "doc" string
> >                         /**************************************/
> >                         /* Also check if the file is a folder */
> >                         /**************************************/
> >                         return pathname.isDirectory() &&
> > pathname.getName().indexOf("doc") != -1;
> >                     }
> >                 });
> >                 for (File file : tmpDocfiles) {
> >                     docfiles.add(file);
> >                 }
> >                 parentDir = parentDir.getParentFile();
> >             }
> >             if (docfiles.size() > 0)
> >                 return docfiles.toArray(new File[0]);
> >             else
> >                 return null;
> >         }
> >     }
> > (In reply to comment #19)
> > > ^_^ find the error Happy
> > > 
> 

Comment 24 Diego Madruga Sandin CLA 2008-10-13 10:09:41 EDT
Since this issue is critical, +1 to published the fix on 0.9 version.

(In reply to comment #23)
> since we haven't published 0.9 yet, i think it is good idea that we include
> this fix. anyone against that?
> 
> :)
> gep

Comment 25 Hugo Raniere CLA 2008-10-13 13:23:57 EDT
+1
I'm OK to publish it on 0.9 as well.
Comment 26 Gang(Allen) Ma CLA 2008-10-13 21:05:21 EDT
+1 to include the fix on 0.9
Comment 27 Gustavo de Paula CLA 2008-10-14 13:22:47 EDT
bug fix and added to 0.9 release. tests run with the follwoing SDKs on windpws XP:
- nokia s40
- nokia s60
- motorola sdk
- sonyericsson
- LG SDK
- Sprint SDK
Comment 28 Gustavo de Paula CLA 2008-10-15 09:21:56 EDT
all bugs we integrated and release on MTj 0.9