2

I am having an issue upgrading my code from Java 8 to Java 11.

I have a spring boot application, the app is packaged as a fat jar. The app also depends on ebay api, which is packaged in ebay-sdk-core-1131.jar file.

The above configuration works fine in Oracle Java 8. Now I am trying to use zulu open JDK 11, I got this exception:

[INFO ] 2020-12-28 12:41:34.997 [ForkJoinPool-1-worker-3] SdkAPIInterfaceServiceLocator - loading wsdl : jar:file:/home/my-application-1.0.jar!/BOOT-INF/lib/ebay-sdk-core-1131.jar!/eBaySvc.wsdl
[ERROR] 2020-12-28 12:41:35.003 [ForkJoinPool-1-worker-3] ApiCall - java.lang.NullPointerException

In fact I have other wsdl files in other dependency libs, they all failed to load in Java 11. They are all OK in Java 8.

This will throw NPE in java 11, but not java 8 (run as fat jar):

import org.springframework.core.io.ClassPathResource;
ClassPathResource cp = new ClassPathResource("/wsdl/wsdl.xml");

Spring boot is at 2.3.7.RELEASE.

Any ideas?

Update:

Forgot to mention the above was running from a docker container.

If I run it locally on my dev machine, (not fat spring jar, instead file system), and it works:

[INFO ] 2020-12-28 09:04:03.153 [ForkJoinPool-1-worker-3] SdkAPIInterfaceServiceLocator - loading wsdl : jar:file:/home/me/work/git/app/app-dao.jar/libs/ebay-sdk-core-1131.jar!/eBaySvc.wsdl

[INFO ] 2020-12-28 09:04:26.127 [ForkJoinPool-1-worker-3] SdkAPIInterfaceServiceLocator - wsdl loaded and service initialized.

Update 2:

More logs:

com.ebay.sdk.SdkException: ApiCall.execute() - null
        at com.ebay.sdk.ApiCall.executeByApiName(Unknown Source) ~[ebay-sdk-core-1131.jar!/:?]
        at com.ebay.sdk.ApiCall.execute(Unknown Source) ~[ebay-sdk-core-1131.jar!/:?]
        at com.ebay.sdk.call.GetOrdersCall.getOrders(GetOrdersCall.java:169) ~[ebay-sdk-calls-1131.jar!/:?]
        at com.company.job.tasks.ebay.EBaySalesList.load(EBaySalesList.java:119) [classes!/:?]

Thanks

João Dias
  • 16,277
  • 6
  • 33
  • 45
The MW
  • 401
  • 4
  • 15
  • 1
    JAXB was removed from JAVA 11. You need to add several libraries to work with XML. Try [this example](https://www.dariawan.com/tutorials/java/using-jaxb-java-11/) – Edgar Khachatryan Dec 28 '20 at 13:02
  • Thanks @EdgarKhachatryan But I don't think I am there yet, the first problem I need to fix it the above error, java failed to load the wsdl file inside the ebay jar file. After that, the jaxb kicks in. – The MW Dec 28 '20 at 13:05
  • @EdgarKhachatryan Thanks, I think maybe your are right, I saw ebay source code has a check of null, so the NPE probably is not what I was thinking, I will look into the link you pasted, thanks! – The MW Dec 28 '20 at 13:14
  • I looked at your question once again and I was mistaken, just adding jaxb dependencies will not help you. I'll suggest you look at [this](https://stackoverflow.com/a/52865705/10806427) answer for using JAXWS in java 11. [and this](https://stackoverflow.com/questions/53266846/replacement-for-wsimport-with-jdk-11) question. Hope it will help. – Edgar Khachatryan Dec 28 '20 at 13:52
  • Thanks @EdgarKhachatryan Funny thing is, I tried it on my dev machine (without changing any dependencies) and it works. See update in the mail post above. – The MW Dec 28 '20 at 14:09
  • @EdgarKhachatryan tried you suggested link (added more dependencies), still NPE. – The MW Dec 28 '20 at 14:46
  • This looks strange. Did you try to change the log level to DEBUG to see any Exception stack trace for your NPE? This should be helpful. EDIT: Since it is running outside of a container, are there any possible restrictions to read that file? How do you build your image, do you use a "normal" Dockerfile or do you use the Spring-Boot Docker-Plugin? – O. Schnieders Dec 28 '20 at 16:26
  • @Maximus I have more log, please see the main post. Running outside of container in my dev env it works. I don't think there are retractions. I have been using the same Docker file for a while, same dockerfile (use oracle java 8 works) but not java 11. – The MW Dec 28 '20 at 18:33
  • Ok. I took a short research about the related ApiCall class and found a little older implementation on GitHub: https://github.com/prestonvanloon/ebaysdkcore/blob/master/src/main/java/com/ebay/sdk/ApiCall.java. It looks like that the API itself does not talk enough to us. I am out at this point, because I am not familiar enough with the eBay API. Did you took a look at this post? https://stackoverflow.com/questions/53758696/could-not-initialize-class-com-ebay-sdk-sdkapiinterfaceservicelocator-java. Maybe the solution is the same. – O. Schnieders Dec 28 '20 at 18:51
  • @Maximus thanks yes I looked at the post and I already added these referenced dependencies. Now I am wondering if this has anything to do with classloading and java 9+ modules? – The MW Dec 28 '20 at 19:01
  • @TheMW Unfortunately I am also not familiar with ebay sdk, just want to make sure that you did not miss anything, please look [at Development Requirements 3rd option](https://developer.ebay.com/devZone/javasdk-jaxb/docs/readme.htm#DevelopmentRequirements) maybe you need to add libraries not in the classpath, but in another place? It is also from ebay sdk docs `You must compile the SDK with version 2.1.4 of Sun JAX-WS RI.` -> [Maven Repo](https://mvnrepository.com/artifact/com.sun.xml.ws/jaxws-rt/2.1.4) , Hope it will help, share your answer when you will find it) – Edgar Khachatryan Dec 29 '20 at 20:38
  • 1
    @EdgarKhachatryan sorry for my late reply. I decided to not use ebay jar file, will generate my own classes so I can completely remove xalan as dependency. Thanks! – The MW Jan 05 '21 at 19:50

0 Answers0