geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aaron Mulder" <ammul...@alumni.princeton.edu>
Subject Re: FindByPrimaryKey
Date Wed, 05 Apr 2006 03:09:34 GMT
Can you attach your original ejb-jar.xml and openejb-jar.xml to an
e-mail?  We need to figure out why it's getting mixed up between
String and the PK class for the primary key for your bean.

Thanks,
    Aaron

On 4/4/06, Olivier Voutat <olivier.voutat@gmail.com> wrote:
> Well, I added the set/get chassi in my CarPK class but no luck...
>
> I did another test too. The primary key returned by the method getPrimaryKey
> of the returned object when I do findBySituation (which was implemented by
> me) is an instance of String, not o CarPK like you can see here...don't get
> why
>
> Primary Key 3687352196865265
> String Instance true
> CarPK Instance false
> Primary Key 65436549663416546
> String Instance true
> CarPK Instance false
> Primary Key 65454894635418697
> String Instance true
> CarPK Instance false
> Primary Key 9BWCA05X85P082824
> String Instance true
> CarPK Instance false
> Primary Key AABB151515
> String Instance true
> CarPK Instance false
> New pk class AABB151515
> Until here everything works.
> setEntityContext called do carro.
> setEntityContext called do carro.
> 23:58:30,665 WARN  [SystemExceptionInterceptor] Carro
> javax.ejb.TransactionRolledbackLocalException
>         at
> org.openejb.transaction.ContainerPolicy$TxRequired.invoke
> (ContainerPolicy.java:123)
>         at
> org.openejb.transaction.TransactionContextInterceptor.invoke(TransactionContextInterceptor.java:80)
>         at
> org.openejb.SystemExceptionInterceptor.invoke(SystemExceptionInterceptor.java
> :82)
>         at
> org.openejb.GenericEJBContainer.invoke(GenericEJBContainer.java:238)
>         at
> org.openejb.proxy.EJBMethodInterceptor.intercept(EJBMethodInterceptor.java:129)
>         at
> org.openejb.proxy.EntityEJBLocalHome$$EnhancerByCGLIB$$1847bc60.findByPrimaryKey
> (<generated>)
>         at
> br.cefetrn.olivier.session.MySessionBean.registrarLocacao(MySessionBean.java:71)
>         at
> br.cefetrn.olivier.session.MySessionBean$$FastClassByCGLIB$$fba7f7a3.invoke(<generated>)
>         at
> org.openejb.dispatch.AbstractMethodOperation.invoke(AbstractMethodOperation.java:90)
>         at
> org.openejb.sfsb.BusinessMethod.execute(BusinessMethod.java:66)
>         at org.openejb.dispatch.DispatchInterceptor.invoke
> (DispatchInterceptor.java:72)
>         at
> org.apache.geronimo.naming.java.ComponentContextInterceptor.invoke(ComponentContextInterceptor.java:56)
>         at
> org.openejb.ConnectionTrackingInterceptor.invoke(ConnectionTrackingInterceptor.java
> :81)
>         at
> org.openejb.sfsb.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:115)
>         at
> org.openejb.transaction.ContainerPolicy$TxRequired.invoke(ContainerPolicy.java:140)
>         at
> org.openejb.transaction.TransactionContextInterceptor.invoke(TransactionContextInterceptor.java:80)
>         at
> org.openejb.SystemExceptionInterceptor.invoke(SystemExceptionInterceptor.java:82)
>         at org.openejb.GenericEJBContainer.invoke
> (GenericEJBContainer.java:238)
>         at
> org.openejb.server.ejbd.EjbRequestHandler.invoke(EjbRequestHandler.java:297)
>         at
> org.openejb.server.ejbd.EjbRequestHandler.doEjbObject_BUSINESS_METHOD(EjbRequestHandler.java
> :325)
>         at
> org.openejb.server.ejbd.EjbRequestHandler.processRequest(EjbRequestHandler.java:196)
>         at
> org.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:150)
>         at org.openejb.server.ejbd.EjbServer.service
> (EjbServer.java:87)
>         at
> org.openejb.server.ejbd.EjbServer$$FastClassByCGLIB$$d379d2ff.invoke(<generated>)
>         at
> net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
>         at
> org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke
> (FastMethodInvoker.java:38)
>         at
> org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(GBeanOperation.java:118)
>         at
> org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.java:800)
>         at
> org.apache.geronimo.gbean.runtime.RawInvoker.invoke(RawInvoker.java:57)
>         at
> org.apache.geronimo.kernel.basic.RawOperationInvoker.invoke(RawOperationInvoker.java:36)
>         at
> org.apache.geronimo.kernel.basic.ProxyMethodInterceptor.intercept
> (ProxyMethodInterceptor.java:96)
>         at
> org.activeio.xnet.ServerService$$EnhancerByCGLIB$$463425f3.service(<generated>)
>         at
> org.activeio.xnet.ServicePool$2.run(ServicePool.java:67)
>         at org.activeio.xnet.ServicePool$3.run
> (ServicePool.java:90)
>         at
> org.apache.geronimo.pool.ThreadPool$ContextClassLoaderRunnable.run(ThreadPool.java:138)
>         at
> EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(Unknown
> Source)
>         at java.lang.Thread.run(Thread.java:595)
> Caused by: java.lang.ClassCastException:
> br.cefetrn.olivier.entity.CarroPK
>         at
> org.tranql.sql.jdbc.binding.StringBinding.setValue(StringBinding.java:43)
>         at
> org.tranql.sql.jdbc.binding.TypeConverterBinding.setValue
> (TypeConverterBinding.java:93)
>         at
> org.tranql.sql.jdbc.binding.TypeConverterBinding.setValue(TypeConverterBinding.java:89)
>         at
> org.tranql.sql.jdbc.JDBCQueryCommand.execute(JDBCQueryCommand.java:64)
>          at
> org.tranql.cache.cache.FindByPKCacheQueryCommand.execute(FindByPKCacheQueryCommand.java:66)
>         at
> org.openejb.entity.cmp.CMPFinder.execute(CMPFinder.java:99)
>         at
> org.openejb.entity.cmp.SingleValuedFinder.execute
> (SingleValuedFinder.java:80)
>         at
> org.openejb.dispatch.DispatchInterceptor.invoke(DispatchInterceptor.java:72)
>         at
> org.apache.geronimo.naming.java.ComponentContextInterceptor.invoke(ComponentContextInterceptor.java
> :56)
>         at
> org.openejb.ConnectionTrackingInterceptor.invoke(ConnectionTrackingInterceptor.java:81)
>         at
> org.openejb.entity.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:136)
>         at
> org.openejb.entity.cmp.InTxCacheInterceptor.invoke(InTxCacheInterceptor.java:90)
>         at
> org.openejb.transaction.ContainerPolicy$TxRequired.invoke(ContainerPolicy.java:119)
>         ... 36 more
> 23:58:30,670 WARN  [SystemExceptionInterceptor] MySession
> javax.ejb.TransactionRolledbackLocalException
>         at
> org.openejb.transaction.ContainerPolicy$TxRequired.invoke(ContainerPolicy.java:123)
>         at
> org.openejb.transaction.TransactionContextInterceptor.invoke
> (TransactionContextInterceptor.java:80)
>         at
> org.openejb.SystemExceptionInterceptor.invoke(SystemExceptionInterceptor.java:82)
>         at
> org.openejb.GenericEJBContainer.invoke(GenericEJBContainer.java:238)
>          at
> org.openejb.proxy.EJBMethodInterceptor.intercept(EJBMethodInterceptor.java:129)
>         at
> org.openejb.proxy.EntityEJBLocalHome$$EnhancerByCGLIB$$1847bc60.findByPrimaryKey(<generated>)
>         at
> br.cefetrn.olivier.session.MySessionBean.registrarLocacao
> (MySessionBean.java:71)
>         at
> br.cefetrn.olivier.session.MySessionBean$$FastClassByCGLIB$$fba7f7a3.invoke(<generated>)
>         at
> org.openejb.dispatch.AbstractMethodOperation.invoke(AbstractMethodOperation.java
> :90)
>         at
> org.openejb.sfsb.BusinessMethod.execute(BusinessMethod.java:66)
>         at
> org.openejb.dispatch.DispatchInterceptor.invoke(DispatchInterceptor.java:72)
>         at
> org.apache.geronimo.naming.java.ComponentContextInterceptor.invoke
> (ComponentContextInterceptor.java:56)
>         at
> org.openejb.ConnectionTrackingInterceptor.invoke(ConnectionTrackingInterceptor.java:81)
>         at
> org.openejb.sfsb.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java
> :115)
>         at
> org.openejb.transaction.ContainerPolicy$TxRequired.invoke(ContainerPolicy.java:140)
>         at
> org.openejb.transaction.TransactionContextInterceptor.invoke(TransactionContextInterceptor.java:80)
>          at
> org.openejb.SystemExceptionInterceptor.invoke(SystemExceptionInterceptor.java:82)
>         at
> org.openejb.GenericEJBContainer.invoke(GenericEJBContainer.java:238)
>         at org.openejb.server.ejbd.EjbRequestHandler.invoke
> (EjbRequestHandler.java:297)
>         at
> org.openejb.server.ejbd.EjbRequestHandler.doEjbObject_BUSINESS_METHOD(EjbRequestHandler.java:325)
>         at
> org.openejb.server.ejbd.EjbRequestHandler.processRequest(EjbRequestHandler.java
> :196)
>         at
> org.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:150)
>         at
> org.openejb.server.ejbd.EjbServer.service(EjbServer.java:87)
>         at
> org.openejb.server.ejbd.EjbServer$$FastClassByCGLIB$$d379d2ff.invoke
> (<generated>)
>         at
> net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
>         at
> org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke(FastMethodInvoker.java:38)
>         at
> org.apache.geronimo.gbean.runtime.GBeanOperation.invoke
> (GBeanOperation.java:118)
>         at
> org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.java:800)
>         at
> org.apache.geronimo.gbean.runtime.RawInvoker.invoke(RawInvoker.java:57)
>         at
> org.apache.geronimo.kernel.basic.RawOperationInvoker.invoke
> (RawOperationInvoker.java:36)
>         at
> org.apache.geronimo.kernel.basic.ProxyMethodInterceptor.intercept(ProxyMethodInterceptor.java:96)
>         at
> org.activeio.xnet.ServerService$$EnhancerByCGLIB$$463425f3.service
> (<generated>)
>         at
> org.activeio.xnet.ServicePool$2.run(ServicePool.java:67)
>         at
> org.activeio.xnet.ServicePool$3.run(ServicePool.java:90)
>         at
> org.apache.geronimo.pool.ThreadPool$ContextClassLoaderRunnable.run
> (ThreadPool.java:138)
>         at
> EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(Unknown
> Source)
>         at java.lang.Thread.run(Thread.java:595)
> Caused by: java.lang.ClassCastException:
> br.cefetrn.olivier.entity.CarroPK
>         at
> org.tranql.sql.jdbc.binding.StringBinding.setValue(StringBinding.java:43)
>         at
> org.tranql.sql.jdbc.binding.TypeConverterBinding.setValue(TypeConverterBinding.java:93)
>         at
> org.tranql.sql.jdbc.binding.TypeConverterBinding.setValue
> (TypeConverterBinding.java:89)
>         at
> org.tranql.sql.jdbc.JDBCQueryCommand.execute(JDBCQueryCommand.java:64)
>         at
> org.tranql.cache.cache.FindByPKCacheQueryCommand.execute(FindByPKCacheQueryCommand.java:66)
>         at
> org.openejb.entity.cmp.CMPFinder.execute(CMPFinder.java:99)
>         at
> org.openejb.entity.cmp.SingleValuedFinder.execute(SingleValuedFinder.java:80)
>         at org.openejb.dispatch.DispatchInterceptor.invoke
> (DispatchInterceptor.java:72)
>         at
> org.apache.geronimo.naming.java.ComponentContextInterceptor.invoke(ComponentContextInterceptor.java:56)
>         at
> org.openejb.ConnectionTrackingInterceptor.invoke(ConnectionTrackingInterceptor.java
> :81)
>         at
> org.openejb.entity.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:136)
>         at
> org.openejb.entity.cmp.InTxCacheInterceptor.invoke(InTxCacheInterceptor.java:90)
>         at
> org.openejb.transaction.ContainerPolicy$TxRequired.invoke
> (ContainerPolicy.java:119)
>         ... 36 more
> 23:58:30,688 WARN  [[Negocio]] Servlet.service() for servlet Negocio threw
> exception
> java.rmi.RemoteException: The bean encountered a non-application exception.
> method; nested exception is:
>         javax.ejb.TransactionRolledbackLocalException
>         at
> org.openejb.server.ejbd.EjbRequestHandler.invoke(EjbRequestHandler.java:303)
>         at
> org.openejb.server.ejbd.EjbRequestHandler.doEjbObject_BUSINESS_METHOD
> (EjbRequestHandler.java:325)
>         at
> org.openejb.server.ejbd.EjbRequestHandler.processRequest(EjbRequestHandler.java:196)
>         at
> org.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:150)
>         at org.openejb.server.ejbd.EjbServer.service
> (EjbServer.java:87)
>         at
> org.openejb.server.ejbd.EjbServer$$FastClassByCGLIB$$d379d2ff.invoke(<generated>)
>         at
> net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
>         at
> org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke
> (FastMethodInvoker.java:38)
>         at
> org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(GBeanOperation.java:118)
>         at
> org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.java:800)
>         at
> org.apache.geronimo.gbean.runtime.RawInvoker.invoke(RawInvoker.java:57)
>         at
> org.apache.geronimo.kernel.basic.RawOperationInvoker.invoke(RawOperationInvoker.java:36)
>         at
> org.apache.geronimo.kernel.basic.ProxyMethodInterceptor.intercept
> (ProxyMethodInterceptor.java:96)
>         at
> org.activeio.xnet.ServerService$$EnhancerByCGLIB$$463425f3.service(<generated>)
>         at
> org.activeio.xnet.ServicePool$2.run(ServicePool.java:67)
>         at org.activeio.xnet.ServicePool$3.run
> (ServicePool.java:90)
>         at
> org.apache.geronimo.pool.ThreadPool$ContextClassLoaderRunnable.run(ThreadPool.java:138)
>         at
> EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(Unknown
> Source)
>         at java.lang.Thread.run(Thread.java:595)
> Caused by: javax.ejb.TransactionRolledbackLocalException
>         at
> org.openejb.transaction.ContainerPolicy$TxRequired.invoke(ContainerPolicy.java:123)
>         at
> org.openejb.transaction.TransactionContextInterceptor.invoke
> (TransactionContextInterceptor.java:80)
>         at
> org.openejb.SystemExceptionInterceptor.invoke(SystemExceptionInterceptor.java:82)
>         at
> org.openejb.GenericEJBContainer.invoke(GenericEJBContainer.java:238)
>          at
> org.openejb.proxy.EJBMethodInterceptor.intercept(EJBMethodInterceptor.java:129)
>         at
> org.openejb.proxy.EntityEJBLocalHome$$EnhancerByCGLIB$$1847bc60.findByPrimaryKey(<generated>)
>         at
> br.cefetrn.olivier.session.MySessionBean.registrarLocacao
> (MySessionBean.java:71)
>         at
> br.cefetrn.olivier.session.MySessionBean$$FastClassByCGLIB$$fba7f7a3.invoke(<generated>)
>         at
> org.openejb.dispatch.AbstractMethodOperation.invoke(AbstractMethodOperation.java
> :90)
>         at
> org.openejb.sfsb.BusinessMethod.execute(BusinessMethod.java:66)
>         at
> org.openejb.dispatch.DispatchInterceptor.invoke(DispatchInterceptor.java:72)
>         at
> org.apache.geronimo.naming.java.ComponentContextInterceptor.invoke
> (ComponentContextInterceptor.java:56)
>         at
> org.openejb.ConnectionTrackingInterceptor.invoke(ConnectionTrackingInterceptor.java:81)
>         at
> org.openejb.sfsb.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java
> :115)
>         at
> org.openejb.transaction.ContainerPolicy$TxRequired.invoke(ContainerPolicy.java:140)
>         at
> org.openejb.transaction.TransactionContextInterceptor.invoke(TransactionContextInterceptor.java:80)
>          at
> org.openejb.SystemExceptionInterceptor.invoke(SystemExceptionInterceptor.java:82)
>         at
> org.openejb.GenericEJBContainer.invoke(GenericEJBContainer.java:238)
>         at org.openejb.server.ejbd.EjbRequestHandler.invoke
> (EjbRequestHandler.java:297)
>         ... 18 more
> Caused by: java.lang.ClassCastException:
> br.cefetrn.olivier.entity.CarroPK
>         at
> org.tranql.sql.jdbc.binding.StringBinding.setValue(StringBinding.java:43)
>          at
> org.tranql.sql.jdbc.binding.TypeConverterBinding.setValue(TypeConverterBinding.java:93)
>         at
> org.tranql.sql.jdbc.binding.TypeConverterBinding.setValue(TypeConverterBinding.java:89)
>         at org.tranql.sql.jdbc.JDBCQueryCommand.execute
> (JDBCQueryCommand.java:64)
>         at
> org.tranql.cache.cache.FindByPKCacheQueryCommand.execute(FindByPKCacheQueryCommand.java:66)
>         at
> org.openejb.entity.cmp.CMPFinder.execute(CMPFinder.java:99)
>         at
> org.openejb.entity.cmp.SingleValuedFinder.execute(SingleValuedFinder.java:80)
>         at
> org.openejb.dispatch.DispatchInterceptor.invoke(DispatchInterceptor.java:72)
>         at
> org.apache.geronimo.naming.java.ComponentContextInterceptor.invoke
> (ComponentContextInterceptor.java:56)
>         at
> org.openejb.ConnectionTrackingInterceptor.invoke(ConnectionTrackingInterceptor.java:81)
>         at
> org.openejb.entity.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java
> :136)
>         at
> org.openejb.entity.cmp.InTxCacheInterceptor.invoke(InTxCacheInterceptor.java:90)
>         at
> org.openejb.transaction.ContainerPolicy$TxRequired.invoke(ContainerPolicy.java:119)
>         ... 36 more
>
>
> On 4/4/06, Aaron Mulder <ammulder@alumni.princeton.edu> wrote:
> >
>  What's the actual problem?  When you call findByPrimaryKey, is it
> returning nothing, or giving you a stack trace, or what?
>
> I think your primary key class is supposed to have getters and setters
> for all the properties, with names matching the primary key fields on
> the bean.  So it may be that you need a getChassi and setChassi on the
> PK class to get it working.
>
> Thanks,
>     Aaron
>
> P.S. Ever played Car Wars?  :)
>
> On 4/4/06, Olivier Voutat < olivier.voutat@gmail.com> wrote:
> > I'm in trouble (again lol) with the findByPrimaryKey method.
> >
> > CarLocalHome localHomeCar = Locator.getCarLocalHome();
> > CarLocal tempcar = null;
> > try {
> >             Iterator temp =
> > localHomeCar.findBySituation("Avaliable").iterator();
> >             CarPK pk = new CarPK();
> >             while (temp.hasNext()) {
> >                 tempcar = (CarLocal)temp.next();
> >                 System.out.println("Primary Key " +
> > tempcar.getPrimaryKey().toString());
> >                 pk = (CarroPK)tempcar.getPrimaryKey();
> > }
> > System.out.println(pk.chassi );
> > System.out.println("Everything works fine until here.");
> >
> >  CarLocal mycar = localHomeCar.findByPrimaryKey(new CarPK("CHASSSICODE");
> > //HERE I don't get to pick my ejbLocalObjet by the primary key.
> >
> > CarLocal mycar = localHomeCar.findByPrimaryKey(pk);
> > //Tried this way too but no success
> >
> -------------------------------------------------------------------------------------------------------------------------------
> > // This is my CarPK class
> > package br.cefetrn.olivier.entity;
> >
> > import java.io.Serializable;
> >
> > public class CarPK implements Serializable {
> >
> >     private static final long serialVersionUID = 1L;
> >     public String chassi;
> >
> >     public CarroPK() {}
> >
> >     public CarroPK(String chas) {
> >         this.chassi = chas;
> >     }
> >
> >     public String toString() {
> >         return chassi.toString();
> >     }
> >
> >     public int hashCode() {
> >         return chassi.hashCode();
> >     }
> >
> >     public boolean equals(Object car) {
> >         return ((CarroPK)car).chassi.equals(chassi);
> >     }
> > }
> >
> -------------------------------------------------------------------------------------------------------------------------------
> > // This is my ejb-jar.xml code
> >     <entity>
> >         <ejb-name>Car</ejb-name>
> >
> >
> <local-home>br.cefetrn.olivier.entity.CarLocalHome</local-home>
> >         <local>br.cefetrn.olivier.entity.CarLocal
> </local>
> >
> > <ejb-class>br.cefetrn.olivier.entity.CarBean</ejb-class>
> >         <persistence-type>Container</persistence-type>
> >         <prim-key-class>br.cefetrn.olivier.entity.CarPK </prim-key-class>
> >     /////////////My PK class
> >         <reentrant>false</reentrant>
> >         <cmp-version>2.x</cmp-version>
> >         <abstract-schema-name>CARS</abstract-schema-name>
> >
> > <cmp-field><field-name>chassi</field-name></cmp-field>
> >
> >
> <cmp-field><field-name>manufacturer</field-name></cmp-field>
> >
> > <cmp-field><field-name>model</field-name></cmp-field>
> >
> > <cmp-field><field-name>plaque</field-name></cmp-field>
> >
> <cmp-field><field-name>km</field-name></cmp-field>
> >
> > <cmp-field><field-name>color</field-name></cmp-field>
> >
> > <cmp-field><field-name>situation</field-name></cmp-field>
> >
> > <cmp-field><field-name>type</field-name></cmp-field>
> >
> > <cmp-field><field-name>price</field-name></cmp-field>
> >         <resource-ref>
> >             <res-ref-name>Fire</res-ref-name>
> >                <res-type>javax.sql.DataSource</res-type>
> >                <res-auth>Container</res-auth>
> >
> > <res-sharing-scope>Shareable</res-sharing-scope>
> >         </resource-ref>
> >     </entity>
> >
> > Does anyone knows what I'm doing wrong in this findByPrimaryKey ?
> > Best Regards,
> > --
> > Olivier Voutat
> > Rua Praia de Muri�, 9188
>
> > Cep 59092-390 / Natal - RN
> > Tel: (84) 3219-0427 Cel: (84) 9977-3917
>
>
>
> --
> Olivier Jeanpierre Voutat
> Rua Praia de Muri�, 9188
>
> Cep 59092-390 / Natal - RN
> Tel: (84) 3219-0427 Cel: (84) 9977-3917
Mime
View raw message