openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Willis Blackburn (JIRA)" <>
Subject [jira] Commented: (OPENJPA-1804) NPE in line 1514
Date Mon, 20 Sep 2010 14:53:32 GMT


Willis Blackburn commented on OPENJPA-1804:

The <class> section looks like:


I've discovered some more information that is relevant.  The Organization object contains
a Set<HostName>.  HostName is an Embeddable.  However:

1.  HostName is obviously not in the list of persistent classes.

2.  When I looked in the class file for Organization, I discovered that the set of host names
did not have any generic type information.  In other words it was Set<?> instead of
Set<HostName>.  That's why OpenJPA complains (above) about "No metadata was found for
type 'class java.lang.Object.'"  (The reason that the generic type information is missing
is that this project is in Scala, and the Set<HostName> is defined in a Scala trait
that the Organization class inherits, and apparently Scala discards generic type information
when compiling classes that inherit members from traits.)

I discovered these two issues by running the standalone enhancer on my classfiles.  The standalone
enhancer doesn't produce NullPointerException, at least not in my tests, but does complain
about Object not being a persistent classes.  Once I fixed the two issues, then the runtime
enhancer started working as well.

I still think that this is a bug, as OpenJPA should not generate NPE even if the input mapping
has errors.

> NPE in line 1514
> ---------------------------------
>                 Key: OPENJPA-1804
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: Enhance
>    Affects Versions: 2.0.1
>            Reporter: Willis Blackburn
> I am encountering a NPE at 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.

View raw message