IC5Notice: We have upgraded developerWorks Community to the latest version of IBM Connections. For more information, read our upgrade FAQ.
Topic
  • 3 replies
  • Latest Post - ‏2010-11-18T14:19:10Z by sutter
MattPepar
MattPepar
2 Posts

Pinned topic NullPointerException in org.apache.openjpa.kernel.SingleFieldManager.derefe

‏2010-11-17T01:19:24Z |
Hi,
Not sure if this is valid JPA code or not, but it worked on Websphere 7 JPA 1.0 and fails on Websphere 7 with JPA 2.0 feature pack installed. This simplified test case is a little unusual but occurred due to having some EntityListeners. It appears that if we set an Embeddable on a managed Entity twice, a NullPointerException is produced inside SingleFieldManager.dereferenceEmbedDependent.

The resultant stacktrace looks like:
Caused by: java.lang.NullPointerException
at org.apache.openjpa.kernel.SingleFieldManager.dereferenceEmbedDependent(SingleFieldManager.java:427)
at org.apache.openjpa.kernel.SingleFieldManager.delete(SingleFieldManager.java:313)
The method that will cause the crash contains the following code (test() is an EJB3 method):




private DepartmentEmbeddable makeEmbeddable() 
{ DepartmentEmbeddable d1 = 

new DepartmentEmbeddable(); d1.setDeptname(
"name"); d1.setMgrno(
"qw"); 

return d1; 
}   @Override 

public 

void test() 
{ Department d = em.find(Department.class, 
"1"); DepartmentEmbeddable d2 = 

new DepartmentEmbeddable(); d.setDepartmentEmbeddable(makeEmbeddable()); d.setDepartmentEmbeddable(makeEmbeddable()); 
}


Stepping through the source code indicates OpenJPA is crashing due to the fact that we're setting the embeddable twice on the managed Department instance. I think OpenJPA should either handle this or throw an exception saying it is invalid to set an embeddable twice.

Test case EAR is attached.

Regards,
Matt
Updated on 2010-11-18T14:19:10Z at 2010-11-18T14:19:10Z by sutter
  • SystemAdmin
    SystemAdmin
    45 Posts

    Re: NullPointerException in org.apache.openjpa.kernel.SingleFieldManager.derefe

    ‏2010-11-17T20:58:04Z  
    Hi Matt,
    This is a bug in OpenJPA. JIRA-1890 is open to address this problem.

    https://issues.apache.org/jira/browse/OPENJPA-1890

    Regards,
    Fay
  • MattPepar
    MattPepar
    2 Posts

    Re: NullPointerException in org.apache.openjpa.kernel.SingleFieldManager.derefe

    ‏2010-11-17T23:12:01Z  
    Thanks for the quick response !
    Out of interest do you know the timeframe for the OpenJPA 2.1 build appearing in a Websphere fixpack?
  • sutter
    sutter
    94 Posts

    Re: NullPointerException in org.apache.openjpa.kernel.SingleFieldManager.derefe

    ‏2010-11-18T14:19:10Z  
    • MattPepar
    • ‏2010-11-17T23:12:01Z
    Thanks for the quick response !
    Out of interest do you know the timeframe for the OpenJPA 2.1 build appearing in a Websphere fixpack?
    Hi Matt,
    Fay resolved this JIRA in the OpenJPA trunk release (2.1.x). The 2.1.x stream has not officially been targeted for a WebSphere release yet. The JPA 2.0 Feature Pack is based off of the OpenJPA 2.0.x stream. If you need this problem resolved in the FeP service stream, it would be best to open a PMR and reference the JIRA (https://issues.apache.org/jira/browse/OPENJPA-1890). This will allow WebSphere to pull in the fix and get you an update as quickly as possible.

    If you have any further questions, please post.

    Thanks,
    Kevin