The default repository (as specified in OJB.properties) is always needed for OJB internal operations (e.g. getting ClassDescriptors etc.).
> -----Urspr�ngliche Nachricht----- > Von: Christian Pietsch [mailto:[EMAIL PROTECTED]] > Gesendet: Donnerstag, 12. September 2002 11:54 > An: [EMAIL PROTECTED] > Betreff: Storing OJB.properties and repository.xml outside classpath > > > First a warm hello to this list. I'm ojb-newbie from germany and > impressed of the simplicity using ojb. > > After playing around with the tutorials (especially the odmg package) > and the built in tests I'm trying to use ojb for my application. For > portabilty issues I do not want to store configuration files > within the > classpath but specify their location in the preferences using > java.util.prefs.Preferences . > > I've read on ojb-homepage that I can set a property with the > location of > my own OJB.property like this > > System.setProperty("OJB.properties","E:/cvs.root/asterixs/buil > d/ojb/OJB. > properties"); > > This part works fine. OJB properties are loaded correctly. > > But furthermore I also want to specify the location of > repository.xml (I > don't want to use the property "repositoryFile" from > ojb.properties). In > tutorial2 it seems to be possible just to set path to > repository.xml via > the org.odmg.Database-open() method: > db.open("E:/cvs.root/asterixs/build/ojb/repository.xml", > Database.OPEN_READ_WRITE); > > This part works fine too. But when I create a OQLQuery I'm getting a > java.io.FileNotFoundException: C:\Documents and > Settings\cp\jbproject\asterixs\repository.xml (The system cannot find > the file specified). Why does OQLQuery also try to open the > repository.xml? > > I hope anybody can help to solve my problem or show me an alternative > way. > > Bye > Chris > > PS: here is the exception followed by the source code. > > [BOOT] INFO: OJB.properties: > file:/E:/cvs.root/asterixs/build/ojb/OJB.properties > (dao.T 47 ) trying: > E:/cvs.root/asterixs/build/ojb/repository.xml > 0 [main] INFO de.asterixs.dao.T - trying: > E:/cvs.root/asterixs/build/ojb/repository.xml > [org.apache.ojb.broker.ta.PersistenceBrokerFactoryDefaultImpl] INFO: > Already created persistence broker instances: 0 > [org.apache.ojb.broker.util.sequence.SequenceManagerFactory] INFO: Use > sequence manager class: class > org.apache.ojb.broker.util.sequence.SequenceManagerHiLoImpl > [org.apache.ojb.broker.accesslayer.AbstractPoolableConnectionFactory] > INFO: # Create connection pool for JdbcDescriptorKey 1554939735 # > [org.apache.ojb.broker.accesslayer.AbstractConnectionFactory] INFO: # > Already created connections: 1 returning : > com.microsoft.jdbc.sqlserver.SQLServerConnection@2c7568 > java.io.FileNotFoundException: C:\Documents and > Settings\cp\jbproject\asterixs\repository.xml (The system cannot find > the file specified) > at java.io.FileInputStream.open(Native Method) > at java.io.FileInputStream.<init>(FileInputStream.java:103) > at java.io.FileInputStream.<init>(FileInputStream.java:66) > at > sun.net.www.protocol.file.FileURLConnection.connect(FileURLCon > nection.ja > va:69) > at > sun.net.www.protocol.file.FileURLConnection.getInputStream(Fil > eURLConnec > tion.java:148) > at java.net.URL.openStream(URL.java:955)[DEFAULT] FATAL: > C:\Documents and Settings\cp\jbproject\asterixs\repository.xml (The > system cannot find the file specified) > > at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown > Source) > at > org.apache.xerces.impl.XMLEntityManager.startDocumentEntity(Unknown > Source) > at > org.apache.xerces.impl.XMLDocumentScannerImpl.setInputSource(Unknown > Source) > at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown > Source) > at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown > Source) > at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) > at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown > Source) > at > org.apache.ojb.broker.metadata.RepositoryPersistor.buildReposi > tory(Repos > itoryPersistor.java:285) > at > org.apache.ojb.broker.metadata.RepositoryPersistor.readFromFil > e(Reposito > ryPersistor.java:150) > at > org.apache.ojb.broker.metadata.DescriptorRepository.getInstanc > e(Descript > orRepository.java:146) > at > org.apache.ojb.broker.metadata.DescriptorRepository.getInstanc > e(Descript > orRepository.java:192) > at > org.apache.ojb.broker.metadata.DescriptorRepository.getDefault > Instance(D > escriptorRepository.java:179) > at > org.apache.ojb.broker.query.QueryFactory.newQuery(QueryFactory > .java:115) > at > org.apache.ojb.broker.query.QueryFactory.newQuery(QueryFactory > .java:127) > at > org.apache.ojb.odmg.oql.OQLParser.selectQuery(OQLParser.java:168) > at > org.apache.ojb.odmg.oql.OQLParser.buildQuery(OQLParser.java:95) > at > org.apache.ojb.odmg.oql.OQLQueryImpl.create(OQLQueryImpl.java:235) > at > org.apache.ojb.odmg.oql.OQLQueryImpl.create(OQLQueryImpl.java:207) > at de.asterixs.dao.T.<init>(T.java:76) > at de.asterixs.dao.T.main(T.java:104) > > org.apache.ojb.broker.metadata.MetadataException > at > org.apache.ojb.broker.metadata.DescriptorRepository.getInstanc > e(Descript > orRepository.java:154) > at > org.apache.ojb.broker.metadata.DescriptorRepository.getInstanc > e(Descript > orRepository.java:192) > at > org.apache.ojb.broker.metadata.DescriptorRepository.getDefault > Instance(D > escriptorRepository.java:179) > at > org.apache.ojb.broker.query.QueryFactory.newQuery(QueryFactory > .java:115) > at > org.apache.ojb.broker.query.QueryFactory.newQuery(QueryFactory > .java:127) > at > org.apache.ojb.odmg.oql.OQLParser.selectQuery(OQLParser.java:168) > at > org.apache.ojb.odmg.oql.OQLParser.buildQuery(OQLParser.java:95) > at > org.apache.ojb.odmg.oql.OQLQueryImpl.create(OQLQueryImpl.java:235) > at > org.apache.ojb.odmg.oql.OQLQueryImpl.create(OQLQueryImpl.java:207) > at de.asterixs.dao.T.<init>(T.java:76) > at de.asterixs.dao.T.main(T.java:104) > Exception in thread "main" > > > > package de.asterixs.dao; > > import org.apache.ojb.broker.PersistenceBrokerFactory; > import org.apache.ojb.broker.singlevm.PersistenceBrokerConfiguration; > import > org.apache.ojb.broker.util.configuration.ConfigurationException; > > import org.apache.ojb.odmg.OJB; > > import org.odmg.Database; > import org.odmg.Implementation; > import org.odmg.ODMGException; > import org.odmg.DList; > import org.odmg.Implementation; > import org.odmg.OQLQuery; > import org.odmg.Transaction; > > import org.apache.log4j.Logger; > import org.apache.log4j.BasicConfigurator; > > public class T { > private static String databaseName; > private static Logger log = Logger.getLogger(T.class); > > static > { > BasicConfigurator.configure(); > > System.setProperty("OJB.properties","E:/cvs.root/asterixs/buil > d/ojb/OJB. > properties"); > databaseName = > "E:/cvs.root/asterixs/build/ojb/repository.xml"; > } > > public T() { > Implementation odmg = OJB.getInstance(); > Database db = odmg.newDatabase(); > > try > { > db.open(databaseName, Database.OPEN_READ_WRITE); > } catch (ODMGException ex) { > ex.printStackTrace(); > } > > Transaction tx = odmg.newTransaction(); > tx.begin(); > OQLQuery query = odmg.newOQLQuery(); // <-- this > causes the error > > try { > query.create("select allproducts from " + > org.apache.ojb.tutorial2.Product.class.getName()); > } catch (QueryInvalidException ex) { > log.error(ex.getMessage()); > } > > try { > DList allProducts = (DList) query.execute(); > log.info("Found products: " + allProducts.size()); > } catch (QueryException ex) { > log.error(ex.getMessage()); > } > tx.commit(); > } > > public static void main(String[] args) { > T t1 = new T(); > } > } > > > -- > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
