Hey,
I try to write a Java application to bundle a git repository and write the bundle afterwards to a file. Unfortenly I get an Exception. I dived a little into the ResourceBundle Class and the Exception seems to be because of a missing ClassLoader. I would appreciate any hint I can't get. I attach both: the Exception I get and the code inside my main function.
java.lang.NullPointerException
at java.util.ResourceBundle.getBundle(ResourceBundle.java:1026)
at org.eclipse.jgit.nls.TranslationBundle.load(TranslationBundle.java:165)
at org.eclipse.jgit.nls.GlobalBundleCache.lookupBundle(GlobalBundleCache.java:96)
at org.eclipse.jgit.nls.NLS.get(NLS.java:132)
at org.eclipse.jgit.nls.NLS.getBundleFor(NLS.java:118)
at org.eclipse.jgit.internal.JGitText.get(JGitText.java:59)
at org.eclipse.jgit.internal.storage.pack.PackWriter.beginPhase(PackWriter.java:938)
at org.eclipse.jgit.internal.storage.pack.PackWriter.findObjectsToPack(PackWriter.java:1662)
at org.eclipse.jgit.internal.storage.pack.PackWriter.preparePack(PackWriter.java:799)
at org.eclipse.jgit.internal.storage.pack.PackWriter.preparePack(PackWriter.java:762)
at org.eclipse.jgit.transport.BundleWriter.writeBundle(BundleWriter.java:210)
at JGitTest.main(JGitTest.java:50)
public static void main(String[] args) throws IOException, GitAPIException {
File file = new File( "readme.txt" );
file.createNewFile();
Git git = Git.init().setDirectory( file.getParentFile() ).call();
git.add().addFilepattern("readme.txt").call();
git.commit().setMessage("Initial commit").call();
System.out.println("Committed file " + file + " to repository at " + git.getRepository().getDirectory());
Ref HEAD = git.getRepository().getRef("refs/heads/master");
if (HEAD == null)
System.out.println("HEAD not fund");
BundleWriter bundlewriter = new BundleWriter(git.getRepository());
File filebundle = new File( "file.bundle" );
filebundle.createNewFile();
System.out.println(mkdirs( filebundle.getAbsoluteFile().getParentFile() ));
OutputStream fos=null;
fos=new FileOutputStream(filebundle);
ProgressMonitor monitor = new EmptyProgressMonitor(){};
try {
bundlewriter.include(HEAD);
bundlewriter.writeBundle(monitor, fos);
} catch (Exception e){
e.printStackTrace();
}