Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 43718 invoked from network); 4 Sep 2009 12:50:10 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 4 Sep 2009 12:50:10 -0000 Received: (qmail 214 invoked by uid 500); 4 Sep 2009 12:50:10 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 170 invoked by uid 500); 4 Sep 2009 12:50:10 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 134 invoked by uid 99); 4 Sep 2009 12:50:10 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Sep 2009 12:50:10 +0000 X-ASF-Spam-Status: No, hits=3.4 required=10.0 tests=HTML_MESSAGE,MSGID_MULTIPLE_AT,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [217.194.8.131] (HELO relay-2.smtp.seeweb.it) (217.194.8.131) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Sep 2009 12:50:00 +0000 Received: from ABODATAcghersi (host35-107-static.82-213-b.business.telecomitalia.it [213.82.107.35]) by relay-2.smtp.seeweb.it (Postfix) with ESMTP id 4C4E24B4D2 for ; Fri, 4 Sep 2009 14:49:36 +0200 (CEST) X-Copfilter: Sender is in whitelist, skipped SpamAssassin X-Copfilter: Client is part of our network, skipped SpamAssassin From: "Cristiano Ghersi" To: References: In-Reply-To: Subject: R: Error getting DataContext Date: Fri, 4 Sep 2009 14:49:29 +0200 Message-ID: <000001ca2d5e$24cd4ad0$6e67e070$@ghersi@abodata.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0001_01CA2D6E.E85641E0" X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: Acosrw8AV6z0X9b2QOCzrtnDTO8hEwArpnSA Content-Language: it X-Virus-Checked: Checked by ClamAV on apache.org ------=_NextPart_000_0001_01CA2D6E.E85641E0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi Andrus, Thank you for your fast reply! I tried with the following as you have proposed: String pathWithConfigurationFiles = System.getProperty("user.dir") + "/config/cayenne"; config = new FileConfiguration("cayenne.xml"); ((FileConfiguration) config).addFilesystemPath(new File(pathWithConfigurationFiles)); config.initialize(); context = config.getDomain().createDataContext(); Unfortunately this code doesn't solve the issue, still present with the same StackTrace. Other ideas? Thank you very much for the help! Cristiano **************************************************************************** *********+ Hi there, Looks like a static Configuration singleton is causing a problem. Could you just keep 2 Configurations separate and avoid using 'initializeSharedConfiguration'. E.g.: Configuration conf = ...; conf.initialize(); // store conf reference for later use ... // use a stored conf to create the context: DataContext context = conf.getDomain().createDataContext(); Hope this helps. Andrus On Sep 3, 2009, at 6:56 PM, Cristiano Ghersi wrote: Good morning, I've got a problem using the static method DataContext.createDataContext(); My environment is the following: I've got a library (let's call it "DataLayer") which use cayenne for the communication towards a single DB. In this library a class called DbManager create a DataContext in its constructor using this piece of code: try { String pathWithConfigurationFiles = "/home/matteo/config/cayenne"; org.apache.cayenne.conf.Configuration conf = new FileConfiguration("cayenne.xml"); // Cayenne configuration files can be found at this location ((FileConfiguration) conf).addFilesystemPath(new File(pathWithConfigurationFiles)); org.apache.cayenne.conf.Configuration.initializeSharedConfiguration(conf); } catch (Exception e){ e.printStackTrace(); } // Create a new one context = DataContext.createDataContext(); This library is used by two different bundles (OSGi Framework); let's call these bundles Bundle1 and Bundle2. If I use only one of these bundles all goes perfectly well, but if I try to start Bundle2 when Bundle1 is already started, the following error appears and Bundle2 is stopped: INFO: loading . org.apache.cayenne.ConfigurationException: [v.3.0M6 May 18 2009 07:49:46] Error during Configuration initialization. org.apache.cayenne.access.dbsync.SkipSchemaUpdateStrategy cannot be cast to org.apache.cayenne.access.dbsync.SchemaUpdateStrategy at org.apache.cayenne.conf.Configuration.initializeSharedConfiguration(Configur ation.java:168) at dbManager.DbManager.(DbManager.java:58) at zzz_bundledbquery.DBQueryStarter.start(DBQueryStarter.java:20) at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleConte xtImpl.java:782) at java.security.AccessController.doPrivileged(Native Method) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(Bu ndleContextImpl.java:773) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleConte xtImpl.java:754) at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.j ava:352) at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle .java:280) at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle .java:272) at org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider._start(Fra meworkCommandProvider.java:253) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl .java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.eclipse.osgi.framework.internal.core.FrameworkCommandInterpreter.execute (FrameworkCommandInterpreter.java:155) at org.eclipse.osgi.framework.internal.core.FrameworkConsole.docommand(Framewor kConsole.java:303) at org.eclipse.osgi.framework.internal.core.FrameworkConsole.console(FrameworkC onsole.java:288) at org.eclipse.osgi.framework.internal.core.FrameworkConsole.run(FrameworkConso le.java:224) at java.lang.Thread.run(Thread.java:619) Caused by: java.lang.ClassCastException: org.apache.cayenne.access.dbsync.SkipSchemaUpdateStrategy cannot be cast to org.apache.cayenne.access.dbsync.SchemaUpdateStrategy at org.apache.cayenne.conf.RuntimeLoadDelegate.shouldLoadDataNode(RuntimeLoadDe legate.java:303) at org.apache.cayenne.conf.ConfigLoader$NodeHandler.init(ConfigLoader.java:345) at org.apache.cayenne.conf.ConfigLoader$DomainHandler.startElement(ConfigLoader .java:222) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Ab stractSAXParser.java:501) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartEl ement(XMLNSDocumentScannerImpl.java:400) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$Fragm entContentDriver.next(XMLDocumentFragmentScannerImpl.java:2747) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocum entScannerImpl.java:648) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSD ocumentScannerImpl.java:140) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanD ocument(XMLDocumentFragmentScannerImpl.java:510) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Con figuration.java:807) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Con figuration.java:737) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:10 7) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractS AXParser.java:1205) at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SA XParserImpl.java:522) at org.apache.cayenne.conf.ConfigLoader.loadDomains(ConfigLoader.java:78) at org.apache.cayenne.conf.DefaultConfiguration.initialize(DefaultConfiguration .java:152) at org.apache.cayenne.conf.Configuration.initializeSharedConfiguration(Configur ation.java:159) ... 19 more What I'm missing? Thank you very much for the help!! Cristiano Ghersi ------=_NextPart_000_0001_01CA2D6E.E85641E0--