Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 323149 - P2 Nullpointer Exception at RepositoryTransport.download
Summary: P2 Nullpointer Exception at RepositoryTransport.download
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: p2 (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.7 M3   Edit
Assignee: P2 Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 327172 (view as bug list)
Depends on:
Blocks: 330030
  Show dependency tree
 
Reported: 2010-08-19 10:39 EDT by Suganya Devi CLA
Modified: 2011-01-27 17:32 EST (History)
6 users (show)

See Also:


Attachments
Remote P2 repository structure (666.64 KB, image/png)
2010-08-19 10:42 EDT, Suganya Devi CLA
no flags Details
ECF filetransfer exception (11.13 KB, application/octet-stream)
2010-10-05 15:08 EDT, Suganya Devi CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Suganya Devi CLA 2010-08-19 10:39:28 EDT
Build Identifier: 3.6.0 I20100608-0911

    I'm following the Product based build for our RCP application. The build creates a local repository in the build directory in my local system. Once the build is successful, I copy the P2 repository to a remote URL (http). 

    The application is pointing to the remote URL. Now when I start my application, I'm getting NullPointer Exception at RepositoryTransport.download(RepositoryTransport.java:75). If I connect to the local repository (in build directory), it works fine. The following is the exception that I'm getting, 

java.lang.reflect.InvocationTargetException
        at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:477)
        at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:372)
        at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:507)
        at ams.client.eclipse.actions.UpdateAction.run(Unknown Source)
        at ams.client.eclipse.AMSClientWorkbenchAdvisor.preStartup(Unknown Source)
        at org.eclipse.ui.internal.Workbench$31.runWithException(Workbench.java:1564)
        at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
        at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
        at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
        at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4041)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3660)
        at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2537)
        at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
        at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
        at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
        at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
        at ams.client.eclipse.AMSClient.start(Unknown Source)
        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
        at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
Caused by: java.lang.NullPointerException
        at org.eclipse.equinox.internal.p2.repository.RepositoryTransport.download(RepositoryTransport.java:75)
        at org.eclipse.equinox.internal.p2.repository.RepositoryTransport.download(RepositoryTransport.java:127)
        at org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.loadIndexFile(AbstractRepositoryManager.java:719)
        at org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.loadRepository(AbstractRepositoryManager.java:640)
        at org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager.loadRepository(MetadataRepositoryManager.java:96)
        at org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager.loadRepository(MetadataRepositoryManager.java:92)
        at org.eclipse.equinox.p2.engine.ProvisioningContext.loadMetadataRepository(ProvisioningContext.java:211)
        at org.eclipse.equinox.p2.engine.ProvisioningContext.getLoadedMetadataRepositories(ProvisioningContext.java:194)
        at org.eclipse.equinox.p2.engine.ProvisioningContext.getMetadata(ProvisioningContext.java:275)
        at org.eclipse.equinox.internal.p2.director.SimplePlanner.updatesFor(SimplePlanner.java:769)
        at org.eclipse.equinox.p2.operations.UpdateOperation.updatesFor(UpdateOperation.java:144)
        at org.eclipse.equinox.p2.operations.UpdateOperation.computeProfileChangeRequest(UpdateOperation.java:181)
        at org.eclipse.equinox.p2.operations.UpdateOperation$1.run(UpdateOperation.java:325)
        at org.eclipse.equinox.internal.p2.operations.SearchForUpdatesResolutionJob.runModal(SearchForUpdatesResolutionJob.java:37)
        at org.eclipse.equinox.p2.operations.ProfileChangeOperation.resolveModal(ProfileChangeOperation.java:115)
        at ams.client.eclipse.actions.UpdateAction$Runner.checkForUpdates(Unknown Source)
        at ams.client.eclipse.actions.UpdateAction$Runner.run(Unknown Source)
        at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:464)



