I am new to JiBX and I get a "No marshaller for element ..."-exception, when I
unmarshall an xml file. I do not define namespaces in the xml or the mapping.
When I change all type references to iImpl in class A from interface I to
implementation class B, then it's working, but obviously, that's not what I
want.
Below my Java classes:
/**
* A marker interface; no methods defined
*/
public interface I { }
/**
* This class does not know the implementation of it's field I
*/
public class A {
private I iImpl = null;
public I getI() {
return iImpl;
}
public void setI(I iImpl) {
this.iImpl = iImpl;
}
}
/**
* One of the possible implementations of interface I
*/
public class B implements I {
private String c = null;
public B() {}
public B(String c) {
setC(c);
}
public String getC() {
return this.c;
}
private void setC(String c) {
if (c == null) {
throw new IllegalArgumentException("c is mandatory");
}
this.c = c;
}
}
My mapping file:
<binding>
<mapping name="Aaaa" class="A">
<structure name="Bbbb" get-method="getI" set-method="setI"
create-type="B"/>
</mapping>
<mapping abstract="true" class="B">
<value name="Cccc" field="c" set-method="setC"/>
</mapping>
</binding>
My xml snippet
<Aaaa>
<Bbbb>
<Cccc>1</Cccc>
</Bbbb>
</Aaaa>
The stacktrace:
org.jibx.runtime.JiBXException: No unmarshaller for element "Cccc" (line 4, col
11)
at
org.jibx.runtime.impl.UnmarshallingContext.unmarshalElement(UnmarshallingContext.java:2754)
at
my.pack.JiBX_binding_AInterfaceMungeAdapter.JiBX_binding_AInterface_unmarshal_1_0()
at
my.pack.AInterfaceField.JiBX_binding_AInterface_unmarshal_1_0(AInterfaceField.java)
at my.pack.JiBX_binding_AInterfaceAInterfaceField_access.unmarshal()
at
org.jibx.runtime.impl.UnmarshallingContext.unmarshalElement(UnmarshallingContext.java:2757)
at
org.jibx.runtime.impl.UnmarshallingContext.unmarshalDocument(UnmarshallingContext.java:2900)
at
my.pack.AInterfaceDatabindingTest.testUnmarshallAInterface(AInterfaceDatabindingTest.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at
org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Can somebody please tell me what I am doing wrong?
Thanks in advance,
Dave
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users