Community
Participate
Working Groups
We are trying to declare our WTP M6 driver, and we found a NPE that is blocking core functionality in one of our plugins. Thus, this defect is of high importance to us. The following the stack trace that we are getting and I suspect this is due to some of the latest changes that we have had to adopt for P2. java.lang.NullPointerException at org.eclipse.equinox.internal.p2.metadata.repository.LocalMetadataRepository.publishRepositoryReferences(LocalMetadataRepository.java:179) at org.eclipse.equinox.internal.p2.metadata.repository.LocalMetadataRepository.initialize(LocalMetadataRepository.java:172) at org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryIO$Parser$RepositoryHandler.finished(MetadataRepositoryIO.java:329) at org.eclipse.equinox.internal.p2.persistence.XMLParser$AbstractHandler.endElement(XMLParser.java:188) at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) at org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryIO$Parser.parse(MetadataRepositoryIO.java:211) at org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryIO.read(MetadataRepositoryIO.java:65) at org.eclipse.equinox.internal.p2.metadata.repository.SimpleMetadataRepositoryFactory.load(SimpleMetadataRepositoryFactory.java:104) at org.eclipse.equinox.internal.p2.updatesite.metadata.UpdateSiteMetadataRepositoryFactory.loadRepository(UpdateSiteMetadataRepositoryFactory.java:76) at org.eclipse.equinox.internal.p2.updatesite.metadata.UpdateSiteMetadataRepositoryFactory.load(UpdateSiteMetadataRepositoryFactory.java:52) at org.eclipse.wst.server.discovery.internal.model.ExtensionUpdateSite.getExtensions(ExtensionUpdateSite.java:67) at org.eclipse.wst.server.discovery.internal.ExtensionUtility$1.run(ExtensionUtility.java:200)
which site do you get that against?
I should mentioned that this happens on any of the following repositories URLs: <site url="http://download.eclipse.org/webtools/updates/"/> <site url="http://www.apache.org/dist/geronimo/eclipse/updates/"/> <site url="http://public.dhe.ibm.com/software/websphere/wasce/updates/"/>
And this is the call that we are doing: IMetadataRepository repo = mrf.load(url2, IRepositoryManager.REPOSITORIES_ALL, monitor);
The NPE is a null agent, who is creating the UpdateSiteMetadataRepositoryFactory? If org.eclipse.wst.server.discovery.internal.model.ExtensionUpdateSite.getExtensions(ExtensionUpdateSite.java:67) is instantiating the factory, it will also need to call factory#setAgent You can get an agent with (IProvisioningAgent) ServiceHelper.getService(getContext(), IProvisioningAgent.SERVICE_NAME);
I don't get any of these errors when I load these repos in the p2 ui.
If I remember correctly you initialize the repository on your own and you may be passing the wrong argument in.
(In reply to comment #4) > You can get an agent with > (IProvisioningAgent) ServiceHelper.getService(getContext(), > IProvisioningAgent.SERVICE_NAME); Sorry, ServiceHelper is not API, you'll need to do an appropriate service lookup with a BundleContext
I added ExtensionUtility#getAgent as a helper. All service lookups should then be done through the acquired agent.
Thanks for the help. That helps, I would expect a better exception to be thrown instead of an NPE. So it would be nice to get that fix. I am now getting problems with the query.. any clues? java.lang.IllegalArgumentException: IMatchExpression cannot be turned into a context expression at org.eclipse.equinox.internal.p2.metadata.expression.ExpressionFactory.contextExpression(ExpressionFactory.java:61) at org.eclipse.equinox.p2.query.ExpressionQuery.<init>(ExpressionQuery.java:31) at org.eclipse.wst.server.discovery.internal.model.ExtensionUpdateSite.getExtensions(ExtensionUpdateSite.java:106) at org.eclipse.wst.server.discovery.internal.ExtensionUtility$1.run(ExtensionUtility.java:200)
Maybe Thomas can offer some insight here.
I don't have the source of wst.server.discovery available right now but from the looks of it, an IMatchExpression is passed into the ExpressionQuery constructor. Try using the ExpressionMatchQuery instead when creating a query for an IMatchExpression.
(In reply to comment #11) Okay I got pass that point now. I am now finding that SimplePlanner doesn't contain an implementation of createChangeRequest, which we use during: org.eclipse.wst.server.discovery.internal.model.Extension.getProvisioningPlan(boolean, IProgressMonitor)
(In reply to comment #12) I wanted to provide more details on what we are actually doing, you can take a look at the code in HEAD here: http://dev.eclipse.org/viewcvs/index.cgi/servertools/plugins/org.eclipse.wst.server.discovery/src/org/eclipse/wst/server/discovery/internal/model/Extension.java?root=WebTools_Project&view=markup What we are trying to do is to create a Provisioning plan, but in order to get the plan we need to calculate an IProfileChangeRequest, which we do using: IProfileChangeRequest pcr = planner.createChangeRequest(profile); but that is comming back with NULL because SimplePlanner, doesn't implement that method.
I have increased the priority on this bug, since I want to get this fix for WTP M7, and I am now fully looking into how to fix this problem to get our function working.
I'm looking at the stack-trace from comment 9. I think that problem is caused by line 80 in the ExpressionUtil: query = new ExpressionQuery<IInstallableUnit>(IInstallableUnit.class, requirement.getMatches()); Try replacing that line with: query = QueryUtil.createMatchQuery(requirement.getMatches()); I see that you have a MatchQuery subclass (the PatternInstallableUnitQuery) which matches names that ends with a string. I would advice you to change that. Replace this: query = new PatternInstallableUnitQuery("org.eclipse.wst.server.core.serverAdapter"); with this: query = QueryUtil.createMatchQuery("id ~= /*org.eclipse.wst.server.core.serverAdapter/"); I don't know what's going on with the provisioning plan. Perhaps Pascal has more insight on that.
(In reply to comment #15) Thanks Thomas. I am able to remove the PatternInstallableUnitQuery. It would be nice to add to the java docs of .createMatchQuery that it accepts RE, and perhaps some simple examples on how to search for ids and other fields. I was trying to use it but I didn't figure out what I needed to pass in.
Pascal, Any ideas on comment #13 ?
The planner method has been properly implemented.