openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fay Wang <fyw...@yahoo.com>
Subject Re: @MappedSuperClass Cause Null Pointer Exception in Class With IdClass
Date Tue, 19 May 2009 20:52:39 GMT

Hi,

   Your test case has been checked into svn in JIRA-873 in package: 

org.apache.openjpa.persistence.inheritance.mappedsuperclass:

TestMappedSuperClass
BaseEntity
CashBaseEntity
SharedName1
SituationDA
ValuableItemDA

  This test case works fine. Could you please double check if this test case is different
from yours?

Thanks!


--- On Tue, 5/19/09, is_maximum <mnrz57@gmail.com> wrote:

> From: is_maximum <mnrz57@gmail.com>
> Subject: Re: @MappedSuperClass Cause Null Pointer Exception in Class With IdClass
> To: users@openjpa.apache.org
> Date: Tuesday, May 19, 2009, 3:08 AM
> 
> Hello
> I am using OpenJPA 2.0 SNAPSHOT but it seems that the
> problem still exists
> 
> Here is the stack trace of exception thrown. The test case
> succeeded without
> IdClass and using Embedded id but IdClass has problem.
> 
> javax.ejb.EJBException: The bean encountered a
> non-application exception.;
> nested exception is: 
>    
> javax.ejb.EJBTransactionRolledbackException: The transaction
> has been
> marked rollback only because the bean encountered a
> non-application
> exception
> :org.apache.openjpa.persistence.PersistenceException : null
>     at
> org.apache.openejb.core.ivm.BaseEjbProxyHandler.convertException(BaseEjbProxyHandler.java:366)
>     at
> org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:323)
>     at
> org.apache.openejb.util.proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java:49)
>     at
> $Proxy60.reassignAuthorizedBranches(Unknown Source)
>     at
> com.kishware.core.gl.service.main.GeneralLedgerImplTest.testAssignAuthorizedBranches(GeneralLedgerImplTest.java:316)
>     at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at
> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>     at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
> Source)
>     at
> java.lang.reflect.Method.invoke(Unknown Source)
>     at
> junit.framework.TestCase.runTest(TestCase.java:154)
>     at
> junit.framework.TestCase.runBare(TestCase.java:127)
>     at
> junit.framework.TestResult$1.protect(TestResult.java:106)
>     at
> junit.framework.TestResult.runProtected(TestResult.java:124)
>     at
> junit.framework.TestResult.run(TestResult.java:109)
>     at
> junit.framework.TestCase.run(TestCase.java:118)
>     at
> junit.framework.TestSuite.runTest(TestSuite.java:208)
>     at
> junit.framework.TestSuite.run(TestSuite.java:203)
>     at
> org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
>     at
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
>     at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>     at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
>     at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
>     at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
>     at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: javax.ejb.EJBTransactionRolledbackException: The
> transaction has
> been marked rollback only because the bean encountered a
> non-application
> exception
> :org.apache.openjpa.persistence.PersistenceException : null
>     at
> org.apache.openejb.core.ivm.BaseEjbProxyHandler.convertException(BaseEjbProxyHandler.java:348)
>     at
> org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:323)
>     at
> org.apache.openejb.util.proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java:49)
>     at $Proxy61.getEntry(Unknown Source)
>     at
> com.kishware.core.gl.interceptor.GLSelfConfig.checkIfRootNotExist(GLSelfConfig.java:38)
>     at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at
> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>     at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
> Source)
>     at
> java.lang.reflect.Method.invoke(Unknown Source)
>     at
> org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:158)
>     at
> org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:141)
>     at
> com.kishware.core.orgfund.session.RequestDataInterceptor.catchRequestHeader(RequestDataInterceptor.java:130)
>     at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at
> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>     at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
> Source)
>     at
> java.lang.reflect.Method.invoke(Unknown Source)
>     at
> org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:158)
>     at
> org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:141)
>     at
> org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:67)
>     at
> org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:210)
>     at
> org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:188)
>     at
> org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:165)
>     at
> org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:217)
>     at
> org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:77)
>     at
> org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:321)
>     ... 22 more
> Caused by: <openjpa-2.0.0-M1-SNAPSHOT-r422266:725770
> nonfatal general error>
> org.apache.openjpa.persistence.PersistenceException: null
>     at
> org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:203)
>     at
> org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142)
>     at
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:196)
>     at
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:60)
>     at
> org.apache.openejb.persistence.JtaEntityManagerRegistry.getEntityManager(JtaEntityManagerRegistry.java:105)
>     at
> org.apache.openejb.persistence.JtaEntityManager.getEntityManager(JtaEntityManager.java:61)
>     at
> org.apache.openejb.persistence.JtaEntityManager.createQuery(JtaEntityManager.java:173)
>     at
> com.kishware.common.persistence.dao.ejb.SearcherImpl.findByField(SearcherImpl.java:159)
>     at
> com.kishware.core.gl.dao.jpa.GeneralLedgerDaoImpl.getEntry(GeneralLedgerDaoImpl.java:389)
>     at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at
> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>     at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
> Source)
>     at
> java.lang.reflect.Method.invoke(Unknown Source)
>     at
> org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:158)
>     at
> org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:141)
>     at
> org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:67)
>     at
> org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:210)
>     at
> org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:188)
>     at
> org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:165)
>     at
> org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:217)
>     at
> org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:77)
>     at
> org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:321)
>     ... 45 more
> Caused by: java.lang.NullPointerException
>     at
> org.apache.openjpa.meta.ClassMetaData.validateAppIdClass(ClassMetaData.java:1883)
>     at
> org.apache.openjpa.meta.ClassMetaData.validateIdentity(ClassMetaData.java:1840)
>     at
> org.apache.openjpa.meta.ClassMetaData.validateMeta(ClassMetaData.java:1757)
>     at
> org.apache.openjpa.meta.ClassMetaData.resolve(ClassMetaData.java:1630)
>     at
> org.apache.openjpa.meta.MetaDataRepository.processBuffer(MetaDataRepository.java:717)
>     at
> org.apache.openjpa.meta.MetaDataRepository.resolveMeta(MetaDataRepository.java:616)
>     at
> org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:541)
>     at
> org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:308)
>     at
> org.apache.openjpa.jdbc.meta.MappingRepository.getMapping(MappingRepository.java:286)
>     at
> org.apache.openjpa.jdbc.meta.MappingTool.getMapping(MappingTool.java:676)
>     at
> org.apache.openjpa.jdbc.meta.MappingTool.buildSchema(MappingTool.java:748)
>     at
> org.apache.openjpa.jdbc.meta.MappingTool.run(MappingTool.java:646)
>     at
> org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(JDBCBrokerFactory.java:153)
>     at
> org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newBrokerImpl(JDBCBrokerFactory.java:119)
>     at
> org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:196)
>     ... 66 more
> 
> 
> 
> 
> Fay Wang wrote:
> > 
> > The NPE is because the SituationDA is inherited from
> CashBaseEntity and
> > CashBaseEntity does not have Id class. JIRA 873 is
> open to address this
> > issue.
> > 
> > Regards,
> > Fay
> > 
> > 
> > --- On Sat, 1/24/09, Drifter <pioneer_ip@yahoo.com>
> wrote:
> > 
> >> From: Drifter <pioneer_ip@yahoo.com>
> >> Subject: @MappedSuperClass Cause Null Pointer
> Exception in Class With
> >> IdClass
> >> To: users@openjpa.apache.org
> >> Date: Saturday, January 24, 2009, 4:30 AM
> >> Dear All .. 
> >> i have four fieild that exist in all tables ..i
> want to use
> >> @MapperSuperClass .I test and I found that when
> there is a
> >> extended class
> >> that have IdClass PCEnhancer cuase null pointer
> exception.
> >> I use OpenJPA.1.2
> >> in other cases there is  no problem..... in
> the following
> >> class in
> >> ValuableItemDA  there is no problem and
> everything work
> >> well.. but in
> >> SituationDA that have a IdClass it cause null
> pointer
> >> excpetion.  in
> >> PCEnhancer..i think i should add some extera
> annotation?but
> >> i dont know how
> >> solve the problem...
> >> 
> >> 
> >> @MappedSuperclass
> >> public abstract class CashBaseEntity extends
> BaseEntity{
> >> @Column(name="TRCCRUI")
> >>           private
> String createUser;
> >>           
> >>          
> @Column(name="TRCCRTS")
> >>           private
> Date createTime;
> >>           
> >>          
> @Column(name="TRCLUUID")
> >>           private
> String updateUser;
> >>           
> >>          
> @Column(name="TRCLUTS")
> >>           private
> Date updateTime;
> >>           
> >>           @Version
> >>          
> @Column(name="TRCVER")
> >>           private
> int version;
> >> //getter setter ....removed ..for short post
> >> 
> >>     }
> >> 
> >> 
> >> @Entity
> >> @Table (  name = "cc2SITUATION")
> >> @IdClass(SituationDA.SituationId.class)
> >> public class SituationDA extends CashBaseEntity{
> >>     
> >>     @Id
> >>     @Column(name="C2008SRL")
> >>     private String
> CashBoxPeriodSerial;
> >>     
> >>     @Id
> >>     @Column(name="C2012TYPE")
> >>     private short Type;
> >> 
> >>     public static class SituationId
> implements Serializable{
> >>         private
> static final long serialVersionUID = 1L;
> >>         public
> String CashBoxPeriodSerial;
> >>         public short
> Type;
> >>         
> >>         public
> SituationId(){
> >>        
>     
> >>         }
> >>         
> >>         public
> boolean equals(Object other){
> >>        
>     if (other instanceof SituationId) {
> >>        
>         final SituationId
> otherId = (SituationId)other;
> >>        
>         return (
> >>
> otherId.CashBoxPeriodSerial.equals(this.CashBoxPeriodSerial)
> >> &&
> >> otherId.Type == this.Type );
> >>        
>         }
> >>        
>         return
> false;    
> >>         }
> >>         
> >>         public int
> hashCode() {
> >>        
>     return super.hashCode();
> >>         }
> >>     }
> >> //getter setter removed for short post..
> >> }
> >> 
> >> 
> >> 
> >> 
> >> @Entity
> >> @Table (name = "CF2VLUITEM") 
> >> public class ValuableItemDA extends
> CashBaseEntity{
> >>     @Id
> >>     @Column(name="C2001COD")
> >>     private short Code;
> >> 
> >> //getter setter removed for short post..
> >> 
> >> }
> >> 
> >> -- 
> >> View this message in context:
> >> http://n2.nabble.com/%40MappedSuperClass-Cause-Null-Pointer-Exception-in-Class-With-IdClass-tp2208581p2208581.html
> >> Sent from the OpenJPA Users mailing list archive
> at
> >> Nabble.com.
> > 
> > 
> >       
> > 
> > 
> 
> -- 
> View this message in context: http://n2.nabble.com/%40MappedSuperClass-Cause-Null-Pointer-Exception-in-Class-With-IdClass-tp2208581p2938664.html
> Sent from the OpenJPA Users mailing list archive at
> Nabble.com.
> 
> 


      

Mime
View raw message