开发者

JGit/EGit Loading of translation bundle failed en_US

I am running the following code in a JUnit test to test fetching a git repository. I'm writing a test for each of the basic functionality i need from JGit so that then i can implement them in my application. The problem is that 开发者_StackOverflow社区i keep getting the following error on the git.fetch() call below:

Loading of translation bundle failed for [org.eclipse.jgit.JGitText, en_US]
org.eclipse.jgit.errors.TranslationBundleLoadingException: Loading of translation bundle failed for [org.eclipse.jgit.JGitText, en_US]

The code sample is below. I verified that the repository paths and everything seems correct. If i put a breakpoint on the fetch call and then run the same command in MSysGit it works.

  try {
         String remoteName = "origin";
         URIish uri = new URIish(repository.getRepositoryDirectory());
         saveRemote(repository2.getRepository(), uri, remoteName);
         Git git = repository.getGit();
         FetchResult r = git.fetch().setRemote(remoteName).call();
         assertNotNull("Did not get any result from fetch.", r);
      } catch (JGitInternalException ex) {
         fail("Failed to do fetch. " + ex.getMessage());
      } catch (InvalidRemoteException ex) {
         fail("Failed to do fetch. " + ex.getMessage());
      } catch (URISyntaxException ex) {
         fail("Failed to do fetch. " + ex.getMessage());
      }

Thanks!


Okay I figured this out. I had to copy the file JGitText.properties from the binary distribution into the same package in the source code, rename it to JGitText_en_US.properties, and add a whole bunch of properties to it manually that the code used in JGitText.java but were not defined in JGitText.properties.

I searched through the entire source code and all binary files and related docs and found no reference to these new properties, or the properties file being created anywhere. I don't know why the devs don't have localization files in the source code or at least a way to generate then through a build file or something. I mean they must manually have to add them into their source code and just not commit it.

Anyway this was a very annoying issue, there was no documentation on it anywhere on the net (that google revealed anyway) so I thought i would share this as it might help others who ran into the same problem.


I had the same problem, but my fix was a little different. In my case, the problem was related to the OSGI classloader.

Here's a commit that fixes the issue: https://github.com/diffplug/jgit/commit/3bcc69bde5567ec57ccd6bd065ded0db49f810fb

And here's the rationale behind it: Loading a ResourceBundle within an OSGi bundle

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