Question

I need to call some git functions from my program. I am getting NPE and may be I am not properly instantiating the class.

GitBlit gitblit = new GitBlit();
gitblit.getRepositoryList();

Is this the wrong way?

Even I tried with GitBlit.self().getRepositoryList(); and still the output was an NPE. I have a gitblit server running my local machine as https://milestones.af.com:8443

No correct solution

OTHER TIPS

Here's an answer from James Moger to the same question asked in the GitBlit forum:

HI Manisha,

In the 1.3.x code GitBlit is the context for the webapp. It is a singleton but it must be properly initialized by the container through web.xml or by using the embedded Jetty. In the 1.3.x code you can't just instantiate a GitBlit instance and have it be ready for use.

In the current master branch (1.4.x) things have been massively refactored and modularized. GitBlit is no longer a webapp context but is the aggregation of several smaller classes. It still relies on proper initialization/configuration but this requirement is now more obvious.

Depending on your needs, you may do better with just harvesting code from the JGitUtils class.

-J

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top