RE: How to specify non-default DataSource for ODMG/PB api in different scenarios?
I looked into the relevent OJB source a little, and am curious if this would be a valid solution: Instead of using Transaction tx = odmg.currentTransaction(); tx.lock(obj, Transaction.WRITE); use Database db = odmg.getDatabase(jcdAlias); db.makePersistent(obj); would this achieve the same thing? Alex -Original Message- From: Alex Bates [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 02, 2003 1:21 AM To: OJB Users List; Armin Waibel Subject: RE: How to specify non-default DataSource for ODMG/PB api in different scenarios? Armin, Thanks for the description. I forgot to mention, I'm using EJBs that I modelled after the OJB sample EJBs. So, for my ODMG save methods, I'm using Transaction tx = odmg.currentTransaction(); tx.lock(obj, Transaction.WRITE); Where odmg is created by a factory in the ejbCreate method as follows; public class PersistenceManagerBean implements SessionBean { private Implementation odmg; private Database db; ODMGFactory factory = (ODMGFactory)context.lookup(OjbConstants.ODMG_FACTORY_LOOKUP); odmg = factory.getInstance(); db = odmg.newDatabase(); Since the currentTransaction method doesn't appear to have any way to pass in a jdcAlias, I'm not sure how to pass it in in my persist methods. In fact, looking closer at the OJB example EJBs, the save methods don't even use the Database db member, they just use Transaction tx = odmg.currentTransaction(); tx.lock(obj, Transaction.WRITE); How would I specify the jdcAlias in this case? Thx, Alex -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Sunday, August 31, 2003 12:47 AM To: OJB Users List Subject: Re: How to specify non-default DataSource for ODMG/PB api in different scenarios? Hi Alex, > > > do you mean changing the used DataSource within > > a transaction or only how to use multiple databases? > > Only how to use with multiple DataSources (each with a different database > login and different privelages). i.e. I've defined multiple DataSources in > JBoss. > Define for each DataSource a jdbc-connection-descriptor. PB-api: Use the defined jcdAlias name and PBKey to lookup the different DataSources PBKey user_1 = new PBKey(jcdAlias,username, passwd); PersistenceBroker broker = PersistenceBrokerFactory.createPersistenceBroker(user_1); ODMG-api: Use jcdAlias name to lookup different DataSources Implementation odmg = OJB.getInstance(); Database db = odmg.newDatabase(); db.open("jcdAlias#username#passwd", Database.OPEN_READ_WRITE); see http://db.apache.org/ojb/faq.html (or in shipped docs) sections 'How do I use multiple databases within OJB?' 'Many different database user - How do they login?' 'Needed to put user/password of database connection in repository file?' HTH regards, Armin > Thanks, > > Alex > > -Original Message- > From: Armin Waibel [mailto:[EMAIL PROTECTED] > Sent: Saturday, August 30, 2003 5:01 PM > To: OJB Users List > Subject: Re: How to specify non-default DataSource for ODMG/PB api in > different scenarios? > > > Hi Alex, > > - Original Message - > From: "Bates, Alex" <[EMAIL PROTECTED]> > To: "'OJB Users List'" <[EMAIL PROTECTED]> > Sent: Friday, August 29, 2003 10:31 PM > Subject: How to specify non-default DataSource for ODMG/PB api in > different scenarios? > > > > Hello, > > > > I'm using the ODMG/PB APIs in the following situations; in each I need > to be > > able to tell OJB to use a named DataSource (defined in > > repository_database.xml) other than the default. Any help would be > > appreciated - > > > > do you mean changing the used DataSource within > a transaction or only how to use multiple databases? > > regards, > Armin > > > -- > > > > Transaction tx = odmg.currentTransaction(); > > tx.lock(obj, Transaction.WRITE); > > > > -- > > > > db = odmg.getDatabase(null); > > db.deletePersistent(obj); > > > > -- > > > > PersistenceBroker broker = ((HasBroker) > > odmg.currentTransaction()).getBroker(); > > Connection conn = null; > > try { > > conn = > broker.serviceConnectionManager().getConnection(); > > } catch (LookupException e) { > > e.printStackTrace(); > > } > > > > -- > > > > // Must mark object as dirty to signal OJB to persist > > Transaction tx = odmg.currentTransaction(); > > ((NarrowTransaction)tx).mar
RE: How to specify non-default DataSource for ODMG/PB api in different scenarios?
Armin, Thanks for the description. I forgot to mention, I'm using EJBs that I modelled after the OJB sample EJBs. So, for my ODMG save methods, I'm using Transaction tx = odmg.currentTransaction(); tx.lock(obj, Transaction.WRITE); Where odmg is created by a factory in the ejbCreate method as follows; public class PersistenceManagerBean implements SessionBean { private Implementation odmg; private Database db; ODMGFactory factory = (ODMGFactory)context.lookup(OjbConstants.ODMG_FACTORY_LOOKUP); odmg = factory.getInstance(); db = odmg.newDatabase(); Since the currentTransaction method doesn't appear to have any way to pass in a jdcAlias, I'm not sure how to pass it in in my persist methods. In fact, looking closer at the OJB example EJBs, the save methods don't even use the Database db member, they just use Transaction tx = odmg.currentTransaction(); tx.lock(obj, Transaction.WRITE); How would I specify the jdcAlias in this case? Thx, Alex -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Sunday, August 31, 2003 12:47 AM To: OJB Users List Subject: Re: How to specify non-default DataSource for ODMG/PB api in different scenarios? Hi Alex, > > > do you mean changing the used DataSource within > > a transaction or only how to use multiple databases? > > Only how to use with multiple DataSources (each with a different database > login and different privelages). i.e. I've defined multiple DataSources in > JBoss. > Define for each DataSource a jdbc-connection-descriptor. PB-api: Use the defined jcdAlias name and PBKey to lookup the different DataSources PBKey user_1 = new PBKey(jcdAlias,username, passwd); PersistenceBroker broker = PersistenceBrokerFactory.createPersistenceBroker(user_1); ODMG-api: Use jcdAlias name to lookup different DataSources Implementation odmg = OJB.getInstance(); Database db = odmg.newDatabase(); db.open("jcdAlias#username#passwd", Database.OPEN_READ_WRITE); see http://db.apache.org/ojb/faq.html (or in shipped docs) sections 'How do I use multiple databases within OJB?' 'Many different database user - How do they login?' 'Needed to put user/password of database connection in repository file?' HTH regards, Armin > Thanks, > > Alex > > -Original Message- > From: Armin Waibel [mailto:[EMAIL PROTECTED] > Sent: Saturday, August 30, 2003 5:01 PM > To: OJB Users List > Subject: Re: How to specify non-default DataSource for ODMG/PB api in > different scenarios? > > > Hi Alex, > > - Original Message - > From: "Bates, Alex" <[EMAIL PROTECTED]> > To: "'OJB Users List'" <[EMAIL PROTECTED]> > Sent: Friday, August 29, 2003 10:31 PM > Subject: How to specify non-default DataSource for ODMG/PB api in > different scenarios? > > > > Hello, > > > > I'm using the ODMG/PB APIs in the following situations; in each I need > to be > > able to tell OJB to use a named DataSource (defined in > > repository_database.xml) other than the default. Any help would be > > appreciated - > > > > do you mean changing the used DataSource within > a transaction or only how to use multiple databases? > > regards, > Armin > > > -- > > > > Transaction tx = odmg.currentTransaction(); > > tx.lock(obj, Transaction.WRITE); > > > > -- > > > > db = odmg.getDatabase(null); > > db.deletePersistent(obj); > > > > -- > > > > PersistenceBroker broker = ((HasBroker) > > odmg.currentTransaction()).getBroker(); > > Connection conn = null; > > try { > > conn = > broker.serviceConnectionManager().getConnection(); > > } catch (LookupException e) { > > e.printStackTrace(); > > } > > > > -- > > > > // Must mark object as dirty to signal OJB to persist > > Transaction tx = odmg.currentTransaction(); > > ((NarrowTransaction)tx).markDirty(obj); > > > > --- > > > > > > Thanks! > > > > Alex > > > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to specify non-default DataSource for ODMG/PB api in different scenarios?
> do you mean changing the used DataSource within > a transaction or only how to use multiple databases? Only how to use with multiple DataSources (each with a different database login and different privelages). i.e. I've defined multiple DataSources in JBoss. Thanks, Alex -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Saturday, August 30, 2003 5:01 PM To: OJB Users List Subject: Re: How to specify non-default DataSource for ODMG/PB api in different scenarios? Hi Alex, - Original Message - From: "Bates, Alex" <[EMAIL PROTECTED]> To: "'OJB Users List'" <[EMAIL PROTECTED]> Sent: Friday, August 29, 2003 10:31 PM Subject: How to specify non-default DataSource for ODMG/PB api in different scenarios? > Hello, > > I'm using the ODMG/PB APIs in the following situations; in each I need to be > able to tell OJB to use a named DataSource (defined in > repository_database.xml) other than the default. Any help would be > appreciated - > do you mean changing the used DataSource within a transaction or only how to use multiple databases? regards, Armin > -- > > Transaction tx = odmg.currentTransaction(); > tx.lock(obj, Transaction.WRITE); > > -- > > db = odmg.getDatabase(null); > db.deletePersistent(obj); > > -- > > PersistenceBroker broker = ((HasBroker) > odmg.currentTransaction()).getBroker(); > Connection conn = null; > try { > conn = broker.serviceConnectionManager().getConnection(); > } catch (LookupException e) { > e.printStackTrace(); > } > > -- > > // Must mark object as dirty to signal OJB to persist > Transaction tx = odmg.currentTransaction(); > ((NarrowTransaction)tx).markDirty(obj); > > --- > > > Thanks! > > Alex > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to deploy OJB on Jboss 3.2
Armin, I'm not sure about xdoclet - since this requirement just came out in 3.2 would guess not. Unless they have some sort of 'custom' tag that lets you insert your own element. Alex -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Friday, June 20, 2003 12:45 AM To: OJB Users List Subject: Re: How to deploy OJB on Jboss 3.2 Hi Alex, great news! Many thanks. Does xdoclet support the element? regards, Armin - Original Message - From: "Bates, Alex" <[EMAIL PROTECTED]> To: "OJB Users List" <[EMAIL PROTECTED]> Sent: Friday, June 20, 2003 2:49 AM Subject: How to deploy OJB on Jboss 3.2 > Armin, > > Found the fix to get OJB to deploy (without having to redeploy) on JBoss 3.2 > with its new classloader scheme. > > The jboss.xml from db-ojb-1.0.rc2-beans.jar must be modified to this: (the > change is a new depends element added in) > > > jboss.xml > > > "http://www.jboss.org/j2ee/dtd/jboss.dtd";> > > > > > > > ODMGSessionBean > org.apache.ojb.ejb.ODMGSessionBean > > org.apache.ojb.ejb.ODMGSessionBeanLocal > optional-attribute-name="Invoker">jboss:service=invoker,type=jrmp > > > PBSessionBean > org.apache.ojb.ejb.PBSessionBean > > org.apache.ojb.ejb.PBSessionBeanLocal > optional-attribute-name="Invoker">jboss:service=invoker,type=jrmp > > > ArticleManagerODMGBean > org.apache.ojb.ejb.ArticleManagerODMGBean > > org.apache.ojb.ejb.ArticleManagerODMGBeanLocal name> > optional-attribute-name="Invoker">jboss:service=invoker,type=jrmp > > > ArticleManagerPBBean > org.apache.ojb.ejb.ArticleManagerPBBean > > org.apache.ojb.ejb.ArticleManagerPBBeanLocal me> > optional-attribute-name="Invoker">jboss:service=invoker,type=jrmp > > > PersonArticleManagerODMGBean > > org.apache.ojb.ejb.PersonArticleManagerODMGBean > > org.apache.ojb.ejb.PersonArticleManagerODMGBeanLocal -jndi-name> > optional-attribute-name="Invoker">jboss:service=invoker,type=jrmp > > > PersonArticleManagerPBBean > > org.apache.ojb.ejb.PersonArticleManagerPBBean > > org.apache.ojb.ejb.PersonArticleManagerPBBeanLocal ndi-name> > optional-attribute-name="Invoker">jboss:service=invoker,type=jrmp > > > PersonManagerODMGBean > org.apache.ojb.ejb.PersonManagerODMGBean > > org.apache.ojb.ejb.PersonManagerODMGBeanLocal ame> > optional-attribute-name="Invoker">jboss:service=invoker,type=jrmp > > > PersonManagerPBBean > org.apache.ojb.ejb.PersonManagerPBBean > > org.apache.ojb.ejb.PersonManagerPBBeanLocal e> > optional-attribute-name="Invoker">jboss:service=invoker,type=jrmp > > > > > > > > > > > -Original Message- > From: Bates, Alex > Sent: Wednesday, June 18, 2003 9:37 PM > To: OJB Users List > Subject: RE: OJB/JBoss "depends on me" startup problem - but redeployment > works fine! > > > > I heard back from the Jboss newsgroup on this one. But not sure exactly how > to implement the workaround (Adrian's #3 seems like the best bet). > > Below is the response from Adrian Bock, JBoss Director of Support - > > -Original Message- > From: Adrian Brock [mailto:[EMAIL PROTECTED] > Sent: Wednesday, June 18, 2003 6:42 PM > To: [EMAIL PROTECTED] > Subject: RE: [JBoss-user] "depends on me" startup problem - but redeployment > works fine! > > > Hi, > > The changes to the way the transaction manager is > deployed have highlighted this problem. > > The root problem is that an ejb shouldn't be > deployed until its declared invokers have started. > > There are a number of possible workarounds: > 1) Make the EJB Deployer depend upon the invoker > (no ejbs will be deployed until the invoker starts) > 2) Move the transaction manager deployment > back into jboss-service.xml (allowing the invoker > to start before the scanner starts looking at /deploy) > 3) Declare a dependency for each ejb on the invoker(s) > in jboss.xml > > The real fix will be to make (3) automatic. > > Regards, > Adrian > > > Adrian Brock > Director of Support > Back Office > JBoss Group, LLC > > > > > -Original Message- > > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] On Behalf Of > > Bates, Alex > > Sent: 19 June 2003 01:52 > > To: [EMAIL PROTECTED] > > Subject: [JBoss-user] "depends on me" startup problem - but > > redeployment works fine! > > > > > > > > I'm trying to deploy Apache OJB in Jboss 3.2.0 as ojb.sar, with two > > MBeans defined in jboss-service.xml. > > > > This packaging structure worked fine in Jboss 3.0.6, but in 3.2 lots > > of exceptions are thrown at init, followed by the "depends on > > me" message shown > > below. The root problem appears to be the "invoker is null" error > > (jboss:service=invoker,type=jrmp) > > > > Yet, if I redeploy my EJB by copying db-o
RE: OJB/JBoss "depends on me" startup problem - but redeployment works fine!
Thanks for the followup Armin. I'm going to post a question to the JBoss newsgroup and investigate further...will post anything I find out. I know they've been making numerous changes to the classloader to support hot redeployment (in the process making cold deployment harder!) Alex -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 17, 2003 10:45 PM To: OJB Users List Subject: Re: OJB/JBoss "depends on me" startup problem - but redeployment works fine! Hi Alex, I can confirm this. With JBoss 3.0.6 all works fine, changing to JBoss 3.2.1 get the described problems when deploying the beans. Redepolying the beans, all get deployed without problems. I can't figure out what's going wrong. > So, it appears that this EJB jar has some dependencies which need to be > explicitly declared in JBoss. Would be great if you could bring to light the hidden secrets of current JBoss version ;-) regards, Armin - Original Message - From: "Swordsman 2000" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, June 17, 2003 11:04 PM Subject: OJB/JBoss "depends on me" startup problem - but redeployment works fine! > Hello, > > When I try to bring up the j2ee build of OJB in JBoss, I get lots of stack > traces, and finally see the message shown below. The root problem appears > to be the "invoker is null" error (jboss:service=invoker,type=jrmp) > > Has anyone else encountered these errors/exceptoins? Am I missing > something? I used the jboss-service.xml file as instructed, have all the > relevent files in the ojb.sar directory (running in JBoss 3.2.0), but get > this problem. Yet, if I redeploy by copying db-ojb-1.0.rc2-beans.jar (the > EJB jar) back into the ojb.sar after bringing up JBoss, it works fine!! > > So, it appears that this EJB jar has some dependencies which need to be > explicitly declared in JBoss. > > Thanks in advance for any help! > > Alex > > > 13:51:24,051 ERROR [URLDeploymentScanner] MBeanException: Exception in MBean > ope > ration 'checkIncompleteDeployments()' > Cause: Incomplete Deployment listing: > Packages waiting for a deployer: > > Incompletely deployed packages: > > MBeans waiting for classes: > > MBeans waiting for other MBeans: > [ObjectName: > jboss.j2ee:jndiName=org.apache.ojb.ejb.PersonManagerPBBean,service= > EJB > state: FAILED > I Depend On: > Depends On Me: java.lang.RuntimeException: invoker is null: > jboss:service=invok > er,type=jrmp, ObjectName: > jboss.j2ee:jndiName=org.apache.ojb.ejb.ArticleManagerP > BBean,service=EJB > state: FAILED > I Depend On: > Depends On Me: java.lang.RuntimeException: invoker is null: > jboss:service=invok > er,type=jrmp, ObjectName: > jboss.j2ee:jndiName=org.apache.ojb.ejb.PersonManagerOD > MGBean,service=EJB > state: FAILED > I Depend On: > Depends On Me: java.lang.RuntimeException: invoker is null: > jboss:service=invok > er,type=jrmp, ObjectName: > jboss.j2ee:jndiName=org.apache.ojb.ejb.PBSessionBean,s > ervice=EJB > state: FAILED > I Depend On: > Depends On Me: java.lang.RuntimeException: invoker is null: > jboss:service=invok > er,type=jrmp, ObjectName: > jboss.j2ee:jndiName=org.apache.ojb.ejb.PersonArticleMa > nagerODMGBean,service=EJB > state: FAILED > I Depend On: > Depends On Me: java.lang.RuntimeException: invoker is null: > jboss:service=invok > er,type=jrmp, ObjectName: > jboss.j2ee:jndiName=org.apache.ojb.ejb.ODMGSessionBean > ,service=EJB > state: FAILED > I Depend On: > Depends On Me: java.lang.RuntimeException: invoker is null: > jboss:service=invok > er,type=jrmp, ObjectName: > jboss.j2ee:jndiName=org.apache.ojb.ejb.PersonArticleMa > nagerPBBean,service=EJB > state: FAILED > I Depend On: > Depends On Me: java.lang.RuntimeException: invoker is null: > jboss:service=invok > er,type=jrmp, ObjectName: > jboss.j2ee:jndiName=org.apache.ojb.ejb.ArticleManagerO > DMGBean,service=EJB > state: FAILED > I Depend On: > Depends On Me: java.lang.RuntimeException: invoker is null: > jboss:service=invok > er,type=jrmp] > > > META-INF\jboss-service.xml > > > > name="DefaultDomain:service=PBAPI,name=ojb/PBAPI"> > jboss.jca:service=RARDeployer > ojb/PBAPI > > > name="DefaultDomain:service=ODMG,name=ojb/defaultODMG"> > jboss.jca:service=RARDeployer > ojb/defaultODMG > > > > _ > Protect your PC - get McAfee.com VirusScan Online > http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional
OJB read/write cache - beware the synchronized bottleneck
Has anyone implemented a read/write cache for use with OJB? This article goes over how to implement, and links to some code for ReadWriteLock (and ConcurrentHashMap): http://www.theserverside.com/resources/article.jsp?l=Readers-Writers However, my real question is: would it be possible to implement such a cache for use with the J2EE version of OJB? Since you can't use threads or the threading API, it appears it would not. If that's the case, I supposed the read/write cache would only be able to run in the servlet layer? Alex - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: OJB + commercial JDO ?
Thomas, Thanks for the reply. My question actually stemmed from some others working on the project, who wanted to make sure our solution could integrate if a given client had already purchased a commercial JDO implementation. If we had to do this, I wanted to shield applications sitting on top of OJB from the underlying implementation. Personally, I like OJB's APIs and mapping files better than those put out by the JDO spec. ESPECIALLY your query APIs, I don't want to write any *QL. Well, I'm happy to write SQL, but not OQL, JDOQL, or EJBQL. However, the real need was to be able to integrate with a distributed cache like Tangosol. So I was happy to see Jason McKerr's recent email/blog about integrating OJB + Tangosol! Alex -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Sunday, June 01, 2003 11:10 AM To: OJB Users List Subject: Re: OJB + commercial JDO ? Hi Alex, I have no idea what kind of integration you are looking for. If you are using a commercial JDO O/R tool why should you use OJB? Or are you looking for that kind of integration that we did with the OJB JDORI plugin for SUN's JDO RI? If so it depends on the layering of the commercial tool. Maybe it's as easy as for the OJB JDORI plugin. But if there is no clear layering than it will be a lot of work. cheers, Thomas Bates, Alex wrote: > Has anyone used OJB with a commercial JDO implementation? (esp. Solar > Metric?) If so, could you give an idea of the work required to integrate > the two? > > thanks, > > Alex > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]