You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Tim McIver <tm...@verizon.net> on 2014/09/25 04:10:16 UTC

Exception when writing an OBR

Hello,

I'm getting an NPE when trying to write an OBR to file; I'm not sure
what I'm doing wrong.  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.

Thanks,
Timusers@felix.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Exception when writing an OBR

Posted by Tim McIver <tm...@verizon.net>.
I've made a small amount of headway on this issue.  It seems that there
are two schemas used for creating OBRs (described here
<http://felix.apache.org/site/apache-felix-osgi-bundle-repository.html#ApacheFelixOSGiBundleRepository-OBRRepositoryFile>). 
The repository file I created using the repoindex tool (a.k.a bindex,
here <https://github.com/osgi/bindex>), seems to have the form defined
by the OSGi spec and not the Felix OBR form.  In looking at the source
code where the exception occurs (I have a copy of the source but I was
unable to find a link to it now; it seems surprisingly difficult to
find) it seems that the repository parser is looking for a tag called
"require" and not "requirement" which is what my repository XML file
has.  So my question is "how do I get the bundlerepository code to parse
my OSGi repository file?"  Or, I could also solve this problem by
creating a repository file in the OBR format but I'm not sure how to do
that.

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.

Any help with this would be greatly appreciated.

Tim

On 09/24/2014 10:10 PM, Tim McIver wrote:
> Hello,
>
> I'm getting an NPE when trying to write an OBR to file; I'm not sure
> what I'm doing wrong.  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.
>
> Thanks,
> Timusers@felix.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>


Fwd: Exception when writing an OBR

Posted by Tim McIver <tm...@verizon.net>.
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