R: R: Error getting DataContext

From: Cristiano Ghersi (cristiano.ghers..bodata.com)
Date: Fri Sep 04 2009 - 09:18:48 EDT

  • Next message: Andrus Adamchik: "Re: R: R: Error getting DataContext"

    This is the stackTrace:

    ****************************************************************************
    *********************************
    Sep 4, 2009 3:17:14 PM org.apache.cayenne.conf.RuntimeLoadDelegate
    startedLoading
    INFO: started configuration loading.
    Sep 4, 2009 3:17:14 PM org.apache.cayenne.conf.RuntimeLoadDelegate
    shouldLoadDataDomain
    INFO: loaded domain: PacketDomain
    Sep 4, 2009 3:17:14 PM org.apache.cayenne.conf.RuntimeLoadDelegate
    loadDataMap
    INFO: loaded <map name='PacketMap' location='PacketMap.map.xml'>.
    Sep 4, 2009 3:17:14 PM org.apache.cayenne.conf.RuntimeLoadDelegate
    shouldLoadDataNode
    INFO: loading <node name='PacketNode' datasource='PacketNode.driver.xml'
    factory='org.apache.cayenne.conf.DriverDataSourceFactory'
    schema-update-strategy='org.apache.cayenne.access.dbsync.SkipSchemaUpdateStr
    ategy'>.
    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 dbManager.DbManager.<init>(DbManager.java:43)
            at zzz_bundledbquery.DBQueryStarter.start(DBQueryStarter.java:28)
            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.resume(AbstractBundl
    e.java:370)
            at
    org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.ja
    va:1068)
            at
    org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(Sta
    rtLevelManager.java:557)
            at
    org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLeve
    lManager.java:464)
            at
    org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(S
    tartLevelManager.java:248)
            at
    org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(Sta
    rtLevelManager.java:445)
            at
    org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.
    java:220)
            at
    org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManage
    r.java:330)
    ****************************************************************************
    *********************************

    Thanks
    Cristiano

    -----Messaggio originale-----
    Da: Andrus Adamchik [mailto:andru..bjectstyle.org]
    Inviato: venerd́ 4 settembre 2009 15.10
    A: use..ayenne.apache.org
    Oggetto: Re: R: Error getting DataContext

    Hmm... Could you actually post the new stack trace? For one thing it
    should not contain this anymore:

    at
    org
    .apache
    .cayenne.conf.Configuration.initializeSharedConfiguration(Configur
    ation.java:168)

    Andrus

    On Sep 4, 2009, at 3:49 PM, Cristiano Ghersi wrote:
    > 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 <node name='PacketNode'
    > datasource='PacketNode.driver.xml'
    > factory='org.apache.cayenne.conf.DriverDataSourceFactory'
    > schema-update-
    > strategy='org.apache.cayenne.access.dbsync.SkipSchemaUpdateStr
    > ategy'>.
    >
    > 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.<init>(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
    >
    >
    >

    Nessun virus nel messaggio in arrivo.
    Controllato da AVG - www.avg.com
    Versione: 8.5.409 / Database dei virus: 270.13.76/2345 - Data di rilascio:
    09/04/09 05:51:00



    This archive was generated by hypermail 2.0.0 : Fri Sep 04 2009 - 09:19:37 EDT