knowm / XChange

XChange is a Java library providing a streamlined API for interacting with 60+ Bitcoin and Altcoin exchanges providing a consistent interface for trading and accessing market data.
http://knowm.org/open-source/xchange/
MIT License
3.82k stars 1.93k forks source link

java.lang.NoClassDefFoundError: jakarta/ws/rs/Path #4804

Open Don-Builds opened 7 months ago

Don-Builds commented 7 months ago
    public static void main(String[] args) {
        MEXCExchange exchange = ExchangeFactory.INSTANCE.createExchange(MEXCExchange.class);
        MarketDataService marketDataService = exchange.getMarketDataService();
        try {
            Ticker ticker = marketDataService.getTicker(CurrencyPair.BTC_USD);
            System.out.println(ticker);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

Exception in thread "main" java.lang.NoClassDefFoundError: jakarta/ws/rs/Path at si.mazi.rescu.RestInvocationHandler.(RestInvocationHandler.java:59) at si.mazi.rescu.RestProxyFactory.createProxy(RestProxyFactory.java:47) at si.mazi.rescu.RestProxyFactoryImpl.createProxy(RestProxyFactoryImpl.java:9) at org.knowm.xchange.client.ExchangeRestProxyBuilder.build(ExchangeRestProxyBuilder.java:80) at org.knowm.xchange.mexc.service.MEXCBaseService.(MEXCBaseService.java:21) at org.knowm.xchange.mexc.service.MEXCMarketDataServiceRaw.(MEXCMarketDataServiceRaw.java:7) at org.knowm.xchange.mexc.service.MEXCMarketDataService.(MEXCMarketDataService.java:10) at org.knowm.xchange.mexc.MEXCExchange.initServices(MEXCExchange.java:15) at org.knowm.xchange.BaseExchange.applySpecification(BaseExchange.java:108) at org.knowm.xchange.ExchangeFactory.createExchange(ExchangeFactory.java:110) at org.knowm.xchange.ExchangeFactory.createExchange(ExchangeFactory.java:53)

pavlo-pastushok commented 6 months ago

hi guys, any update on this? I am facing a similar error, during Binance initialization

pavlo-pastushok commented 6 months ago

@rizer1980 hi, can you please try this one?

I am just trying to start a small demo on v5.1.1 before my app migration

I am using next main method as described in README

public static void main(String[] args) throws IOException {
        Exchange bitstamp = ExchangeFactory.INSTANCE.createExchange(BitstampExchange.class);
        MarketDataService marketDataService = bitstamp.getMarketDataService();
        Ticker ticker = marketDataService.getTicker(CurrencyPair.BTC_USD);
        System.out.println(ticker.toString());
    }

And I received an error everytime, I tried Binance, Bitfinex, Kraken and Bitstamp All exchanges have same behaviour

16:01:51.119 [main] DEBUG org.knowm.xchange.ExchangeFactory - Creating default exchange from class name
16:01:51.120 [main] DEBUG org.knowm.xchange.ExchangeFactory - Creating default exchange from class name
16:01:51.128 [main] DEBUG o.k.x.bitstamp.BitstampExchange - Loading metadata from bitstamp.json
16:01:51.676 [main] DEBUG o.k.x.bitstamp.BitstampExchange - ExchangeMetaData(instruments={}, currencies={BTC=CurrencyMetaData [scale=8, withdrawalFee=0.0005, minWithdrawalAmount=null, walletHealth=null], USD=CurrencyMetaData [scale=2, withdrawalFee=0, minWithdrawalAmount=null, walletHealth=null], EUR=CurrencyMetaData [scale=2, withdrawalFee=0, minWithdrawalAmount=null, walletHealth=null], GBP=CurrencyMetaData [scale=2, withdrawalFee=0, minWithdrawalAmount=null, walletHealth=null], XRP=CurrencyMetaData [scale=6, withdrawalFee=0.02, minWithdrawalAmount=null, walletHealth=null], LTC=CurrencyMetaData [scale=8, withdrawalFee=0.001, minWithdrawalAmount=null, walletHealth=null], ETH=CurrencyMetaData [scale=8, withdrawalFee=0.001, minWithdrawalAmount=null, walletHealth=null], BCH=CurrencyMetaData [scale=8, withdrawalFee=0.0001, minWithdrawalAmount=null, walletHealth=null], XLM=CurrencyMetaData [scale=8, withdrawalFee=0.005, minWithdrawalAmount=null, walletHealth=null], PAX=CurrencyMetaData [scale=8, withdrawalFee=20.0, minWithdrawalAmount=null, walletHealth=null], LINK=CurrencyMetaData [scale=8, withdrawalFee=1.0, minWithdrawalAmount=null, walletHealth=null], OMG=CurrencyMetaData [scale=8, withdrawalFee=3.0, minWithdrawalAmount=null, walletHealth=null], USDC=CurrencyMetaData [scale=8, withdrawalFee=20.0, minWithdrawalAmount=null, walletHealth=null], AAVE=CurrencyMetaData [scale=8, withdrawalFee=0.07, minWithdrawalAmount=null, walletHealth=null], BAT=CurrencyMetaData [scale=8, withdrawalFee=5.0, minWithdrawalAmount=null, walletHealth=null], UMA=CurrencyMetaData [scale=8, withdrawalFee=0.2, minWithdrawalAmount=null, walletHealth=null], DAI=CurrencyMetaData [scale=8, withdrawalFee=1.0, minWithdrawalAmount=null, walletHealth=null], KNC=CurrencyMetaData [scale=8, withdrawalFee=1.75, minWithdrawalAmount=null, walletHealth=null], MKR=CurrencyMetaData [scale=8, withdrawalFee=0.005, minWithdrawalAmount=null, walletHealth=null], ZRX=CurrencyMetaData [scale=8, withdrawalFee=3.0, minWithdrawalAmount=null, walletHealth=null], GUSD=CurrencyMetaData [scale=8, withdrawalFee=1.0, minWithdrawalAmount=null, walletHealth=null], ETH2=CurrencyMetaData [scale=8, withdrawalFee=0, minWithdrawalAmount=null, walletHealth=null]}, publicRateLimits=null, privateRateLimits=[RateLimit [calls=60, timeSpan=0, timeUnit=MINUTES]], shareRateLimits=true)
16:01:51.690 [main] DEBUG si.mazi.rescu.Config - Configuration from rescu.properties:
16:01:51.691 [main] DEBUG si.mazi.rescu.Config - httpConnTimeout = 30000
16:01:51.691 [main] DEBUG si.mazi.rescu.Config - httpReadTimeout = 30000
16:01:51.691 [main] DEBUG si.mazi.rescu.Config - proxyHost = null
16:01:51.691 [main] DEBUG si.mazi.rescu.Config - proxyPort = null
16:01:51.691 [main] DEBUG si.mazi.rescu.Config - proxyType = null
16:01:51.691 [main] DEBUG si.mazi.rescu.Config - ignoreHttpErrorCodes = false
Exception in thread "main" java.lang.NoClassDefFoundError: jakarta/ws/rs/Path
    at si.mazi.rescu.RestInvocationHandler.<init>(RestInvocationHandler.java:59)
    at si.mazi.rescu.RestProxyFactory.createProxy(RestProxyFactory.java:47)
    at si.mazi.rescu.RestProxyFactoryImpl.createProxy(RestProxyFactoryImpl.java:9)
    at org.knowm.xchange.client.ExchangeRestProxyBuilder.build(ExchangeRestProxyBuilder.java:80)
    at org.knowm.xchange.bitstamp.service.BitstampMarketDataServiceRaw.<init>(BitstampMarketDataServiceRaw.java:28)
    at org.knowm.xchange.bitstamp.service.BitstampMarketDataService.<init>(BitstampMarketDataService.java:19)
    at org.knowm.xchange.bitstamp.BitstampExchange.initServices(BitstampExchange.java:36)
    at org.knowm.xchange.BaseExchange.applySpecification(BaseExchange.java:108)
    at org.knowm.xchange.ExchangeFactory.createExchange(ExchangeFactory.java:110)
    at org.knowm.xchange.ExchangeFactory.createExchange(ExchangeFactory.java:53)
    at io.my.MainClass.main(MainClass.java:84)
Caused by: java.lang.ClassNotFoundException: jakarta.ws.rs.Path
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
    ... 11 more
pavlo-pastushok commented 6 months ago

on v5.1.0 - everything looks fine same main method output:

16:08:14.357 [main] DEBUG org.knowm.xchange.ExchangeFactory - Creating default exchange from class name
16:08:14.358 [main] DEBUG org.knowm.xchange.ExchangeFactory - Creating default exchange from class name
16:08:14.362 [main] DEBUG o.k.x.bitstamp.BitstampExchange - Loading metadata from bitstamp.json
16:08:14.569 [main] DEBUG o.k.x.bitstamp.BitstampExchange - ExchangeMetaData(instruments={}, currencies={BTC=CurrencyMetaData [scale=8, withdrawalFee=0.0005, minWithdrawalAmount=null, walletHealth=null], USD=CurrencyMetaData [scale=2, withdrawalFee=0, minWithdrawalAmount=null, walletHealth=null], EUR=CurrencyMetaData [scale=2, withdrawalFee=0, minWithdrawalAmount=null, walletHealth=null], GBP=CurrencyMetaData [scale=2, withdrawalFee=0, minWithdrawalAmount=null, walletHealth=null], XRP=CurrencyMetaData [scale=6, withdrawalFee=0.02, minWithdrawalAmount=null, walletHealth=null], LTC=CurrencyMetaData [scale=8, withdrawalFee=0.001, minWithdrawalAmount=null, walletHealth=null], ETH=CurrencyMetaData [scale=8, withdrawalFee=0.001, minWithdrawalAmount=null, walletHealth=null], BCH=CurrencyMetaData [scale=8, withdrawalFee=0.0001, minWithdrawalAmount=null, walletHealth=null], XLM=CurrencyMetaData [scale=8, withdrawalFee=0.005, minWithdrawalAmount=null, walletHealth=null], PAX=CurrencyMetaData [scale=8, withdrawalFee=20.0, minWithdrawalAmount=null, walletHealth=null], LINK=CurrencyMetaData [scale=8, withdrawalFee=1.0, minWithdrawalAmount=null, walletHealth=null], OMG=CurrencyMetaData [scale=8, withdrawalFee=3.0, minWithdrawalAmount=null, walletHealth=null], USDC=CurrencyMetaData [scale=8, withdrawalFee=20.0, minWithdrawalAmount=null, walletHealth=null], AAVE=CurrencyMetaData [scale=8, withdrawalFee=0.07, minWithdrawalAmount=null, walletHealth=null], BAT=CurrencyMetaData [scale=8, withdrawalFee=5.0, minWithdrawalAmount=null, walletHealth=null], UMA=CurrencyMetaData [scale=8, withdrawalFee=0.2, minWithdrawalAmount=null, walletHealth=null], DAI=CurrencyMetaData [scale=8, withdrawalFee=1.0, minWithdrawalAmount=null, walletHealth=null], KNC=CurrencyMetaData [scale=8, withdrawalFee=1.75, minWithdrawalAmount=null, walletHealth=null], MKR=CurrencyMetaData [scale=8, withdrawalFee=0.005, minWithdrawalAmount=null, walletHealth=null], ZRX=CurrencyMetaData [scale=8, withdrawalFee=3.0, minWithdrawalAmount=null, walletHealth=null], GUSD=CurrencyMetaData [scale=8, withdrawalFee=1.0, minWithdrawalAmount=null, walletHealth=null], ETH2=CurrencyMetaData [scale=8, withdrawalFee=0, minWithdrawalAmount=null, walletHealth=null]}, publicRateLimits=null, privateRateLimits=[RateLimit [calls=60, timeSpan=0, timeUnit=MINUTES]], shareRateLimits=true)
16:08:14.577 [main] DEBUG si.mazi.rescu.Config - Configuration from rescu.properties:
16:08:14.577 [main] DEBUG si.mazi.rescu.Config - httpConnTimeout = 30000
16:08:14.577 [main] DEBUG si.mazi.rescu.Config - httpReadTimeout = 30000
16:08:14.577 [main] DEBUG si.mazi.rescu.Config - proxyHost = null
16:08:14.577 [main] DEBUG si.mazi.rescu.Config - proxyPort = null
16:08:14.577 [main] DEBUG si.mazi.rescu.Config - proxyType = null
16:08:14.577 [main] DEBUG si.mazi.rescu.Config - ignoreHttpErrorCodes = false
16:08:14.617 [main] INFO  o.k.x.bitstamp.BitstampExchange - Calling Remote Init...
16:08:14.622 [main] DEBUG si.mazi.rescu.HttpTemplate - Executing GET request at https://www.bitstamp.net/api/v2/trading-pairs-info/
16:08:15.136 [main] DEBUG si.mazi.rescu.HttpTemplate - Request http status = 200
16:08:15.176 [main] DEBUG si.mazi.rescu.HttpTemplate - Http call returned 200; response body:
[{"name": "BTC/USD", "url_symbol": "btcusd", "base_decimals": 8, "counter_decimals": 0, "instant_order_counter_decimals": 2, "minimum_order": "10 USD", "trading": "Enabled", "instant_and_market_orders": "Enabled", "description": "Bitcoin / U.S. dollar"}, {"name": "BTC/EUR", "url_symbol": "btceur", "base_decimals": 8, "counter_decimals": 0, "instant_order_counter_decimals": 2, "minimum_order": "10 EUR", "trading": "Enabled", "instant_and_market_orders": "Enabled", "description": "Bitcoin / Euro"}, {"name": "BTC/GBP", "url_symbol": "btcgbp", "base_decimals": 8, "counter_decimals": 0, "instant_order_counter_decimals": 2, "minimum_order": "10 GBP", "trading": "Enabled", "instant_and_market_orders": "Enabled", "description": "Bitcoin / British Pound"}, {"name": "BTC/PAX", "url_symbol": "btcpax", "base_decimals": 8, "counter_decimals": 0, "instant_order_counter_decimals": 2, "minimum_order": "10 PAX", "trading": "Enabled", "instant_and_market_orders": "Enabled", "description": "Bitcoin / Paxos Standard"}, {"name": "GBP/USD", "url_symbol": "gbpusd", "base_decimals": 5, "counter_decimals": 5, "instant_order_counter_decimals": 5, "minimum_order": "10.00000 USD", "trading": "Enabled", "instant_and_market_orders": "Enabled", "description": "British Pound / U.S. dollar"}, {"name": "EUR/USD", "url_symbol": "eurusd", "base_decimals": 5, "counter_decimals": 5, "instant_order_counter_decimals": 5, "minimum_order": "10.00000 USD", "trading": "Enabled", "instant_and_market_orders": "Enabled", "description": "Euro / U.S. dollar"}, {"name": "XRP/USD", "url_symbol": "xrpusd", "base_decimals": 8, "counter_decimals": 5, "instant_order_counter_decimals": 5, "minimum_order": "10.00000 USD", "trading": "Enabled", "instant_and_market_orders": "Enabled", "description": "XRP / U.S. dollar"}, {"name": "XRP/EUR", "url_symbol": "xrpeur", "base_decimals": 8, "counter_decimals": 5, "instant_order_counter_decimals": 5, "minimum_order": "10.00000 EUR", "trading": "Enabled", "instant_and_market_orders": "Enabled", "description": "XRP / Euro"}, {"name": "XRP/BTC", "url_symbol": "xrpbtc", "base_decimals": 8, "counter_decimals": 8, "instant_order_counter_decimals": 8, "minimum_order": "0.00020000 BTC", "trading": "Enabled", "instant_and_market_orders": "Enabled", "description": "XRP / Bitcoin"}, {"name": "XRP/GBP", "url_symbol": "xrpgbp", "base_decimals": 8, "counter_decimals": 5, "instant_order_counter_decimals": 5, "minimum_order": "10.00000 GBP", "trading": "Enabled", "instant_and_market_orders": "Enabled", "description": "XRP / British Pound"}, {"name": "LTC/BTC", "url_symbol": "ltcbtc", "base_decimals": 8, "counter_decimals": 8, "instant_order_counter_decimals": 8, "minimum_order": "0.00020000 BTC", "trading": "Enabled", "instant_and_market_orders": "Enabled", "description": "Litecoin / Bitcoin"}, {"name": "LTC/USD", "url_symbol": "ltcusd", "base_decimals": 8, "counter_decimals": 2, "instant_order_counter_decimals": 2, "minimum_order": "10.00 USD", "trading": "Enabled", "instant_and_market_orders": "Enabled", "description": "Litecoin / U.S. dollar"}, {"name": "LTC/EUR", "url_symbol": "ltceur", "base_decimals": 8, "counter_decimals": 2, "instant_order_counter_decimals": 2, "minimum_order": "10.00 EUR", "trading": "Enabled", "instant_and_market_orders": "Enabled", "description": "Litecoin / Euro"}, {"name": "LTC/GBP", "url_symbol": "ltcgbp", "base_decimals": 8, "counter_decimals": 2, "instant_order_counter_decimals": 2, "minimum_order": "10.00 GBP", "trading": "Enabled", "instant_and_market_orders": "Enabled", "description": "Litecoin / British Pound"}, {"name": "ETH/BTC", "url_symbol": "ethbtc", "base_decimals": 8, "counter_decimals": 8, "instant_order_counter_decimals": 8, "minimum_order": "0.00020000 BTC", "trading": "Enabled", "instant_and_market_orders": "Enabled", "description": "Ether / Bitcoin"}, {"name": "ETH/USD", "url_symbol": "ethusd", "base_decimals": 8, "counter_decimals": 1, "instant_order_counter_decimals": 2, "minimum_order": "10.0 USD", "trading": "Enabled", "instant_and_market_orders": "Enabled", "description": "Ether / U.S. dollar"}, {"n
16:08:15.191 [main] DEBUG si.mazi.rescu.HttpTemplate - Executing GET request at https://www.bitstamp.net/api/v2/ticker/btcusd/
16:08:15.233 [main] DEBUG si.mazi.rescu.HttpTemplate - Request http status = 200
16:08:15.233 [main] DEBUG si.mazi.rescu.HttpTemplate - Http call returned 200; response body:
{"timestamp": "1705759694", "open": "41622", "high": "42152", "low": "40258", "last": "41579", "volume": "2017.55507201", "vwap": "41258", "bid": "41577", "ask": "41578", "side": "0", "open_24": "41294", "percent_change_24": "0.69"}
Ticker [instrument=BTC/USD, open=41622, last=41579, bid=41577, ask=41578, high=42152, low=40258,avg=41258, volume=2017.55507201, quoteVolume=null, timestamp=1705759694000, bidSize=null, askSize=null, percentageChange=null]

Process finished with exit code 0
bigscoop commented 6 months ago

Hi. Looks like your project uses javax packages. With PR https://github.com/knowm/XChange/pull/4735 XChange switched to jakarta ones