0

If i create JAXBContext (JAXBContext.newInstance(Abc.class)) and run this class file in my system, it works fine. But the same code throws error, when I run it as an applet, with the same JRE (and same PC). First error I get is -

javax.xml.bind.JAXBException: jaxb.properties in package com/test/package does not contain the javax.xml.bind.context.factory property.
    at javax.xml.bind.ContextFinder.find(Unknown Source)
    at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
    at javax.xml.bind.JAXBContext.newInstance(Unknown Source)

If I add a jaxb.properties in the package com/test/package, I get another error. This time it is -

javax.xml.bind.JAXBException
 - with linked exception:
[java.lang.NoSuchMethodException: com.sun.xml.internal.ws.developer.JAXBContextFactory.createContext([Ljava.lang.Class;, java.util.Map)]
    at javax.xml.bind.ContextFinder.newInstance(Unknown Source)
    at javax.xml.bind.ContextFinder.newInstance(Unknown Source)
    at javax.xml.bind.ContextFinder.find(Unknown Source)
    at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
    at javax.xml.bind.JAXBContext.newInstance(Unknown Source)

jaxb.properties contents -

javax.xml.bind.context.factory=com.sun.xml.internal.ws.developer.JAXBContextFactory

I have tried changing java version too. What might be possible cause of this error.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Acn
  • 1,010
  • 2
  • 11
  • 22
  • Are you *sure* you are running the same JRE? Check which JRE your browser is using here: http://javatester.org/version.html – Andreas Aug 29 '15 at 19:57
  • You tagged your question both `applet` and `java-web-start`, but those are not the same. Which is it? – Andreas Aug 29 '15 at 20:00
  • @Andreas it is a java applet, and java version i tested is same. – Acn Aug 29 '15 at 20:07
  • Which Java version is that? – Andreas Aug 29 '15 at 21:33
  • possible duplicate of [How can I use JAXB from an unsigned applet (without signing it)?](http://stackoverflow.com/questions/2084391/how-can-i-use-jaxb-from-an-unsigned-applet-without-signing-it) – Andreas Aug 29 '15 at 21:35
  • @Andreas *"You tagged your question both applet and java-web-start, but those are not the same. Which is it?"* No, they are not the same, but JWS can **deploy** applets. JWS has been able to do that since it was first introduced. OP - Be sure to check the JNLP using JaNeLA, available at my [share drive](https://drive.google.com/drive/#folders/0B5B9wDXIGw9lUnJaUjA2cmlVRE0). – Andrew Thompson Aug 30 '15 at 13:16
  • I have explained answer to your question in this [post][1]. [1]: http://stackoverflow.com/questions/32268883/jaxbexception-on-creating-jaxb-context/32334379 – ag112 Sep 01 '15 at 14:53

0 Answers0