Enum is not a valid type for an enumerated display

I have a real head-scratcher on the following exception that is thrown when trying and deploying my webapp in a Glassfish container (both static shell and server). Basically, I have an entity class that has the following property:

    @Entity
    public class Anniversary implements Serializable, Comparable<Anniversary>
    {
     ...

        @Enumerated
        private AnniversaryType type;

     ....Rest of class
     }

      

This refers to an enumerated class, which is declared like this:

 public enum AnniversaryType

      

The program is built without complaint in Netbeans 8.0 using a standard Maven project, but the following exception is thrown when deployed:

Caused by: Exception [EclipseLink-7151] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd):         org.eclipse.persistence.exceptions.ValidationException
Exception Description: The type [class com.mycompany.anniversaries_final.AnniversaryType] for the   attribute [type] on the entity class [class com.mycompany.anniversaries_final.Anniversary] is not a     valid type for an enumerated mapping. The attribute must be defined as a Java enum.
at org.eclipse.persistence.exceptions.ValidationException.invalidTypeForEnumeratedAttribute(ValidationException.java:1125)
at org.eclipse.persistence.internal.jpa.metadata.converters.EnumeratedMetadata.process(EnumeratedMetadata.java:115)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.MappingAccessor.processEnumerated(MappingAccessor.java:1684)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.BasicAccessor.processEnumerated(BasicAccessor.java:467)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.MappingAccessor.processMappingConverter(MappingAccessor.java:1769)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.MappingAccessor.processMappingValueConverter(MappingAccessor.java:1796)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.BasicAccessor.process(BasicAccessor.java:419)
at org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor.processMappingAccessors(MetadataDescriptor.java:1536)
at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.ClassAccessor.processMappingAccessors(ClassAccessor.java:1648)
at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.processMappingAccessors(EntityAccessor.java:1234)
at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.process(EntityAccessor.java:697)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage2(MetadataProject.java:1793)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:576)
at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:585)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1869)
... 64 more

      

... I'm confused! I have looked at both of the following questions, JPA and enum type and jaxws and EclipseLink refuses to use enums from lib , both of which offer answers if the class is in a separate jar file, but in my case it is not (as far as I know). I had another problem with this enum elsewhere in the application where I used it as a map key and had to explicitly list the table and key values ​​at https://bugs.eclipse.org/bugs/show_bug.cgi?id= 364922 .

I'm completely stumped .... any help would be greatly appreciated!

+3


source to share


1 answer


Fixed! The problem is caused by the following line in an enumerated class:

return Arrays.asList(values()).stream().filter(type -> {
          return type.isCultural();
       }).collect(Collectors.toList());

      



I seem to be having trouble using streams in entity classes in general; when I use them, they seem to throw all kinds of obviously unrelated exceptions. I submitted a post with Glassfish and am waiting for a response ...

+4


source







All Articles