0

i have an issue which slowly starts driving me nuts, so any help would be really appreciated. I am using Talend ESB (based on ServiceMix and Camel). In one of my routes, i need to send files through a webservice using MTOM. I use the camel-cxf component with jaxb-binding for that. Somehow i absolutely can't get that to work. The Exception i get is:

com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
javax.activation.DataHandler does not have a no-arg default constructor.

I understand that this is because the JAXB-Marshaller needs a no-arg constructor (even thought i only marshal, never unmarshal), but i just don't know what to do about it. Tried to write my own CustomDataHandler by extending on javax.activation.DataHandler, so the exception was gone, but the file was not transferred at all. Also tried using an XML-Adapter like descriped here, didn't work either. I even ended up building a jar-project in eclipse for that and used maven-assembly-plugin to bundle all dependencies. That JAR is used in my route. It's working fine in Eclipse or in a webproject that i created out of pure desperation to prove that the JAR-content is finde. But i can't get it to work in the Talend/Karaf-container, whatever i do.

Here is the relevant mapping:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "document")
public class Document {
    @XmlElement(required = true)
    @XmlMimeType("application/octet-stream")
    private DataHandler dataHandler;
...

Nearly forgot one more thing: it's working fine in the Talend Studio as well. "Just" not in the runtime container. Any idea what i can do about this or how i can work around it? Thanks in advance!

Community
  • 1
  • 1
Mario B
  • 2,102
  • 2
  • 29
  • 41
  • The fact that it does not work in the runtime container may point to JDK comatibility/version/classpath problem. Maybe you have an older JDK on the server? Or some JARs are missing? Try to single out, what the difference is. – lexicore Oct 06 '14 at 20:11
  • Thanks for your comment. Cant find any difference unfortunately. Java version, operating system - everything seems to be the same. – Mario B Oct 07 '14 at 12:54

1 Answers1

0

I resolved this. The problem was, that i deployed a JAR-dependency with my bundle that was also already present in the OSGI-Container. I guess this resulted in some ClassLoader-issues. The Exception was misleading, but in the end all i had to do was changing the dependency to "provided" in my pom.xml

Mario B
  • 2,102
  • 2
  • 29
  • 41