You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by Tim McIver <tm...@verizon.net> on 2014/09/28 23:23:44 UTC
Fwd: Exception when writing an OBR
Hello,
I have a repo file which I've generated using bindex
(https://github.com/osgi/bindex) but I'm getting an NPE when trying to
read in then write this repo to another file. Here's the stack trace I see:
Exception in thread "main" java.lang.NullPointerException
at
org.apache.felix.bundlerepository.impl.DataModelHelperImpl.toXml(DataModelHelperImpl.java:380)
at
org.apache.felix.bundlerepository.impl.DataModelHelperImpl.toXml(DataModelHelperImpl.java:336)
at
org.apache.felix.bundlerepository.impl.DataModelHelperImpl.toXml(DataModelHelperImpl.java:299)
at
org.apache.felix.bundlerepository.impl.DataModelHelperImpl.writeRepository(DataModelHelperImpl.java:186)
at com.timmciver.App.main(App.java:19)
And here's the test class I created that gives this exception:
// start
package com.timmciver;
import org.apache.felix.bundlerepository.DataModelHelper;
import org.apache.felix.bundlerepository.Repository;
import org.apache.felix.bundlerepository.impl.DataModelHelperImpl;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
public class App {
public static void main(String[] args) throws Exception {
File repoFile = new File(args[0]);
DataModelHelper dmh = new DataModelHelperImpl();
Repository repo = dmh.repository(repoFile.toURI().toURL());
File outFile = File.createTempFile("obr-test-", ".xml");
try (Writer writer = new OutputStreamWriter(new
FileOutputStream(outFile))) {
dmh.writeRepository(repo, writer);
}
}
}
//end
I've also created a github repo if anyone wants to run it themselves:
https://github.com/tmciver/obr-test.
After looking at the code a bit it seems that the repository parser is looking for a tag called "require" and not
"requirement" which is what my repository XML file has. I think the repository parser is expecting to see an OBR-
specific file but Felix bundle repository claims to support both the OSGi Repository spec and an OBR-specific format
(http://felix.apache.org/site/apache-felix-osgi-bundle-repository.html#ApacheFelixOSGiBundleRepository-OBRRepositoryFile).
So my question is "how do I get the bundlerepository code to parse my OSGi repository file?"
I should also probably state my main goal: I'm trying to update a remote OBR XML file with the data for a new bundle
resource. I know the Maven Bundle Plugin does this but I'm actually trying to write a similar plugin for Leiningen -
Clojure's build tool. If there's a better way to do this, I'm all ears. :)
Thanks,
Tim