Phillip Blevins wrote:
Greetings,
I keep getting an error stating that "OJB can't open database". However I'm sure the repository.xml file is in the classpath. I've put several evenings into to figuring this out and am unable to find a solution. It seems like it is unable to find the repository.xml file. I initially try this in a Struts project but I thought that maybe that fact that some of the depended libraries were a higher version then what came with the 1.0.1 download that this might be messing things up. I then moved it to a two class project in eclipse and added all the libraries that came with OJB 1.0.1, and I received the same error.
Thanks for any Help! Phillip Blevins
here is my connection code public static void storeCountry() { CountryVO cc = new CountryVO(); cc.setArms(10); cc.setArtisans(10); cc.setDefense(11); cc.setName("Chi Chan"); cc.setNumber(10);
Implementation odmg = OJB.getInstance(); Database db = odmg.newDatabase();
try{ //db.open("default#pblevins#friend", Database.OPEN_READ_WRITE); //db.open("repository.xml", Database.OPEN_READ_WRITE); db.open("default", Database.OPEN_READ_WRITE); }catch (ODMGException ex){ ex.printStackTrace(); }
/* ... use the database ... */
try{ Implementation impl = OJB.getInstance(); Transaction tx = impl.newTransaction(); tx.begin(); tx.lock(cc, Transaction.WRITE); tx.commit();
db.close(); }catch (org.odmg.ODMGException ee){ ee.printStackTrace(); } }
This Would be my error:
(core.PersistenceBrokerFactoryDefaultImpl ? ) Create
PersistenceBroker instance pool, pool configuration was
{whenExhaustedAction=0, maxIdle=-1, maxActive=100, maxWait=2000,
removeAbandoned=false, numTestsPerEvictionRun=10, testWhileIdle=false,
minEvictableIdleTimeMillis=1000000, testOnReturn=false,
logAbandoned=false, removeAbandonedTimeout=300,
timeBetweenEvictionRunsMillis=-1, testOnBorrow=false}
(metadata.RepositoryPersistor ? ) OJB Descriptor Repository:
file:/C:/Program%20Files/eclipse3.0/workspace/TSSt/bin/repository.xml
(metadata.RepositoryPersistor ? ) Building repository from
:file:/C:/Program%20Files/eclipse3.0/workspace/TSSt/bin/repository.xml
(metadata.MetadataManager ? ) No repository.xml file
found, starting with empty metadata and connection configuration
(metadata.MetadataManager ? ) No 'default-connection'
attribute set in jdbc-connection-descriptors, thus it's currently not
possible to use 'defaultPersistenceBroker()' convenience method to
lookup PersistenceBroker instances. But it's possible to enable this
at runtime using 'setDefaultKey' method.
(metadata.ConnectionRepository ? ) Could not find
org.apache.ojb.broker.metadata.JdbcConnectionDescriptor for PBKey
org.apache.ojb.broker.PBKey: jcdAlias=default, user=null,
password=null
(odmg.DatabaseImpl ? ) Open database failed:
Borrow broker from pool failed, using PBKey
org.apache.ojb.broker.PBKey: jcdAlias=default, user=null,
password=null
org.apache.ojb.broker.PBFactoryException: Borrow broker from pool
failed, using PBKey org.apache.ojb.broker.PBKey: jcdAlias=default,
user=null, password=null
at org.apache.ojb.broker.core.PersistenceBrokerFactoryDefaultImpl.createPersistenceBroker(Unknown
Source)
at org.apache.ojb.broker.PersistenceBrokerFactory.createPersistenceBroker(Unknown
Source)
at org.apache.ojb.odmg.DatabaseImpl.open(Unknown Source)
at CountryDA.main(CountryDA.java:33)
Caused by: org.apache.ojb.broker.PBFactoryException: Given PBKey
org.apache.ojb.broker.PBKey: jcdAlias=default, user=null,
password=null does not match in metadata configuration
at org.apache.ojb.broker.core.PersistenceBrokerFactoryBaseImpl.createNewBrokerInstance(Unknown
Source)
at org.apache.ojb.broker.core.PersistenceBrokerFactoryDefaultImpl$PBKeyedPoolableObjectFactory.makeObject(Unknown
Source)
at org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:792)
... 4 more
org.odmg.DatabaseNotFoundException: OJB can't open database default
Borrow broker from pool failed, using PBKey
org.apache.ojb.broker.PBKey: jcdAlias=default, user=null,
password=null
at org.apache.ojb.odmg.DatabaseImpl.open(Unknown Source)
at CountryDA.main(CountryDA.java:33)
org.odmg.DatabaseClosedException: Database is NULL, must have a DB in
order to create a transaction
at org.apache.ojb.odmg.ImplementationImpl.newTransaction(Unknown Source)
at CountryDA.main(CountryDA.java:42)
Exception in thread "main"
The error states that OJB could not find the repository.xml file on the classpath, so check its position: for a webapp put it into WEB-INF/classes along with OJB.properties and also don't put OJB into the server's shared lib folder but into the WEB-INF/lib folder of your webapp.
Tom
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]