Java xml bind exceptions

5
Hello Community, I'm have a java app which consumes webservices from a provider who mainly deals with xsd, oauth and has custom types in their xsd. The Java App works perfectly well. However in mendix I get this bug whenever I try to use the jar generated from the java project. How can I get around this. I'm using mendix 5.5.0 -> javax.xml.bind.JAXBException - with linked exception: [java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory not found by com.typesafe.akka.osgi [26]] at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:241) at javax.xml.bind.ContextFinder.find(ContextFinder.java:455) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:652) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:599) at com.rossjourdain.util.xero.XeroXmlManager.contactsToXml(XeroXmlManager.java:112) at com.rossjourdain.util.xero.XeroClient.postContacts(XeroClient.java:110) at bookshop.actions.NewContact.executeAction(NewContact.java:153) at bookshop.actions.NewContact.executeAction(NewContact.java:38) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:53) at com.mendix.core.actionmanagement.CoreAction.doCall(SourceFile:291) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:276) at com.mendix.core.actionmanagement.ActionManager.executeSync(SourceFile:205) at com.mendix.core.component.InternalCore.execute(SourceFile:259) at com.mendix.hs.execute(SourceFile:42) at com.mendix.ib.a(SourceFile:47) at com.mendix.ia.a(SourceFile:193) at com.mendix.ia.executeAction(SourceFile:148) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:53) at com.mendix.core.actionmanagement.CoreAction.doCall(SourceFile:291) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:276) at com.mendix.core.actionmanagement.ActionManager.executeSync(SourceFile:205) at com.mendix.core.component.InternalCore.execute(SourceFile:259) at com.mendix.iO.a(SourceFile:135) at com.mendix.pa$g.apply$mcV$sp(SourceFile:292) at com.mendix.pa$g.apply(SourceFile:283) at com.mendix.pa$g.apply(SourceFile:283) at com.mendix.core.session.Worker$$anonfun$receive$3$$anonfun$2.apply(SourceFile:148) at scala.util.Try$.apply(Try.scala:161) at com.mendix.core.session.Worker$$anonfun$receive$3.applyOrElse(SourceFile:146) at akka.actor.ActorCell.receiveMessage(ActorCell.scala:498) at akka.actor.ActorCell.invoke(ActorCell.scala:456) at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:237) at akka.dispatch.Mailbox.run(Mailbox.scala:219) at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:386) at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) Caused by: java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory not found by com.typesafe.akka.osgi [26] at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532) at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75) at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955) at java.lang.ClassLoader.loadClass(Unknown Source) at javax.xml.bind.ContextFinder.safeLoadClass(ContextFinder.java:573) at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:239) ... 37 more javax.xml.bind.JAXBException - with linked exception: [java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory not found by com.typesafe.akka.osgi [26]] at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:241) at javax.xml.bind.ContextFinder.find(ContextFinder.java:455) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:652) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:599) at com.rossjourdain.util.xero.XeroXmlManager.xmlToException(XeroXmlManager.java:79) at com.rossjourdain.util.xero.XeroClientException.<init>(XeroClientException.java:50) at com.rossjourdain.util.xero.XeroClient.postContacts(XeroClient.java:115) at bookshop.actions.NewContact.executeAction(NewContact.java:153) at bookshop.actions.NewContact.executeAction(NewContact.java:38) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:53) at com.mendix.core.actionmanagement.CoreAction.doCall(SourceFile:291) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:276) at com.mendix.core.actionmanagement.ActionManager.executeSync(SourceFile:205) at com.mendix.core.component.InternalCore.execute(SourceFile:259) at com.mendix.hs.execute(SourceFile:42) at com.mendix.ib.a(SourceFile:47) at com.mendix.ia.a(SourceFile:193) at com.mendix.ia.executeAction(SourceFile:148) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:53) at com.mendix.core.actionmanagement.CoreAction.doCall(SourceFile:291) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:276) at com.mendix.core.actionmanagement.ActionManager.executeSync(SourceFile:205) at com.mendix.core.component.InternalCore.execute(SourceFile:259) at com.mendix.iO.a(SourceFile:135) at com.mendix.pa$g.apply$mcV$sp(SourceFile:292) at com.mendix.pa$g.apply(SourceFile:283) at com.mendix.pa$g.apply(SourceFile:283) at com.mendix.core.session.Worker$$anonfun$receive$3$$anonfun$2.apply(SourceFile:148) at scala.util.Try$.apply(Try.scala:161) at com.mendix.core.session.Worker$$anonfun$receive$3.applyOrElse(SourceFile:146) at akka.actor.ActorCell.receiveMessage(ActorCell.scala:498) at akka.actor.ActorCell.invoke(ActorCell.scala:456) at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:237) at akka.dispatch.Mailbox.run(Mailbox.scala:219) at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:386) at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) Caused by: java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory not found by com.typesafe.akka.osgi [26] at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532) at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75) at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955) at java.lang.ClassLoader.loadClass(Unknown Source) at javax.xml.bind.ContextFinder.safeLoadClass(ContextFinder.java:573) at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:239) ... 38 more It fails at this line: JAXBContext context = JAXBContext.newInstance(ResponseType.class);
asked
1 answers
0

Try something like this : JAXBContext context = JAXBContext.newInstance(ResponseType.class.getPackage().getName(), ResponseType.class.getClassLoader());

I had a similar issue since upgrading to Mendix 5. Being more specific did the trick for me.

answered