javarestjpaglassfisheclipselink

EclipseLink: Missing class for indicator field value of typ


My application runs on Payara and provides a REST API but when I try to create an object with a POST request I get the following exception:

Exception [EclipseLink-43] (Eclipse Persistence Services - 2.6.0.payara-p1): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: Missing class for indicator field value [Miss] of type [class java.lang.String].
Descriptor: XMLDescriptor(at.htl.handballinheritance.entity.Throw --> [DatabaseTable(event), DatabaseTable(dataObject)])
  at org.eclipse.persistence.exceptions.DescriptorException.missingClassForIndicatorFieldValue(DescriptorException.java:940)
  at org.eclipse.persistence.internal.oxm.QNameInheritancePolicy.classFromRow(QNameInheritancePolicy.java:278)
  ...

Full Stacktrace

On the contrary everything is fine and no errors occur when I am executing the program on Wildfly which uses Hibernate.

Entities:

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@XmlRootElement
public abstract class Event extends DataObject implements Serializable {
    ... 
}

@Entity
public class Throw extends Event implements Serializable {

    @Enumerated(EnumType.STRING)
    @NotNull
    private ThrowingType type;

    ...
}

public enum ThrowingType {
    Goal, Miss
}

REST API:

@POST
public Response create(Throw entity) {
    em.persist(entity);
    return Response.created(URI.create("...")).build();
}

I think that Eclipselink has problems to unmarshal my json. Do I need any additional annotation?


Solution

  • Joined inheritance will by default use a 'type' field to determine the entity class to use, as does json/xml marshalling. You have a type field, but populated it with "Miss' which can't be converted to a class.

    See eclipselink/Moxy : inheritance and attribute name oveloading based on type for custom strategies or https://www.eclipse.org/eclipselink/documentation/2.4/moxy/type_level003.htm if you can change the JSON being posted.

    The type field within JPA is somewhat discussed here http://www.coderanch.com/t/489497/ORM/databases/InheritanceType-JOINED-DiscriminatorColumn and here https://en.wikibooks.org/wiki/Java_Persistence/Inheritance#No_class_discriminator_column_2