Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 346005 - IllegalArgumentException with eclipseLink-orm.xml involving coverters
Summary: IllegalArgumentException with eclipseLink-orm.xml involving coverters
Status: RESOLVED FIXED
Alias: None
Product: Dali JPA Tools
Classification: WebTools
Component: JPA (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 3.1 M2   Edit
Assignee: Brian Vosburgh CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-16 17:13 EDT by Neil Hauge CLA
Modified: 2011-11-07 13:40 EST (History)
1 user (show)

See Also:


Attachments
Stack trace (4.75 KB, text/plain)
2011-05-16 17:14 EDT, Neil Hauge CLA
no flags Details
patch 1 (90.18 KB, patch)
2011-05-18 15:00 EDT, Brian Vosburgh CLA
no flags Details | Diff
Stack Trace (4.70 KB, text/plain)
2011-05-18 18:15 EDT, Nan Li CLA
no flags Details
patch 2 (143.62 KB, patch)
2011-05-23 16:34 EDT, Brian Vosburgh CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Neil Hauge CLA 2011-05-16 17:13:46 EDT
If you create a converter based error and then override that entity with an eclipselink-orm.xml you will hit the following exception.  To reproduce you simply reference a non-existing converter in a Java entity, then add that entity to your eclipselink-orm.xml.   I hit this reproducing bug 339418.


Null text range for message ID: ID_MAPPING_UNRESOLVED_CONVERTER_NAME

java.lang.IllegalArgumentException: Null text range for message ID: ID_MAPPING_UNRESOLVED_CONVERTER_NAME
    at org.eclipse.jpt.jpa.eclipselink.core.internal.DefaultEclipseLinkJpaValidationMessages.buildMessage(DefaultEclipseLinkJpaValidationMessages.java:48)


Full stack is attached.
Comment 1 Neil Hauge CLA 2011-05-16 17:14:21 EDT
Created attachment 195794 [details]
Stack trace
Comment 2 Neil Hauge CLA 2011-05-16 17:18:19 EDT
This results in there being no source location for the validation error.
Comment 3 Brian Vosburgh CLA 2011-05-18 15:00:15 EDT
Created attachment 196034 [details]
patch 1

Candidate patch. Requires Pascal's patch from bug 339418.
Comment 4 Brian Vosburgh CLA 2011-05-18 17:38:58 EDT
Pascal's patch fixes the problem where we do not detect that a Java attribute mapping is "virtual" when it is part of a type mapping in an EclipseLink orm.xml file (as opposed to a generic orm.xml file).

The patch attached to this bug addresses a number of problems with EclipseLink converters:

Converters cannot use a reserved name ("none", "class-instance", or "serialized").

There is no such thing as a "virtual" converter. Java converters defined on a Java type mapping or attribute mapping is still active when the Java mapping is overridden in the orm.xml file.

Overridden converters should not be validated.

Invalid Java converters should be marked as such in the *Java* source file, as opposed the corresponding orm.xml file mapping element.

These changes uncovered some bugs in how the UI listens for changes to the list of converters in a persistence unit. These are fixed.
Comment 5 Nan Li CLA 2011-05-18 18:14:56 EDT
With the patch applied, I got an NPE(stack trace attached) and no validation
message show up even when no eclipselink-orm.xml is involved. The ID mapping I
have is

    @Id
    @Convert("BALABA")  
    @Converter(converterClass = Foo.class, name = "CONV")
    private int id1;
Comment 6 Nan Li CLA 2011-05-18 18:15:37 EDT
Created attachment 196055 [details]
Stack Trace
Comment 7 Neil Hauge CLA 2011-05-18 21:28:24 EDT
Tried to get this fixed for RC2 but didn't have enough time.  Targeting to RC3 and will evaluate whether or not it is appropriate for RC3 when the fix is complete.
Comment 8 Neil Hauge CLA 2011-05-18 21:28:50 EDT
(In reply to comment #7)
> Tried to get this fixed for RC2 but didn't have enough time.  Targeting to RC3
> and will evaluate whether or not it is appropriate for RC3 when the fix is
> complete.

oops..wrong bug.  please ignore the last comment.
Comment 9 Nan Li CLA 2011-05-19 11:39:30 EDT
(In reply to comment #5)
> With the patch applied, I got an NPE(stack trace attached) and no validation
> message show up even when no eclipselink-orm.xml is involved. The ID mapping I
> have is
> 
>     @Id
>     @Convert("BALABA")  
>     @Converter(converterClass = Foo.class, name = "CONV")
>     private int id1;

This problem is cause by the validation of converter class and should be a separate problem so it will be tracked in another bug. The patch can be verified with other types of converters.
Comment 10 Neil Hauge CLA 2011-05-19 13:46:24 EDT
Fix is too big for RC's...targeting to maintenance.  We will fix invalid validation by removing it in RC3.
Comment 11 Brian Vosburgh CLA 2011-05-23 16:34:24 EDT
Created attachment 196364 [details]
patch 2

This patch fixes the NPE described in comment 5 (and bug 346498) which was caused by an oversight in patch 1. (As a hack) converter validation is passed a null instead of an AST. This was OK for calculating text ranges, since the appropriate Dali annotations now cache their text ranges; but caused a NPE because the AST is also being used to determine the converter class's inheritance tree. We now use the JDT model (as opposed to the AST) to determine the converter class's inheritance.

This patch also includes a modified version of the patch for bug 339418; so that patch no longer needed.
Comment 12 Neil Hauge CLA 2011-06-08 10:26:00 EDT
These problems have been reduced in severity with the fix for bug 346535.  These changes (patch 2) need to be resolved with the changes in 346535 in head.
Comment 13 Neil Hauge CLA 2011-07-01 16:24:30 EDT
Moving JPA specific bugs to new JPA component in bugzilla.
Comment 14 Neil Hauge CLA 2011-11-07 13:40:32 EST
I think these changes have already gone in.  I can no longer reproduce this issue.  Let me know if there was anything else needed here Brian.