Installing Transfer in ModelGlue:Unity
Today we will install the Transfer ORM inside our Contact-O-Matic application. To complete this tutorial, you should have the Contact-O-Matic installed and running. If you have not completed this step, please create the database described at the bottom of Series 6 and install the files at Series 10 download link. Test the application by manually adding several ContactTypes to the ContactType table in your database (I chose Co-Worker, Enemy, Friend). Then use the Contact Form in the ContactOMatic application to enter a few contacts.
Once you confirm the application works as intended, open your /ContactOMatic/config/ColdSpring.xml file and make the following edits to the ModelGlueConfiguration bean:
- Set reload = true
- Set rescaffold = true
- Set debug = true
The Transfer Integration in ModelGlue:Unity depends on the alias functionality in ColdSpring which is currently found in the BER release. If you do not have the BER release, or are not sure, you should Checkout the /Head/Coldspring directory into your webroot as 'coldspring'.
Note: If you complete this series and do not have a version of ColdSpring with alias support, you will not get an obvious error. Here are the CVS configuration details for checking out ColdSpring. If you use (cf)eclipse, you already have a CVS client. If not, I suggest you download one.
Below is a screenshot of the CVS parameters for Eclipse:
Download the latest Transfer ORM framework at RIA Forge/ Transfer ORM, then extract it to your webroot.
Now open the ContactManagerMG directory and create a 'transfer' directory in /ContactManagerMG/Config and also a 'transfer' directory inside /ContactManagerMG/Model.
Following that, create two new .xml files named Datasource.xml and Transfer.xml inside /ContactManagerMG/Config/transfer. Datasource.xml file contains the datasource used by your application. Fill it out like so:
2<datasource xsi:noNamespaceSchemaLocation="../../transfer/resources/xsd/datasource.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3 <name>ContactOMatic</name>
4 <username></username>
5 <password></password>
6</datasource>
2<transfer xsi:noNamespaceSchemaLocation="../../../transfer/resources/xsd/transfer.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3 <objectDefintions>
4 <!-- Contact details -->
5 <object name="Contact" table="Contact">
6 <id name="ContactID" type="numeric"/>
7 <property name="ContactName" type="string" column="ContactName"/>
8 <manytoone name="ContactType">
9 <!--
10 The column on the Post table that links
11 to the primary key on the User
12 -->
13 <link to="ContactType" column="ContactTypeID"/>
14 </manytoone>
15 </object>
16
17 <object name="ContactType" table="ContactType">
18 <id name="ContactTypeID" type="numeric"/>
19 <property name="ContactType" type="string" column="ContactType"/>
20 </object>
21 </objectDefintions>
22</transfer>
Lastly, connect Transfer to ModelGlue:Unity through ColdSpring. Open /ContactManagerMG/config/ColdSpring.xml and paste the following definitions:
2 <alias alias="ormAdapter" name="ormAdapter.Transfer" />
3 <alias alias="ormService" name="ormService.Transfer" />
4 <!-- This sets the definitions for the ModelGlue -->
5 <bean id="ormAdapter.Transfer" class="ModelGlue.unity.orm.transfer.TransferAdapter">
6 <constructor-arg name="framework">
7 <ref bean="ModelGlue" />
8 </constructor-arg>
9 </bean>
10 <!-- This sets the definitions for Transfer -->
11 <bean id="ormService.Transfer" class="transfer.TransferFactory">
12 <constructor-arg name="configuration">
13 <ref bean="transferConfiguration" />
14 </constructor-arg>
15 </bean>
16 <!-- This is your application specific Transfer Configuration. Paths are from the webroot or mapping -->
17 <bean id="transferConfiguration" class="transfer.com.config.Configuration">
18 <constructor-arg name="datasourcePath">
19 <value>/ContactManagerMG/config/transfer/datasource.xml</value>
20 </constructor-arg>
21 <constructor-arg name="configPath">
22 <value>/ContactManagerMG/config/transfer/transfer.xml</value>
23 </constructor-arg>
24 <constructor-arg name="definitionPath">
25 <value>/ContactManagerMG/model/transfer</value>
26 </constructor-arg>
27 </bean>
Note: If you are using MG:3 Gesture, you do not need the definitions for the ormAdapter and the ormService.
Why? Because these are provided for you already in the Gesture framework. If you use the above definitions, you will get the following error:
Bean creation exception during init() of ModelGlue.unity.orm.transfer.TransferAdapter The TRANSFER parameter to the init function is required but was not passed in.:
The fix is easy. Remove the following XML from the above configuration:
2 <bean id="ormAdapter.Transfer" class="ModelGlue.unity.orm.transfer.TransferAdapter">
3 <constructor-arg name="framework">
4 <ref bean="ModelGlue" />
5 </constructor-arg>
6 </bean>
7 <!-- This sets the definitions for Transfer -->
8 <bean id="ormService.Transfer" class="transfer.TransferFactory">
9 <constructor-arg name="configuration">
10 <ref bean="transferConfiguration" />
11 </constructor-arg>
12 </bean>
Test the integration by running your ContactOMatic application again. Scroll to the ModelGlue Debug output and look for the Happy Message:
If you did not get the Happy Message, something is borked. You may see one of the below messages:
2 Not using an ORM adapter. You will not be able to do automatic database functions.
3
4Cause: Transfer failed to load: coldspring.beanCreationException : Bean creation exception during init() of transfer.TransferFactory : An error occurred when performing a file operation read on file C:\Webroot\ContactManagerMG\config\transfer\datasource.xml.:The cause of this exception was: java.io.FileNotFoundException: C:\Webroot\ContactManagerMG\config\transfer\datasource.xml (The system cannot find the file specified).
2 Not using an ORM adapter. You will not be able to do automatic database functions.
3
4Cause: Transfer failed to load: coldspring.beanCreationException : Bean creation exception during init() of transfer.TransferFactory : An error occurred when performing a file operation read on file C:\Webroot\ContactManagerMG\config\transfer\transfer.xml.:The cause of this exception was: java.io.FileNotFoundException: C:\Webroot\ContactManagerMG\config\transfer\transfer.xml (The system cannot find the file specified).
To resolve this, examine the name and path of each of the configuration files above.
Remember: the file path referenced in the ColdSpring.xml / transferConfiguration bean is the path from your webroot or ColdFusion Mapping.
If you still get this message:
One of three things is wrong:
- You did not reload your application
- You did not install the ColdSpring BER properly
- You did not install Transfer Properly
For reference, below is the proper directory/file structure for the completed installation:
There are no comments for this entry.


