Bug 367576 - Predeployment complains about invalid mapping for enum type
Summary: Predeployment complains about invalid mapping for enum type
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P2 major with 4 votes (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-27 08:21 EST by Christoph Laeubrich CLA
Modified: 2022-06-09 10:02 EDT (History)
3 users (show)

See Also:


Attachments
simple tescase reproducing the problem (8.63 KB, application/zip)
2012-01-24 12:59 EST, Christoph Laeubrich CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christoph Laeubrich CLA 2011-12-27 08:21:46 EST
Build Identifier: 2.3.1.v20110928-r10176

Exception Description: Predeployment of PersistenceUnit [mitarbeiter] failed.
Internal Exception: Exception [EclipseLink-7151] (Eclipse Persistence Services - 2.3.1.v20110928-r10176): org.eclipse.persistence.exceptions.ValidationException
Exception Description: The type [class data.mitarbeiter.FehlzeitType] for the attribute [fehlType] on the entity class [class mitarbeiter.dao.DBFehlzeit] is not a valid type for an enumerated mapping. The attribute must be defined as a Java enum.
	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1402)
	at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.callPredeploy(JPAInitializer.java:98)
	at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.initPersistenceUnits(JPAInitializer.java:306)
	at org.eclipse.gemini.jpa.provider.GeminiOSGiInitializer.initializeFromBundle(GeminiOSGiInitializer.java:119)
	at org.eclipse.gemini.jpa.provider.EclipseLinkOSGiProvider.assignPersistenceUnitsInBundle(EclipseLinkOSGiProvider.java:191)
	at org.eclipse.gemini.jpa.PersistenceBundleExtender.tryAssigningPersistenceUnitsInBundle(PersistenceBundleExtender.java:172)
	at org.eclipse.gemini.jpa.PersistenceBundleExtender.bundleChanged(PersistenceBundleExtender.java:314)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:847)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
	at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEventPrivileged(Framework.java:1523)
	at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEvent(Framework.java:1459)
	at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEvent(Framework.java:1454)
	at org.eclipse.osgi.framework.internal.core.PackageAdminImpl.processDelta(PackageAdminImpl.java:487)
	at org.eclipse.osgi.framework.internal.core.PackageAdminImpl.doResolveBundles(PackageAdminImpl.java:253)
	at org.eclipse.osgi.framework.internal.core.PackageAdminImpl$1.run(PackageAdminImpl.java:173)
	at java.lang.Thread.run(Thread.java:662)

Reproducible: Always

Steps to Reproduce:
Mappings:

public class DBFehlzeit extends VersionedObject implements Fehlzeit {
    @Temporal(TemporalType.DATE)
    private Date         von;
    @Temporal(TemporalType.DATE)
    private Date         bis;
    @Enumerated(EnumType.STRING)
    private FehlzeitType fehlType;
    private String       user;
}

Enum:
public enum FehlzeitType {
    Krankheit,
    Urlaub;
}
Comment 1 Christoph Laeubrich CLA 2012-01-08 10:01:55 EST
I testes a little more, it seems that the superclass information is not set correctly with the setSuperclassName and isValidEnumeratedType returns always false.
Comment 2 Tom Ware CLA 2012-01-23 11:07:07 EST
Any more information you can provide about this issue will be useful.  (e.g. a full test case or at least the full set of mappings including superclass)  We have working test cases that demonstrate a working class with an enum, so perhaps the inheritance is important.  Also, I see that DBFehlzeit is not annotated as an Entity - if it is not set up as an Entity in some other way, that may be the problem.  (You cannot inherit being an Entity from a superclass)
Comment 3 Christoph Laeubrich CLA 2012-01-24 12:59:23 EST
Created attachment 209990 [details]
simple tescase reproducing the problem

Hi Tom,

sorry for the confusion. I shrinked down the class an mapping information and thus accidentally removed the entity annotation.

I now was able to put together a testcase (and another observation):
As long as the enum resides in the same bundle as the Entity class everything works fine. When importing the enum via a package import the problem occurs (but still the entity can be persisted and worked with...)

I'm using EclipseLink together with eclipse gemini in non container managed mode with Java 1.6 and Equinox as the OSGi runtime.
Comment 4 Tom Ware CLA 2012-02-09 10:27:34 EST
Setting target and priority.  See the following page for the meanings of these fields:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines

Community: Please vote for this bug if it is important to you.  Votes are one of the main criteria we use to determine which bugs to fix next.
Comment 5 Daniele Pirola CLA 2012-07-19 11:43:04 EDT
(In reply to comment #4)
> Setting target and priority.  See the following page for the meanings of these
> fields:
> 
> http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines
> 
> Community: Please vote for this bug if it is important to you.  Votes are one
> of the main criteria we use to determine which bugs to fix next.

Bug Voted
Interfaces are also affected by this problem.
If you map a field with an interface outside the bundle (but in the classpath)
you get the same error
Comment 6 Daniele Pirola CLA 2012-07-19 16:16:48 EDT
I can suggest a workaround for this problem.
Just put all classes, interfaces and enums outside the bundle (reached via import package) where there is the persistence.xml file. 
With this layout, entities are all unreachable by the predeploy method and would be analized after the bundle is started.
It's not the optimal solution but it's work for me
Comment 7 Christoph Laeubrich CLA 2012-07-20 10:31:50 EDT
(In reply to comment #6)
> I can suggest a workaround for this problem.
> Just put all classes, interfaces and enums outside the bundle (reached via
> import package) where there is the persistence.xml file. 
> With this layout, entities are all unreachable by the predeploy method and
> would be analized after the bundle is started.
> It's not the optimal solution but it's work for me

You mean an bundle which only contains the persitence XML?
Comment 8 Daniele Pirola CLA 2012-07-20 10:43:12 EDT
(In reply to comment #7)
> (In reply to comment #6)
> > I can suggest a workaround for this problem.
> > Just put all classes, interfaces and enums outside the bundle (reached via
> > import package) where there is the persistence.xml file. 
> > With this layout, entities are all unreachable by the predeploy method and
> > would be analized after the bundle is started.
> > It's not the optimal solution but it's work for me
> 
> You mean an bundle which only contains the persitence XML?

Yes, an bundle with only persistence xml and at least self-contained entities, that don't refer to other classes.
eg.

- bundle A 
  - persistence.xml 
       - refers to class Alfa 
                which has a Beta enum field
       - refers to class Delta (self-contained)
  - class Delta

- bundle B 
  - class Alfa 
  - Enum Beta
Comment 9 Eclipse Webmaster CLA 2022-06-09 10:02:44 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink