Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » JGit : Problem with using the Bundlewriter
JGit : Problem with using the Bundlewriter [message #1796535] Mon, 15 October 2018 20:09 Go to next message
Christian Jeschke is currently offline Christian JeschkeFriend
Messages: 1
Registered: October 2018
Junior Member
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 f‌ile = new File( "readme.txt" );
    	f‌ile.createNewFile();
    	Git git = Git.init().setDirectory( f‌ile.getParentFile() ).call();
    	git.add().addFilepattern("readme.txt").call();
        git.commit().setMessage("Initial commit").call();
        System.out.println("Committed file " + f‌ile + " 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();
	}
Re: JGit : Problem with using the Bundlewriter [message #1797279 is a reply to message #1796535] Mon, 29 October 2018 13:45 Go to previous message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 1268
Registered: July 2009
Senior Member
Are JGitText.class and JGitText.properties present on your application's classpath ?
Previous Topic:I want to add a submodule with a relative path
Next Topic:Is it possible to check user/password credentials valid on repository?
Goto Forum:
  


Current Time: Thu Apr 25 08:53:29 GMT 2024

Powered by FUDForum. Page generated in 0.03221 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top