Hey Nathan, I went back to look at original post, in Application.cfc:

Application.cfc

<cffunction name="onApplicationStart">
:
        <cfset application.serviceFactory = createObject( "component",
                                                "coldspring.beans.DefaultXmlBeanFactory").init()/>

        <cfset application.serviceFactory.loadBeansFromXmlFile(application.serviceDefinitionLocation)/>
:
</cffunction>


is application.serviceDefinitionLocation properly set to the path of your coldspringServices.xml file? I'm jumping in late, so sorry if this is a dumb question on my part...

Chris

Chris Scott







On Jul 5, 2006, at 7:14 PM, Nathan Drury wrote:

Hi Dave and Tom

Thanks for your replies.  Yes, using getDsn() was a screw up on my part,
but note that the error is for dsn not the getDsn function.  So I got
rid of the getDsn call and just have variables.dsn and it now gives the
error:

Element DSN is undefined in VARIABLES.

So dsn is not being set in the variables scope.  

I was sure that I'd done everything right based on the ColdSpring doco
and the examples, but for the life of me it's not working.  Do I have to
have an init function in MenusGateway that calls setDSN?

Re: adding debug statements to the core files.  I wouldn't do this
normally, but I've spent over a day trying to work out why it isn't
working and wanted to confirm that Coldspring was wiring things up as
expected.

So, to reiterate, I'm not using a framework except for Coldspring.
Should all I need to do is what I outlined in my original email? (beans
in xml file, xml file loaded via
DefaultXmlBeanFactory.loadBeansFromXmlFile, setter in dsn.cfc and setter
in MenusGateway.cfc).

Also, to use Coldspring for remoting with Flex, should I be referring to
the feedviewer-remote example since the other examples use frameworks or
AOP?  (that said, I'd like to use AOP for authentication in certain
sections of the app too).

Cheers

Nathan Drury

-----Original Message-----
[mailto:[email protected]] On Behalf Of Dave Ross
Sent: Wednesday, 5 July 2006 9:45 PM
Subject: [coldspring-dev] Can't get it working :( And a Flex 2 question

Nathan,

In your menu gateway, you are assigning variables.dsn to be the result
of getDsn() on your "dsn" object - which is probably returns a string.
Then, later, you are trying to call getDsn() on this string (within
your cfquery tag).

I think what tripped you up here is naming conventions. "dsn" means
"datasource name". So to have a class called "dsn" is confusing,
especially if you have a getDsn() method inside. I bet if your class
was named "DatasourceConfig' or "DatasourceSettings", or anything
other than "dsn" you probably wouldn't have made this minor mistake.

I don't recommend adding debug statements to the core files - it may
execute things in an order that you don't expect and confuse you even
more. The error you were getting was pointed to exactly the line in
your code where it was happening, and ColdSpring had already wired
everything together and was out of the way by the time the error
occured. I would say it's better to put debug statements in your code
(probably in your init() and setter-methods) to see if the dependency
resolution is occuring as you expect.

Lastly, yes, ColdSpring is great to use in a remoting enviroment -
there's a section on it in the docs. We plan on adding some
Flex2-specific tips soon.

thanks,

Dave Ross

(I would rename this class to "datasourceBean" or something else -
"dsn" means "datasourcename"

On 7/5/06, Nathan Drury <[EMAIL PROTECTED]> wrote:



Hi

First I will ask if Coldspring can be used with a CF backend that will
be
accessed via Flex 2 using remoting.  If so, great, because I really
like the
ideas behind Coldspring and AOP.  If not, plese ignore the rest of
this
email :)

I've created an app that will be used as a back end for Flex.  At this
stage
however I am just creating a few DAO / Gateways and am testing them as
a
normal html web app.  However, I cannot get it to work.  I've created
a
ModelGlue app in the past and it worked fine with Coldspring (thanks
Sean
Corfield).  But this app is not to use any framework and I cannot get
it to
work with Coldspring.  Here is what I have done so far (using my
MenusGateway.cfc as the cfc I'm trying to inject my datasource name
into):

coldspringServices.xml

<beans>
        <bean id="dsn"
                        class="com.tq.utils.db.dsn">
                <property name="dsn" type="string"><!-- uses get/set
-->
                        <value>THEZOO_DATASOURCE</value>
                </property>
        </bean>

        <bean id="menusGateway"
                        class="com.tq.utils.menu.MenusGateway">
                <property name="dsn">
                        <ref bean="dsn"/>
                </property>
        </bean>

</beans>

Application.cfc

<cffunction name="onApplicationStart">
:
        <cfset application.serviceFactory = createObject( "component",

"coldspring.beans.DefaultXmlBeanFactory").init()/>

        <cfset

application.serviceFactory.loadBeansFromXmlFile(application.serviceDefin
itionLocation)/>
:
</cffunction>

MenusGateway.cfc

<cfcomponent>

        <cffunction name="setDSN" returntype="void" access="public"
output="true">
                <cfargument name="dsn" type="com.tq.utils.db.dsn"
required="true" />
                <cfoutput>setDSN</cfoutput>
                <cfset variables.dsn = arguments.dsn.getDSN() />
        </cffunction>

        <cffunction name="getAll"
returntype="com.tq.utils.menu.Menus[]">
                <cfset var qRead="">
                <cfquery name="qRead"
datasource="#variables.dsn.getDSN()#">
                        QUERY HERE
                </cfquery>
                :
                :
                </cfquery>
        </cffunction>
</cfcomponent>

I also added some outputs to DefaultXmlBeanFactory.cfc's
loadBeanDefinitions:

<cfoutput>beanIx: #beanIx#,
beanAttributes.id:#beanAttributes.id#,
beanAttributes.class:#beanAttributes.class#<br></cfoutput>

 and BeanDefinition.cfc's addProperty function:

<cfoutput>addProperty:
#arguments.property.getName()#<br></cfoutput>

 to get some debug

When I call MenusGateway's getAll function I get:

beanIx: 1, beanAttributes.id:dsn,
beanAttributes.class:com.tq.utils.db.dsn
addProperty: dsn
beanIx: 3, beanAttributes.id:menusGateway,
beanAttributes.class:com.tq.utils.menu.MenusGateway
addProperty: dsn

But then it throws the error referring to the qRead query line in
MenusGateway.cfc:

Element DSN is undefined in a Java object of type class
[Ljava.lang.String


So I thought I had it all set up properly, but it appears not.  Does
anyone
have any suggestions?

Thanks

Nathan Drury
Systems Analyst / Developer
Tourism Queensland - ICT
( +61 7 3535 5037






Reply via email to