'Handshake' not known in JAXB context

Issue #69 closed
Former user created an issue

Hi,

I'm trying to create a Component however on first connect/login in throws an exception:

rocks.xmpp.core.XmppException: javax.xml.bind.JAXBException: class rocks.xmpp.extensions.component.accept.model.Handshake nor any of its super class is known to this context.
    at rocks.xmpp.core.session.XmppSession.throwAsXmppExceptionIfNotNull(XmppSession.java:232)
    at rocks.xmpp.extensions.component.accept.ExternalComponent.login(ExternalComponent.java:145)
    at rocks.xmpp.extensions.component.accept.ExternalComponent.connect(ExternalComponent.java:119)
    at rocks.xmpp.core.session.XmppSession.connect(XmppSession.java:248)
    at eu.siacs.formserver.Component.main(Component.java:13)
Caused by: javax.xml.bind.JAXBException: class rocks.xmpp.extensions.component.accept.model.Handshake nor any of its super class is known to this context.
    at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:567)
    at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:467)
    at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:308)
    at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:163)
    at rocks.xmpp.core.session.XmppStreamWriter.lambda$send$18(XmppStreamWriter.java:112)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

I'm able to work around that by adding Handshake manually to the JAXB Context like this:

XmppSessionConfiguration configuration = XmppSessionConfiguration.builder().extensions(Extension.of(Handshake.class)).build();

and passing this to the ExternalComponent constructor.

Comments (7)

  1. Christian Schudt repo owner

    Do you have the source code imported directly into your IDE? I've seen similar issues as well, but only when not using the jar files.

    It uses java.util.ServiceLoader to locate elements. If Handshake is not found, then likely all others won't be found as well. See class ExtensionModule.

    Unfortunately I am not sure, how to tell the IDE to resolve these via ServiceLoader semantics. (it should look at META-INF/services/rocks.xmpp.core.session.Module).

  2. Daniel Gultsch

    Oh ok. I had a look into how Babbler is initially adding classes to the context and it does so by looking at the class path. - Which doesn't seem to work if you create fat jars...

  3. Christian Schudt repo owner

    I've only saw this issue once, on one machine using IntelliJ. Then later, it was gone again. I thought it was a bad setup or IntelliJ bug maybe.

  4. Christian Schudt repo owner

    Ah... not sure how you built it ;-) I went through this as well...

    See xmpp-documentation/pom.xml, which builds an assembled jar file. (=> org.apache.maven.plugins.shade.resource.ServicesResourceTransformer)

    maybe it helps.

  5. Log in to comment