Re: problem creating standalone DataContext

From: Lothar Krenzien (lkrenzie..eb.de)
Date: Wed Jan 04 2006 - 09:27:50 EST

  • Next message: Gentry, Michael \(Contractor\): "RE: Modeller M9 Problem"

    Hi Andrus,

    sorry if my question wasn't clear enough. I know that the file from the WEB-INF directory is loaded by a servlet-container. But it wasn't clear for me where cayenne is searching for the config file when I want to create a standalone context. But I found it out in the meantime. Now I get another error:

    ...
    org.objectstyle.cayenne.conf.RuntimeLoadDelegate.using factory: org.objectstyle.cayenne.conf.JNDIDataSourceFactory
    org.objectstyle.cayenne.access.QueryLogger.Connecting. JNDI path: jdbc/dbSr2
    org.objectstyle.cayenne.access.QueryLogger.*** Connecting: FAILURE.
    org.objectstyle.cayenne.conf.RuntimeLoadDelegate.Error: DataSource load failed
    javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    ...

    For me it looks like that I have to set a JNDI resource. Normally it will be set in the context.xml which is loaded by a web container. But how can I specifiy the JNDI context when I run cayenne without a web-container ?

    Thanks again
    Lothar

    BTW: I know the chapter 12 (Deployment ) in the user guide and did it that way. Here's my cayenne.xml
    ...
    <domain name="Sr2Domain">
            <property name="cayenne.DataDomain.sharedCache" value="true"/>
            <map name="Sr2DomainMap" location="Sr2DomainMap.map.xml"/>

            <node name="Sr2DomainNode"
                     datasource="jdbc/dbSr2"
                     adapter="com.conergy.sunreader.base.cayenne.SQLServerAdapter"
                     factory="org.objectstyle.cayenne.conf.JNDIDataSourceFactory">
                            <map-ref name="Sr2DomainMap"/>
             </node>
    ...

    And here's an extract of the context.xml
    ..
            <Resource
                              name="jdbc/dbSr2" auth="Container"
                               type="javax.sql.DataSource"
                              removeAbandoned="true"
                              removeAbandonedTimeout="60"
                              logAbandoned="true"
                              initialSize="20"
                              maxActive="100"
                              maxIdle="30"
                              maxWait="10000"
                              username="XXX"
                              password="XXX"
                              driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
                              url="jdbc:microsoft:sqlserver://TestServer:1433;DatabaseName=testDB"/>

    ...

    cayenne-use..bjectstyle.org schrieb am 04.01.06 14:08:07:
    >
    > For Cayenne to load XML files from WEB-INF, a servlet container is
    > required (i.e. an application lifecycle compatible with the servlet
    > spec is assumed). In your JUnit environment you won't have that. A
    > solution - put the XML files in CLASSPATH (wherever that might be).
    >
    > Andrus
    >
    >
    > On Jan 4, 2006, at 6:22 AM, Lothar Krenzien wrote:
    >
    > > Hi there,
    > >
    > > for testing purposes (JUnit for example) I want to create a
    > > DataContext using the following command:
    > > DataContext.createDataContext().
    > > But I get always an error like that "URL not found with
    > > classloader: cayenne.xml" . I tried it also with these commands :
    > > CayenneDataContextManager.createDataContext("LocalDomain")
    > > DataContext.createDataContext()
    > >
    > > I have the cayenne.xml and LocalDomain.map.xml files in my Web-INF
    > > dir and a copy in the root of the source dir. But nothing works.
    > > When I create the DataContext from a request with the command
    > > CayenneDataContextManager.getDataContext(ctx.getRequest())
    > > it works fine. so what I'm doing wrong ?
    > >
    > > Thanks, Lothar
    >

    ______________________________________________________________
    Verschicken Sie romantische, coole und witzige Bilder per SMS!
    Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193



    This archive was generated by hypermail 2.0.0 : Wed Jan 04 2006 - 09:27:52 EST