JDK-8177705 : Java WebStart throws ClassNotFoundException when attempting to link to JAXB type
  • Type: Bug
  • Component: deploy
  • Sub-Component: webstart
  • Affected Version: 9
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: windows_7
  • CPU: x86_64
  • Submitted: 2017-03-24
  • Updated: 2019-12-04
  • Resolved: 2017-03-31
Related Reports
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "9-ea"
Java(TM) SE Runtime Environment (build 9-ea+161)
Java HotSpot(TM) 64-Bit Server VM (build 9-ea+161, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Windows 7 Professional Edition 64 bit

A DESCRIPTION OF THE PROBLEM :
When launching my application with javaws I got the exception:

java.lang.NoClassDefFoundError: javax/xml/bind/JAXBContext
	at cin.confirma.applet.managers.EnvironmentManager.getTokenEnvironment(EnvironmentManager.java:126)
	at cin.confirma.jws.configuration.Initializer.initializeApplication(Initializer.java:150)
	at cin.confirma.jws.SignerJWS.main(SignerJWS.java:48)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at jdk.javaws@9-ea/com.sun.javaws.Launcher.executeApplication(Unknown Source)
	at jdk.javaws@9-ea/com.sun.javaws.Launcher.executeMainClass(Unknown Source)
	at jdk.javaws@9-ea/com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
	at jdk.javaws@9-ea/com.sun.javaws.Launcher.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBContext
	at jdk.deploy@9-ea/com.sun.deploy.security.DeployURLClassLoader.findClass(Unknown Source)
	at jdk.javaws@9-ea/com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
	at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
	at jdk.javaws@9-ea/com.sun.jnlp.JNLPClassLoader.loadClass(Unknown Source)
	at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
	... 12 more
mar 24, 2017 11:17:45 AM cin.confirma.jws.configuration.Initializer initializationError
GRAVE: javax/xml/bind/JAXBContext
java.lang.NoClassDefFoundError: javax/xml/bind/JAXBContext
	at cin.confirma.applet.managers.EnvironmentManager.getTokenEnvironment(EnvironmentManager.java:126)
	at cin.confirma.jws.configuration.Initializer.initializeApplication(Initializer.java:150)
	at cin.confirma.jws.SignerJWS.main(SignerJWS.java:48)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at jdk.javaws@9-ea/com.sun.javaws.Launcher.executeApplication(Unknown Source)
	at jdk.javaws@9-ea/com.sun.javaws.Launcher.executeMainClass(Unknown Source)
	at jdk.javaws@9-ea/com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
	at jdk.javaws@9-ea/com.sun.javaws.Launcher.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBContext
	at jdk.deploy@9-ea/com.sun.deploy.security.DeployURLClassLoader.findClass(Unknown Source)
	at jdk.javaws@9-ea/com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
	at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
	at jdk.javaws@9-ea/com.sun.jnlp.JNLPClassLoader.loadClass(Unknown Source)
	at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
	... 12 more

I have added in jnlp file:
...
<j2se version="1.6+" java-vm-args="--add-modules java.xml.bind"/>
...

but still not working, while similar code launched with java and same arg doesn't result in any Issue

I found an old Bug indicating a very similar problem:

http://bugs.java.com/view_bug.do?bug_id=8152839

Could it be a Regression case? 

Thanks for yout attention


REGRESSION.  Last worked in version 8u121

ADDITIONAL REGRESSION INFORMATION: 
I didn't check in other early access versions for java 9

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Should start as webstart code like this:

import javax.xml.bind.JAXBContext; 
import javax.xml.bind.JAXBException;

public class Test { 
        public static void main(String[] args) { 
                try {
					JAXBContext.newInstance("NotExistent.class");
				} catch (JAXBException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} 
        } 
} 

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
javax.xml.bind.JAXBException: "NotExistent.class" non contiene ObjectFactory.class o jaxb.index
        at java.xml.bind@9-ea/com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown Source)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at java.xml.bind@9-ea/javax.xml.bind.ContextFinder.newInstance(Unknown Source)
        at java.xml.bind@9-ea/javax.xml.bind.ContextFinder.newInstance(Unknown Source)
        at java.xml.bind@9-ea/javax.xml.bind.ContextFinder.find(Unknown Source)
        at java.xml.bind@9-ea/javax.xml.bind.JAXBContext.newInstance(Unknown Source)
        at java.xml.bind@9-ea/javax.xml.bind.JAXBContext.newInstance(Unknown Source)
        at java.xml.bind@9-ea/javax.xml.bind.JAXBContext.newInstance(Unknown Source)
        at it.test.Test.main(Test.java:8)
ACTUAL -
java.lang.NoClassDefFoundError: javax/xml/bind/JAXBContext

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.xml.bind.JAXBContext; 
import javax.xml.bind.JAXBException;

public class Test { 
        public static void main(String[] args) { 
                try {
					JAXBContext.newInstance("NotExistent.class");
				} catch (JAXBException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} 
        } 
} 
---------- END SOURCE ----------


Comments
Closing this as not an issue, post submitter confirmation: =================================================== Yes working with current jdk, but not needed there additional jvm parameter "--add-modules". As reported in https://bugs.openjdk.java.net/browse/JDK-8166438, while jvm arguments passed to java command could be passed as: -argName argValue or -argname=argValue In jnlp file for java-vm-args="..." only the second type is admidted! Using java-vm-args="--add-modules=java.xml.bind" I resolved my Issue (pratically 'not a Bug'). So that I think you can close the Issue with these considerations. ====================================================
31-03-2017

From the description it seems related to JDK-8152839 which is fixed in 9 ea b116. However, submitter has passed jvm arguments as java-vm-args="--add-modules java.xml.bind" and is failing apprently. According to JDK-8166438, only "--add-modules=" will be a secure vm arg prefix and "--add-modules " (with space) is not considered secure therefore failing. This can be closed as not an issue, however written back to the submitter for rechecking and respond back.
28-03-2017