Interesting, I'd like to know how did you manage to achieve this
result. Please, send a code snippet.
What is the transaction attribute for that bean method?
Oleg
On Friday 02 March 2001 19:50, JP wrote:
> Well, at least I'm getting a different error :-0 Using
> castor-0.8.11.jar or castor-0.9.jar (and castor-jdo.jar) built from
> the CVS tree I'm getting:
>
> [Interest] endresources(0): state=1
> [Interest] CONTAINER EXCEPTION:This transaction is not open
> [Interest] java.lang.IllegalStateException: This transaction is not
> open [Interest] at
> org.exolab.castor.jdo.engine.DatabaseImpl.afterCompletion(Dat
> abaseImpl.java:530)
> [Interest] at
> org.jboss.tm.TxCapsule.doAfterCompletion(TxCapsule.java:1120)
>
> [Interest] at
> org.jboss.tm.TxCapsule.commit(TxCapsule.java:329) [Interest]
> at
> org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:76)
> [Interest] at
> org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(Tx
> InterceptorCMT.java:318)
> [Interest] at
> org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCM
> T.java:99)
> [Interest] at
> org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInte
> rceptor.java:144)
> [Interest] at
> org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.ja
> va:192)
> [Interest] at
> org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessi
> onContainer.java:271)
> [Interest] at
> org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke
> (JRMPContainerInvoker.java:163)
> [Interest] at java.lang.reflect.Method.invoke(Native Method)
> [Interest] at
> sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.jav
> a:241)
> [Interest] at
> sun.rmi.transport.Transport$1.run(Transport.java:142) [Interest]
> at java.security.AccessController.doPrivileged(Native Method)
> [Interest] at
> sun.rmi.transport.Transport.serviceCall(Transport.java:139)
> [Interest] at
> sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTranspor
> t.java:443)
> [Interest] at
> sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPT
> ransport.java:643)
> [Interest] at java.lang.Thread.run(Thread.java:484)
>
> -----Original Message-----
> From: Oleg Nitz [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, March 01, 2001 2:03 PM
> To: JBoss-User
> Subject: Re: [jBoss-User] Castor JDO / jBoss integration error
>
>
> Hi,
>
> Yes, sorry, this is a bug in Castor 0.9
> (no such code in Castor 0.8.11 BTW).
> Either use a CVS version of Castor 0.9, or remove
> "|| ! _ctx.isOpen()" yourself and rebuild.
>
> Regards,
> Oleg
>
> On Thursday 01 March 2001 18:22, Nimbus Partners Ltd wrote:
> > Look at org.exolab.castor.jdo.engine.DatabaseImpl and
> > org.exolab.castor.persist.TransactionContext
> >
> > First of all JBoss calls beforeCompletion in DatabaseImpl
> >
> > if (_transaction == null || _ctx == null || ! _ctx.isOpen())
> > throw new IllegalStateException ..........
> > ...............
> > _ctx.prepare();
> >
> >
> > If all is ok TransactionContext changes transaction status on
> > STATUS_PREPARED
> >
> > Then JBoss calls afterCompletion
> > if (_transaction == null || _ctx == null || ! _ctx.isOpen())
> > throw new IllegalStateException ..........
> >
> > Now you have exception because of ctx.isOpen now return false!
> > TransactionContext.isOpen will only return true if status ==
> > STATUS_ACTIVE or status == STATUS_MARKED_ROLLBACK.
> > But our status is STATUS_PREPARED!
> >
> > So, is this a bug in Castor?
> >
> > Regards,
> >
> > Dmitri Ulitski
> >
> >
> > Thanks, that fixed the error I was getting. Now I'm getting
> > another:
> >
> > [Default] jBoss 2.0 FINAL Started
> > [Interest] Someone called `calculateCompoundInterest!'
> > [CastorJDO] SQL for creating Referrer: INSERT INTO
> > "SUBSCRIPTION_TYPES" ("ID") VALUES (?)
> > [CastorJDO] SQL for deleting Referrer: DELETE FROM
> > "SUBSCRIPTION_TYPES" WHERE "ID"=?
> > [CastorJDO] SQL for updating Referrer: UPDATE
> > "SUBSCRIPTION_TYPES" SET WHERE "ID"=?
> > [CastorJDO] SQL for loading Referrer: SELECT 1 FROM
> > "SUBSCRIPTION_TYPES" WHERE "SUBSCRIPTION_TYPES"."ID"=?
> > [CastorJDO] SELECT "SUBSCRIPTION_TYPES"."ID" FROM
> > "SUBSCRIPTION_TYPES" WHERE "SUBSCRIPTION_TYPES"."ID" = ?
> > [Interest] endresources(0): state=1
> > [Interest] CONTAINER EXCEPTION:This transaction is not open
> > [Interest] java.lang.IllegalStateException: This transaction is
> > not open [Interest] at
> > org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:72)
> > [Interest] at
> > org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInte
> >rc eptorCMT. java:318) [Interest] at
> > org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.ja
> >va
> >
> >:99) [Interest] at
> >
> > org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityIntercep
> >to r.java:14 4)
> > [Interest] at
> > org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:1
> >92 ) [Interest] at
> > org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionCo
> >nt ainer.jav a:271) [Interest] at
> > org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRM
> >PC ontainerI nvoker.java:163)
> > [Interest] at java.lang.reflect.Method.invoke(Native Method)
> > [Interest] at
> > sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:24
> >1) [Interest] at
> > sun.rmi.transport.Transport$1.run(Transport.java:142) [Interest]
> > at java.security.AccessController.doPrivileged(Native Method)
> > [Interest] at
> > sun.rmi.transport.Transport.serviceCall(Transport.java:139)
> > [Interest] at
> > sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.ja
> >va
> >
> >:443) [Interest] at
> >
> > sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTrans
> >po rt.java:6 43)
> > [Interest] at java.lang.Thread.run(Thread.java:484)
> >
> > Here's the code:
> > public double calculateCompoundInterest(double principle,
> > double rate, double periods) {
> >
> > System.out.println ("Someone called
> > `calculateCompoundInterest!'"); InitialContext ic = null;
> > DataObjects jdo = null;
> > Database db = null;
> >
> > try {
> > ic = new InitialContext();
> > jdo = (DataObjects) ic.lookup("java:comp/env/jdo/core");
> > db = jdo.getDatabase();
> >
> >
> > // Look up the product and if found in the database,
> > // delete this object from the database
> > OQLQuery productOql = db.getOQLQuery( "SELECT p FROM
> > Referrer p WHERE id = $1" );
> > productOql.bind( 99 );
> > QueryResults results = productOql.execute();
> > while ( results.hasMore() ) {
> > Referrer referrer = (Referrer) results.next();
> > System.out.println( "Deleting existing product: " +
> > referrer ); db.remove( referrer );
> > }
> >
> >
> > db.close();
> > } catch (Exception e) {
> > System.out.println("error doing jdo stuff");
> > e.printStackTrace();
> > }
> >
> > return principle * Math.pow(1+rate, periods) - principle;
> > }
> >
> > Here's the ejb-jar.xml:
> >
> > <?xml version="1.0" encoding="Cp1252"?>
> > <ejb-jar>
> > <description>jBoss test application</description>
> > <display-name>Test</display-name>
> > <enterprise-beans>
> > <session>
> > <ejb-name>Interest</ejb-name>
> > <home>com.trafficstation.interest.InterestHome</home>
> > <remote>com.trafficstation.interest.Interest</remote>
> > <ejb-class>com.trafficstation.interest.InterestBean</ejb-class>
> > <session-type>Stateless</session-type>
> > <transaction-type>Container</transaction-type>
> >
> > <resource-ref>
> > <description>DataObjects factory</description>
> > <res-ref-name>jdo/core</res-ref-name>
> > <res-type>org.exolab.castor.jdo.DataObjects</res-type>
> > <res-auth>Container</res-auth>
> > </resource-ref>
> >
> > </session>
> > </enterprise-beans>
> >
> > <assembly-descriptor>
> > <container-transaction>
> > <method>
> > <ejb-name>Interest</ejb-name>
> > <method-name>*</method-name>
> > </method>
> > <trans-attribute>Required</trans-attribute>
> > </container-transaction>
> > </assembly-descriptor>
> >
> > </ejb-jar>
> >
> > -----Original Message-----
> > From: Oleg Nitz [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, February 28, 2001 5:05 AM
> > To: JBoss-User
> > Subject: Re: [jBoss-User] Castor JDO / jBoss integration error
> >
> >
> > Hi,
> >
> > JDO.getDatabase() must be called in a transaction context.
> > I.e. if you have a bean with Bean Managed Transactions (BMT),
> > you should call
> > ut = _context.getUserTransaction();
> > ut.begin();
> > before
> > db = jdo.getDatabase();
> > If you have a bean with Container Managed Transactions (CMT),
> > you should set either "Required" or "RequiresNew" transaction
> > attribute for the method where getDatabase() is called.
> > Transactions attributes are set in ejb-jar.xml.
> >
> > Regards,
> > Oleg
> >
> > JP wrote:
> > > I'm trying to get Castor to run with Jboss. I'm completely new
> > > to
> >
> > EJB/jBoss
> >
> > > and Castor. So I'm assuming I've screwed up my configuration.
> > >
> > > Within Castor's JDO.java tm.getTransaction() is returning null
> > > which is
> >
> > then
> >
> > > causing things to blow up. (_tmName="java:/TransactionManager"
> > > and is returning a org.jboss.tm.TxManager from JNDI)
> > >
> > > try {
> > > if(tm == null) {
> > > ctx = new InitialContext();
> > > tm = (TransactionManager) ctx.lookup(
> > > _tmName ); }
> >
> > RETURNS NULL>>>> tx = tm.getTransaction();
> >
> > > if ( tx.getStatus() == Status.STATUS_ACTIVE ) {
> > > dbImpl = new DatabaseImpl( _dbName,
> > > _lockTimeout, _logInterceptor, tx, _classLoader );
> > > tx.registerSynchronization( dbImpl );
> > > return dbImpl;
> > > }
> > > } catch ( NoInitialContextException except ) {
> > >
> > >
> > > [CastorJDO] java.lang.NullPointerException
> > > [CastorJDO] at
> > > org.exolab.castor.jdo.JDO.getDatabase(JDO.java:482) [CastorJDO]
> > > at org.jboss.jdo.castor.CastorJDOImpl.getDatabase
> > > CastorJDOImpl.java:142)
> > > [CastorJDO] at
> >
> > com.trafficstation.interest.InterestBean.calculateCompoundInteres
> >t( InterestB
> >
> > > ean.java:47)
> > > [CastorJDO] at java.lang.reflect.Method.invoke(Native Method)
> > > [CastorJDO] at
> >
> > org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invo
> >ke (Stateles
> >
> > > sSessionContainer.java:472)
> > > [CastorJDO] at
> > > org.jboss.ejb.plugins.TxInterceptorBMT.invoke(TxInterceptorBMT.
> > >ja va:254) [CastorJDO] at
> >
> > org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(
> >St atelessSe
> >
> > > ssionInstanceInterceptor.java:87)
> > > [CastorJDO] at
> >
> > org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityIntercep
> >to r.java:14
> >
> > > 4)
> > > [CastorJDO] at
> > > org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java
> > >:1 92) [CastorJDO] at
> >
> > org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionCo
> >nt ainer.jav
> >
> > > a:271)
> > > [CastorJDO] at
> >
> > org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRM
> >PC ontainerI
> >
> > > nvoker.java:163)
> > > [CastorJDO] at java.lang.reflect.Method.invoke(Native Method)
> > > [CastorJDO] at
> > > sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:
> > >24 1) [CastorJDO] at
> > > sun.rmi.transport.Transport$1.run(Transport.java:142)
> > > [CastorJDO] at
> > > java.security.AccessController.doPrivileged(Native Method)
> > > [CastorJDO] at
> >
> > sun.rmi.transport.Transport.serviceCall(Transport.java:139)
> >
> > > [CastorJDO] at
> > > sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.
> > >ja va:443) [CastorJDO] at
> >
> > sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTrans
> >po rt.java:6
> >
> > > 43)
> > > [CastorJDO] at java.lang.Thread.run(Thread.java:484)
> > >
> > >
> > > --
> > > --------------------------------------------------------------
> > > To subscribe: [EMAIL PROTECTED]
> > > To unsubscribe: [EMAIL PROTECTED]
> > > List Help?: [EMAIL PROTECTED]
> >
> > --
> > --------------------------------------------------------------
> > To subscribe: [EMAIL PROTECTED]
> > To unsubscribe: [EMAIL PROTECTED]
> > List Help?: [EMAIL PROTECTED]
> >
> >
> > --
> > --------------------------------------------------------------
> > To subscribe: [EMAIL PROTECTED]
> > To unsubscribe: [EMAIL PROTECTED]
> > List Help?: [EMAIL PROTECTED]
> >
> >
> >
> > --
> > --------------------------------------------------------------
> > To subscribe: [EMAIL PROTECTED]
> > To unsubscribe: [EMAIL PROTECTED]
> > List Help?: [EMAIL PROTECTED]
>
> --
> --------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
>
>
> --
> --------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]