Based on your information provided, here are my inputs. Please note anything which require your input/you-to-try-out, I have marked it as <try-out>
.
Firstly <try-out>
following:
a. Verify you don't see multiple java versions as checked inside: widnows-> control panel->java->java tab->view java locations. Basically this is to ensure your java application and applet using same JRE.
Regarding your first exception : javax.xml.bind.JAXBException: jaxb.properties in package com/test/package does not contain the javax.xml.bind.context.factory property
This is problem of JRE not able to locate an JAXB implementation. Please go through the URL and locate section "Discovery of JAXB implementation".
It mentions that following 4 locations are used to identify JAXB implementation:
- Finding jaxb.properties at package level directory
- System property JAXB_CONTEXT_FACTORY
- Looking for /META-INF/services/javax.xml.bind.JAXBContext file in all jars
- Default JVM specific implementation.
Now you are getting this exception only in case of Applet NOT for JAVA application. You mentioned that both java application and applet are using same JDK + additional jars. Only reason I can think of difference between applet and application environment could be due to point 2 above.
<try-out>
following:
b.Can you check if you are specifying JAXB_CONTEXT_FACTORY as system property when you run java application (perhaps through eclipse or something)
c. May be you can print all system properties in your code:
Properties props = System.getProperties();
props.list(System.out);
and verify if JAXB context factory is set there or not?
Regarding your second exception :
after you added jaxb.properties file, you received your second exception. It could be due to following reason:-
exception stack trace shows you might have specified com.sun.xml.internal.ws.developer.JAXBContextFactory
in JAXB.properties
file.
Now if you see again URL and locate first SPEC REQUIREMENT for JAXBContext provider: the provider must supply an implementation class containing the following method signatures:
public static JAXBContext createContext( Class[] classes, Map<String,Object> properties ) throws JAXBException
Further Now if you google content of com.sun.xml.internal.ws.developer.JAXBContextFactory
class, you can see at this site that this class does NOT contain the method createConext()
; it only define a method call createJAXBContext(
). Please note this class is internally called by com.sun.xml.internal.bind.api.JAXBRIContext
which extension of javax.xml.bind.JAXBContext
class.
<try-out>
following:
d. you should specify a proper value of javax.xml.bind.context.factory
in jaxb.properties
file which point to a class implementing createConext()
operation.
Finally, last point :
There is possiblity that you are specifying correct factory in jaxb.properties
but its value might not be picked by runtime and instead runtime is picking JAXB implementation value from other mechanisms specified in points 1-4 above. This can be case of multiple JAXB factory implementations present in JVM runtime.
<try-out>
following:
e. In such situations, best to use Java endorsed override mechanism as specified in this post