Troubleshooting

Exception

When invoking a REST service and getting a response with an embeded stacktrace like:

{
	"httpStatusCode": 500,
	"message": "com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
Klasse enthält zwei Eigenschaften mit demselben Namen \"name\"
	this problem is related to the following location:
		at public java.lang.String ife.dep.ServiceName.getName()
		at ife.dep.ServiceName
		at public ife.dep.ServiceName ife.dep.ProvidedService.getServiceName()
		at ife.dep.ProvidedService
		at public java.util.SortedSet ife.dep.Release.getCapabilities()
		at ife.dep.Release
		at public ife.dep.Release ife.cfg.Configuration.getRelease()
		at ife.cfg.Configuration
		at public ife.cfg.Configuration ife.cfg.ConfigEntry.getConfiguration()
		at ife.cfg.ConfigEntry
		at public java.util.SortedSet ife.cfg.Endpoint.getCfgEntries()
		at ife.cfg.Endpoint
	this problem is related to the following location:
		at public java.lang.String ife.dep.ServiceName.name
		at ife.dep.ServiceName
		at public ife.dep.ServiceName ife.dep.ProvidedService.getServiceName()
		at ife.dep.ProvidedService
		at public java.util.SortedSet ife.dep.Release.getCapabilities()
		at ife.dep.Release
		at public ife.dep.Release ife.cfg.Configuration.getRelease()
		at ife.cfg.Configuration
		at public ife.cfg.Configuration ife.cfg.ConfigEntry.getConfiguration()
		at ife.cfg.ConfigEntry
		at public java.util.SortedSet ife.cfg.Endpoint.getCfgEntries()
		at ife.cfg.Endpoint
",
[...]
}

Solution

Add @XmlAccessorType(XmlAccessType.FIELD) to your domain entity:

@javax.jdo.annotations.PersistenceCapable(identityType = IdentityType.DATASTORE)
@javax.jdo.annotations.DatastoreIdentity(strategy = javax.jdo.annotations.IdGeneratorStrategy.NATIVE, column = "id")
@javax.jdo.annotations.Version(strategy = VersionStrategy.VERSION_NUMBER, column = "version")
@Named("xxx.ServiceName")
@DomainObject(bounded = true)
@DomainObjectLayout(cssClassFa = "tag", describedAs = "")
@XmlAccessorType(XmlAccessType.FIELD)
@SuppressWarnings("javadoc")
public class ServiceName implements Capability, Comparable<ServiceName> {

	public String title() {
		return getName();
	}

	public int compareTo(ServiceName o) {
		return name.compareTo(o.name);
	}

	@Override
	public String toString() {
		return title();
	}

	@javax.jdo.annotations.Column(allowsNull = "false")
	@Getter	@Setter
	public String name;

	public boolean isSynchronous() {
		return !isAsynchonous();
	}

	public boolean isAsynchonous() {
		return name.startsWith(Constants.ESB_JMS_PREFIX);
	}
}