-3

I am not able to add any file in the repository using editor, it is throwing a java.lang.NullPointerException exception at line editor.addFile(textfile, null, -1);

try {
    url = "https://XXX.yyy.zzzz";
    SVNRepository repository = null;
    String name = "testuser";
    String password = "testuserpassword";
    repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(url));
    ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(name, password);
    repository.setAuthenticationManager(authManager);
    System.out.println(repository.getLatestRevision());

    SVNClientInterface client = SVNClientImpl.newInstance();
} catch (Exception e) {
    System.out.println("error");
}               

try { 
    ISVNEditor editor = repository.getCommitEditor("This is a log message.", new CommitMediator()); 

    editor.openRoot(-1); 
    System.out.println("in DAV");
    editor.addFile(textfile, null, -1);
    editor.addFile("file1.txt", null, -1);       
    editor.applyTextDelta("file1.txt", null); 
    OutputStream os=null;
    os.close(); 
    editor.textDeltaEnd(file1.txt); 
    editor.closeFile(file1.txt, null); 
    editor.closeEdit(); 
} catch(Exception e) {
    System.out.println(e);
}
javanna
  • 59,145
  • 14
  • 144
  • 125
  • I am not able to add any file in the repository using editor, it is throwing an java.lang.NullPointerException exception at line "editor.addFile(textfile, null, -1); " Thanks in Advance – user1118693 Jan 11 '12 at 04:22
  • `os.close();` after `OutputStream os=null;` means `NullPointerException` for sure. – javanna Jan 11 '12 at 12:49
  • If you don't want to use log4j or something for logging, at least replace `System.out.println(e);` with `e.printStackTrace();`, please! – javanna Jan 11 '12 at 12:51

1 Answers1

0
editor.addFile(textfile, null, -1);

What's textfile?

OutputStream os=null;
os.close();

Might want to think about what's happening right there.

Rob Hruska
  • 118,520
  • 32
  • 167
  • 192