Can I retract my post?
The problem was simply that the <objectDefinitions> tag was missing one of the "i"s
Thanks to Joe for picking out the missing "i" in the <objectDefinitions>. Fixed my problem.
Hi Dan,
I am getting following error and when I check the xml there isn't any ModelGlue bean:
There is no bean registered with the factory with the id ModelGlue
The error occurred in C:\inetpub\wwwroot\coldspring\beans\AbstractBeanFactory.cfc: line 146
Called from C:\inetpub\wwwroot\coldspring\beans\AbstractBeanFactory.cfc: line 215
Called from C:\inetpub\wwwroot\coldspring\beans\BeanDefinition.cfc: line 534
Actally I am using - MG:3 Gesture, and I need to comment the definition, and now it worked.
cheers
philip
Hello,
I just downloaded the most recent version of the Transfer ORM and am having all sorts of difficulty with your transfer.xml
Not using an ORM adapter. You will not be able to do automatic database functions. I did a copy and paste. I see no other problems reported so I might assume the xsd changed since the time of this post?
Cause: Transfer failed to load: coldspring.beanCreationException : Bean creation exception during init() of transfer.TransferFactory : The XML Provided in 'C:\Inetpub\wwwroot\ContactManagerMG\config\transfer\Transfer.xml' is not valid against its XML Schema:[Error] :32:19: cvc-complex-type.2.4.a: Invalid content was found starting with element 'objectDefintions'. One of '{"":nullValues, "":objectDefinitions}' is expected.