This case applies to the JBXB annotations based injection.
Consider the following xml bit:
<application-policy>
<authentication>
......
</authentication>
<enhanced-authentication>
.....
</enhanced-authentication>
</application-policy>
and we have modeled the objects as follows:
public class Authentication extends BaseAuthentication
public class EnhancedAuthentication extends BaseAuthentication
and my root object has a single method as follows:
public class ApplicationPolicy
{
public void add(BaseAuthentication ba)
}
This will not work because the Unmarshaller framework still expects two distinct add methods in the root object as follows:
public void add(Authentication ba)
public void add(EnhancedAuthentication ea)
The stack trace is as follows:
Caused by: org.jboss.xb.binding.JBossXBRuntimeException: Failed to find addMethod.name=add, addMethod.valueType=Authentication in class ApplicationPolicy: org.jboss.xb.binding.sunday.unmarshalling.impl.runtime.RtElementHandler.invokeAdd(RtElementHandler.java:1157)
at org.jboss.xb.binding.sunday.unmarshalling.impl.runtime.RtElementHandler.setParent(RtElementHandler.java:266)
at org.jboss.xb.binding.sunday.unmarshalling.SundayContentHandler.endElement(SundayContentHandler.java:581)
at
This is a minor fix in the following code:
org.jboss.xb.binding.sunday.unmarshalling.impl.runtime.RtElementHandler
Class ownerClass = owner.getClass();
Method addMethod;
try
{
addMethod = ownerClass.getMethod(addMethodMetaData.getMethodName(), new Class[]{valueType});
}
catch(NoSuchMethodException e)
{
throw new JBossXBRuntimeException("Failed to find addMethod.name=" +
addMethodMetaData.getMethodName() +
", addMethod.valueType=" +
valueType.getName() +
" in class " +
ownerClass.getName() +
": " +
e.getMessage(), e
);
}
If there is no objecttion, I am going to create a JIRA entry and add this fix.