Petar Tahchiev Petar Tahchiev - 5 months ago 16
Java Question

JSR-354 java money moneta specify proxy

I'm trying to perform money conversion with Moneta API, so I call this:

MonetaryConversions.getExchangeRateProvider("IDENT", "ECB", "IMF", "ECB-HIST", "ECB-HIST90").getExchangeRate(sourceCurrency, targetCurrency);


Unfortunately I get this exception:

2016-06-15 17:14:12,659 [main] ERROR: Failed to load resource: IMFHistoricRateProvider
java.lang.IllegalStateException: Failed to load remote as well as fallback resources for LoadableResource [resourceId=IMFHistoricRateProvider, fallbackLocation=jar:file:/C:/Users/e-tahchpet/.m2/repository/org/javamoney/moneta/1.1/moneta-1.1.jar!/java-money/defaults/IMF/rms_five.xls, remoteResources=[http://www.imf.org/external/np/fin/data/rms_five.aspx?tsvflag=Y], loadCount=0, accessCount=1, lastLoaded=0]
at org.javamoney.moneta.internal.loader.LoadableResource.getData(LoadableResource.java:378)


I'm pretty sure it is because I am behind a corporate firewall. Is there a way to specify a proxy? Myabe in some property file?

Answer

Actually I found out it is possible by specifying the http.proxyHost and http.proxyPort system properties.