CI/CD/DevOps
Published in

CI/CD/DevOps

Exception in thread “main” java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema

a ridiculous debugging story

while trying to install Android Studio headlessly on my Mac, I bumped into the commonly seen *license not accepted* problem, so I googled and tried to batch accept all the license with

yes | sudo sdkmanager --licenses

and I got

Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:606)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:168)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 5 more

after googling around for very long time, and installing/uninstalling JDK8 a few times, I realized that my JAVA_HOME wasn’t set for root users, and that is the simple reason for the above; so the answer is ridiculous simple — I shouldn’t have used the sudo at all.

yes |  sdkmanager --licenses
.................................
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: java.io.FileNotFoundException: https://dl.google.com/android/repository/sys-img/android-desktop/sys-img2-1.xml
All SDK package licenses accepted.======] 100% Computing updates...

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Shi

Shi

25 Followers

I am a coder/engineer/application security specialist. I like to play around with language and tools; I have strong interest in efficiency improvement.