[ 
https://issues.apache.org/jira/browse/OPENJPA-1804?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12912556#action_12912556
 ] 

Willis Blackburn commented on OPENJPA-1804:
-------------------------------------------

Rick,

I just saw the error about there not being any metadata for java.lang.Object.  
But I knew what was causing the problem because I was pursuing a strategy of 
starting off with running the enhancer on a single class with a single 
annotation (@Entity) and then gradually adding annotations and classes until it 
stopped working.  It gave me that message after I re-added the Set<HostName>, 
so I figured that it was unable to figure out what type was in the Set.  I 
subsequently discovered the issue with Scala, which I entered here:

http://lampsvn.epfl.ch/trac/scala/ticket/3857

It would have been helpful if OpenJPA had reported why it was looking for 
metadata for Object.  Like "No metadata was found for type 'class 
java.lang.Object' referenced from Organization.hostNames."  Also, it might be 
worth handling missing metadata for Object specially;  it's more likely that 
OpenJPA has encountered a raw collection type than that the developer really 
wants Object to be persistent but has neglected to provide the metadata.

About the runtime enhancer, why even have it if it's half-baked?  It would be 
better to simply remove it and make the code base that much simpler.  If it's 
there, then people will use it, and if it doesn't work, then they'll wind up 
with a bad impression of OpenJPA that may not be warranted.



> NPE in MappingInfo.java line 1514
> ---------------------------------
>
>                 Key: OPENJPA-1804
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1804
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: Enhance
>    Affects Versions: 2.0.1
>            Reporter: Willis Blackburn
>
> I am encountering a NPE at MappingInfo.java line 1514.  I'm sorry I don't 
> have time to prepare a test case right now.  I'm not even 100% sure what is 
> causing the problem, but it seems to be something like this:
> I have classes Organization, Group, User, and AddressBook.
> Group has a reference (many-to-one) to Organization.
> I'm using field-level access and the Java 6 runtime enhancer.  (NOT the 
> build-time enhancer or the agent.)
> In ManagedClassSubclasser.prepareUnenhancedClasses, the code receives a list 
> of Class objects--the ones in persistence.xml.  They are not in the same 
> order as they are in persistence.xml, but I don't know if that's important.  
> The first one is Group.  During the processing of Group, the code invokes 
> ClassMapping.setTable to set the table name, which is "group_table."  This 
> comes from the @Table annotation of Group.  So far, so good.  Then the code 
> does some additional processing on the relationship mappings of Group, which 
> include the reference to Organization.  During the processing of that 
> relationship, the code calls MappingInfo.mergeJoinColumn.  On line 1367, the 
> method calls rel.getTable.  The "rel" variable points to the ClassMapping for 
> Organization.  Remember that prepareUnenhancedClasses hasn't gotten to 
> Organization yet--it's still working on Group--and so I assume that this 
> Organization mapping was created on-demand.  However, rel.getTable returns 
> null.  The Organization class has a @Table attribute, and I can see that the 
> table name has been loaded in the ClassMappingInfo instance attached to the 
> ClassMapping for Organization, however the table name has not yet been copied 
> from ClassMappingInfo to ClassMapping.  Later, the mergeJoinColumn method 
> attempts to dereference the null table name and generates the NPE.
> Bottom line:  When using the Java 6, runtime enhancer, if class A has a 
> reference to class B, and both classes have @Table annotations (at least), 
> and class A is processed first, then it produces a NPE.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to