Reproducible: Always
Comment 1 Suganya Devi CLA 2010-08-19 10:42:34 EDT
Created attachment 177001 [details]
Remote P2 repository structure
Comment 2 Suganya Devi CLA 2010-08-24 16:04:52 EDT
Is this something to do with the proxy setting?
Comment 3 Suganya Devi CLA 2010-09-27 08:50:17 EDT
Can someone have a look at this issue?
Comment 4 DJ Houghton CLA 2010-09-28 10:27:17 EDT
Pascal, this seems to be a duplicate of bug 313732 (which is a duplicate of bug 313502). 

Although the problem may be with the setup of an external bundle, it seems like we should be protecting against an NPE. The javadoc for Job#getResult says that it may return null so we should be checking for it. What should we do in this case? Which type of exception should we throw?
Comment 5 Suganya Devi CLA 2010-09-30 11:58:43 EDT
It works fine with the local repository. Also, I noticed that the logic to download the index file from remote P2 repository is different from the local repository. I thought the index files are optional ones.
Comment 6 Henrik Lindberg CLA 2010-09-30 21:20:05 EDT
(In reply to comment #4)
> Pascal, this seems to be a duplicate of bug 313732 (which is a duplicate of bug
> 313502). 
> 
> Although the problem may be with the setup of an external bundle, it seems like
> we should be protecting against an NPE. The javadoc for Job#getResult says that
> it may return null so we should be checking for it. What should we do in this
> case? Which type of exception should we throw?

It currently does this:

IStatus result = reader.getResult();
if (result.getSeverity() == IStatus.CANCEL)
    throw new UserCancelledException();
if (!result.isOK())
    throw new CoreException(result);

// Download status is expected on success
DownloadStatus status = new DownloadStatus(IStatus.OK, Activator.ID, Status.OK_STATUS.getMessage());
return statusOn(target, status, reader);

I think it is enough to return statusOn(...) with a DownloadStatus having IStatus.ERROR, and code ProvisionException.REPOSITORY_FAILED_READ, and suitable message.
Comment 7 Suganya Devi CLA 2010-10-04 08:34:35 EDT
(In reply to comment #4)
> Although the problem may be with the setup of an external bundle, it seems like

Can you please explain me what kind of a problem it could be? Even if the NPE is fixed, my download from remote repository would still fail. So I would like to resolve that as well.
Comment 8 DJ Houghton CLA 2010-10-04 11:42:30 EDT
Ok, I've released a fix with Henrik's suggestions to protect against the NPE.

Bug 313732 comment 9 says that it is because of a problem with SLF4J. Perhaps Pascal can comment on this further for you.
Comment 9 Suganya Devi CLA 2010-10-04 12:39:09 EDT
(In reply to comment #8)
> Ok, I've released a fix with Henrik's suggestions to protect against the NPE.

Can you please tell me where can I get the patch from?

> Bug 313732 comment 9 says that it is because of a problem with SLF4J. Perhaps
> Pascal can comment on this further for you.

Bug 313732 is breaking because of SLF4J, but our RCP application is not. Anyways, will wait for Pascal to answer this.
Comment 10 DJ Houghton CLA 2010-10-04 12:45:32 EDT
You can see it in CVS here:

server: dev.eclipse.org
repo: /cvsroot/rt
path: org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.repository
Comment 11 Suganya Devi CLA 2010-10-05 15:03:26 EDT
(In reply to comment #10)
Applied the patch and included in my RCP application. It doesn't throw NPE at RepositoryTransport. But, I see exceptions in loading simpleRepository and compositeRepository. Please see the attached .log file. Also the update is not downloaded.
Comment 12 Suganya Devi CLA 2010-10-05 15:08:46 EDT
Created attachment 180275 [details]
ECF filetransfer exception
Comment 13 Suganya Devi CLA 2010-10-05 16:14:03 EDT
Note: I'm getting INFO status with STATUS_NOTHING_TO_UPDATE.
Comment 14 Henrik Lindberg CLA 2010-10-05 18:47:12 EDT
(In reply to comment #13)
> Note: I'm getting INFO status with STATUS_NOTHING_TO_UPDATE.

The stack trace has this at the top:

java.lang.NoClassDefFoundError
	at org.eclipse.ecf.provider.filetransfer.httpclient.HttpClientBrowseFileTransferFactory$1.sendBrowseRequest(HttpClientBrowseFileTransferFactory.java:53)
	at org.eclipse.ecf.provider.filetransfer.browse.MultiProtocolFileSystemBrowserAdapter.sendBrowseRequest(MultiProtocolFileSystemBrowserAdapter.java:95)
	at org.eclipse.equinox.internal.p2.repository.FileInfoReader.sendBrowseRequest(FileInfoReader.java:181)

This indicates that ECF is not configured correctly. Guessing that HttpClient is missing in your configuration (i.e. not a p2 issue, although if this results in a silent "nothing to update", than this is no good and should be logged as separate issue "misconfigured ECF is (almost) silently ignored"
Comment 15 Suganya Devi CLA 2010-10-06 09:01:48 EDT
(In reply to comment #14)
Henrik,
Thanks for the tip. I will check the configuration. 

But, the same application downloads the update if I point to a local repository / map the remote repository to a local drive.
Comment 16 Suganya Devi CLA 2010-10-06 14:32:15 EDT
(In reply to comment #15)
OMG, it works now. Once again thanks for the tip on HttpClient. 
    
I verified the configuration, and found that all the ECF file transfer and related bundles were available and started properly. So I just included a piece of line in one of our class files to invoke HttpClient (to see if it throws NoClassDefFoundError). When I started the application, I got InvocationTarget  exception caused by the following ClassCastException at HttpClient. 

"The chosen LogFactory implementation does not extend LogFactory. Please check your configuration. 
(Caused by java.lang.ClassCastException: The application has specified that a custom LogFactory implementation should be used but Class 'com.ibm.ws.commons.logging.TrLogFactory' cannot be converted  to 'org.apache.commons.logging.LogFactory'................."

HttpClient has a static loader (at line 66) and it was loading WebSphere's TrLogFactory, which caused the ClassCastException. So, the HttpClient was not loaded and further caused NoClassDefFoundError at HttpClientBrowseFileTransferFactory. 

I found the explanation and fixes for the ClassCastException at http://commons.apache.org/logging/troubleshooting.html#Symptoms. I added "-Dorg.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.LogFactoryImpl" to the system properties and when I started the application, it downloaded from the remote P2 repository and updated perfectly.

Thanks for the all the help and support from P2 team.
Comment 17 Thomas Hallgren CLA 2010-10-14 11:42:52 EDT
Is there some workaround for this other then applying the patch? I get the same error when I use the director app. Slightly different stack trace.

java.lang.NullPointerException
	at org.eclipse.equinox.internal.p2.repository.RepositoryTransport.download(RepositoryTransport.java:75)
	at org.eclipse.equinox.internal.p2.repository.RepositoryTransport.download(RepositoryTransport.java:127)
	at org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.loadIndexFile(AbstractRepositoryManager.java:718)
	at org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.loadRepository(AbstractRepositoryManager.java:639)
	at org.eclipse.equinox.internal.p2.artifact.repository.ArtifactRepositoryManager.loadRepository(ArtifactRepositoryManager.java:99)
	at org.eclipse.equinox.internal.p2.artifact.repository.ArtifactRepositoryManager.loadRepository(ArtifactRepositoryManager.java:95)
	at org.eclipse.equinox.internal.p2.director.app.DirectorApplication.initializeRepositories(DirectorApplication.java:380)
	at org.eclipse.equinox.internal.p2.director.app.DirectorApplication.run(DirectorApplication.java:796)
	at org.eclipse.equinox.internal.p2.director.app.DirectorApplication.start(DirectorApplication.java:954)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at
Comment 18 Suganya Devi CLA 2010-10-14 13:31:50 EDT
If you apply the patch you might come to know the root cause (as in my case). If you can identify & fix the root cause, there is no need to apply the patch. But, I applied the patch even though the root cause in my application was fixed.
Comment 19 Ian Bull CLA 2010-11-09 20:05:08 EST
*** Bug 327172 has been marked as a duplicate of this bug. ***
Comment 20 Jason Bennett CLA 2011-01-27 17:32:11 EST
This bug may be the cause for some people... Spring IDE:

https://jira.springsource.org/browse/IDE-1163