问题
I am using Java eBay SDK, and I am trying to call addItem
API, I added eBay maven dependency and repository and wrote a simple application that adds a new Item
. The main is as shown below:
public static void main(String[] args) {
App aai = new App();
try {
ItemType item = aai.buildItem();
FeesType fees;
AddItemCall call = new AddItemCall(aai.apiContext);
call.setItem(item);
call.setAutoSetItemUUID(true);
fees = call.addItem();
} catch (Exception e) {
e.printStackTrace();
}
}
I keep getting this error that i couldn't fix:
[main] INFO com.ebay.sdk.SdkAPIInterfaceServiceLocator - loading wsdl : jar:file:/home/mss/.m2/repository/ebaysdkcore/ebaysdkcore/943/ebaysdkcore-943.jar!/eBaySvc.wsdl
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class com.ebay.sdk.SdkAPIInterfaceServiceLocator
at com.ebay.sdk.ApiCall.executeByApiName(ApiCall.java:594)
at com.ebay.sdk.ApiCall.execute(ApiCall.java:348)
at com.ebay.sdk.call.AddItemCall.addItem(AddItemCall.java:162)
at org.ecommerce_eBay.App.main(App.java:38)
Does anyone have any idea about it? Thank you !
回答1:
I had the same error with Java 11. Just add the following dependencies into the maven file:
<dependency>
<groupId>com.ebay</groupId>
<artifactId>ebaysdkcore</artifactId>
<version>1055</version>
<version>1085</version>
</dependency>
<dependency>
<groupId>com.ebay</groupId>
<artifactId>ebaycalls</artifactId>
<version>1055</version>
<version>1085</version>
</dependency>
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>rt</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-ri</artifactId>
<version>2.3.2</version>
<type>pom</type>
</dependency>
Java 11 dont have the com.sun.xml.ws dependencies anymore -> Therefore, we need to add them explicitly.
Hope it helps!
来源:https://stackoverflow.com/questions/53758696/could-not-initialize-class-com-ebay-sdk-sdkapiinterfaceservicelocator-java