You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Vitaly Repetenko <vi...@mtu.ru> on 2001/10/26 13:00:30 UTC

DataSourceResourceLoader

Hello!

Is it possible to use DataSourceResourceLoader?

I have built Velocity (nightly 2001-10-24) with jar-J2EE build target.
It seems that DataSourceResourceLoader can not load properties.

[skip]
Fri Oct 26 13:23:11 MSD 2001   [info] Resource Loader Instantiated:
org.apache.velocity.runtime.resource.loader.DataSourceResourceLoader
!!!!!!!!!!!!!!!!!!!!!
Fri Oct 26 13:23:11 MSD 2001   [info] Resources Loaded From: null/null
Fri Oct 26 13:23:11 MSD 2001   [info] Resource Loader using columns:
null, null and null
!!!!!!!!!!!!!!!!!!!!!
Fri Oct 26 13:23:11 MSD 2001   [info] Resource Loader Initalized.
[skip]
Fri Oct 26 13:23:12 MSD 2001   [info] Velocimacro : initialization
starting.
Fri Oct 26 13:23:12 MSD 2001   [info] Velocimacro : adding VMs from VM
library template : VM_global_library.vm
Fri Oct 26 13:23:12 MSD 2001  [error] DataSourceResourceLoader Error:
database problem trying to load resource VM_global_library.vm:
java.lang.NullPointerException
Fri Oct 26 13:23:12 MSD 2001  [error] ResourceManager : unable to find
resource 'VM_global_library.vm' in any resource loader.
Fri Oct 26 13:23:12 MSD 2001   [info] Velocimacro : error using  VM
library template VM_global_library.vm :
org.apache.velocity.exception.ResourceNotFoundException: Unable to find
resource 'VM_global_library.vm'
[skip]
Fri Oct 26 13:23:12 MSD 2001   [info] Velocity successfully started.
Fri Oct 26 13:23:12 MSD 2001  [error] DataSourceResourceLoader Error:
database problem trying to load resource 10:
java.lang.NullPointerException
Fri Oct 26 13:23:12 MSD 2001  [error] ResourceManager : unable to find
resource '10' in any resource loader.
[END]

I was trying to use these properties:

resource.loader = datasource
datasource.resource.loader.description = Velocity DataSource Resource
Loader
datasource.resource.loader.class =
org.apache.velocity.runtime.resource.loader.DataSourceResourceLoader

datasource.resource.loader.datasource = jdbc/testDS
datasource.resource.loader.table = temp
datasource.resource.loader.keycolumn = id
datasource.resource.loader.templatecolumn = template
datasource.resource.loader.timestampcolumn = timestamp
datasource.resource.loader.cache = false
datasource.resource.loader.modificationCheckInterval = 60

datasource.resource.datasource = jdbc/testDS
datasource.resource.table = temp
datasource.resource.keycolumn = id
datasource.resource.templatecolumn = template
datasource.resource.timestampcolumn = timestamp
datasource.resource.cache = false
datasource.resource.modificationCheckInterval = 60

resource.datasource = jdbc/testDS
resource.table = temp
resource.keycolumn = id
resource.templatecolumn = template
resource.timestampcolumn = timestamp
resource.loader.cache = false
resource.loader.modificationCheckInterval  = 60

Result is same!

If I change this code in class DataSourceResourceLoader everything works
correctly!

     public void init( ExtendedProperties configuration)
     {
/*
        dataSourceName  =
configuration.getString("resource.datasource");
         tableName       = configuration.getString("resource.table");
         keyColumn       =
configuration.getString("resource.keycolumn");
         templateColumn  =
configuration.getString("resource.templatecolumn");
         timestampColumn =
configuration.getString("resource.timestampcolumn");
*/
         dataSourceName = "jdbc/testDS";
         tableName = "test";
         keyColumn = "id";
         templateColumn = "template";
         timestampColumn = "timestamp";

         Runtime.info("Resources Loaded From: " + dataSourceName + "/" +
tableName);
         Runtime.info( "Resource Loader using columns: " + keyColumn +
", "
                       + templateColumn + " and " + timestampColumn);
         Runtime.info("Resource Loader Initalized.");
     }

It seems that I use wrong names of properties.

Can I use my own ResourceLoader?


Thanks in advance,
Vitaly.


Re: DataSourceResourceLoader

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 10/26/01 3:29 PM, "David Kinnvall" <da...@alertir.com> wrote:

> Vitaly,
> 
> From: "Vitaly Repetenko" <vi...@mtu.ru>
>> Hello!
>> 
>> Is it possible to use DataSourceResourceLoader?
>> 
>> I have built Velocity (nightly 2001-10-24) with jar-J2EE build target.
>> It seems that DataSourceResourceLoader can not load properties.
> 
> I have been busy doing other stuff for quite some time, but last time I
> used the DataSourceResourceLoader (I wrote the initial version of it) I
> used a velocity.properties fragment like this (multiple loaders supported):
> 
> #---
> # EXAMPLE FOR DataSourceResourceLoader
> #---
> resource.loader.1.public.name = DataSource
> resource.loader.1.description = Velocity DataSource Resource Loader
> resource.loader.1.class =
> org.apache.velocity.runtime.resource.loader.DataSourceResourceLoader
> resource.loader.1.resource.datasource = jdbc/OrionDS
> resource.loader.1.resource.table = template
> resource.loader.1.resource.keycolumn = id
> resource.loader.1.resource.templatecolumn = definition
> resource.loader.1.resource.timestampcolumn = timestamp
> resource.loader.1.cache = false
> resource.loader.1.modificationCheckInterval = 20
> 
> [snip]
>> I was trying to use these properties:
> [snip]
> 
> I'm not sure, but the resource loader configuration syntax may very well
> have changed since last time I used it. Anybody else with current info?
> 

The config changed.  I will update the DataResourceLoader today...



> (I will catch up soon enough, since I will be able to resume development
> in the project of mine that uses Velocity. Will be fun!)
> 

Cool!

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
"He who throws mud only loses ground." - Fat Albert


Re: DataSourceResourceLoader

Posted by David Kinnvall <da...@alertir.com>.
Vitaly,

From: "Vitaly Repetenko" <vi...@mtu.ru>
> Hello!
>
> Is it possible to use DataSourceResourceLoader?
>
> I have built Velocity (nightly 2001-10-24) with jar-J2EE build target.
> It seems that DataSourceResourceLoader can not load properties.

I have been busy doing other stuff for quite some time, but last time I
used the DataSourceResourceLoader (I wrote the initial version of it) I
used a velocity.properties fragment like this (multiple loaders supported):

#---
# EXAMPLE FOR DataSourceResourceLoader
#---
resource.loader.1.public.name = DataSource
resource.loader.1.description = Velocity DataSource Resource Loader
resource.loader.1.class =
org.apache.velocity.runtime.resource.loader.DataSourceResourceLoader
resource.loader.1.resource.datasource = jdbc/OrionDS
resource.loader.1.resource.table = template
resource.loader.1.resource.keycolumn = id
resource.loader.1.resource.templatecolumn = definition
resource.loader.1.resource.timestampcolumn = timestamp
resource.loader.1.cache = false
resource.loader.1.modificationCheckInterval = 20

[snip]
> I was trying to use these properties:
[snip]

I'm not sure, but the resource loader configuration syntax may very well
have changed since last time I used it. Anybody else with current info?

(I will catch up soon enough, since I will be able to resume development
in the project of mine that uses Velocity. Will be fun!)

Regards,

David


Re: DataSourceResourceLoader

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
1) The properties for DataSourceResourceLoader are wrong.  I will update
tonight or tomorrow.  Sorry about the confusion.

2) Yes you can use your own ResourceLoader


geir

On 10/26/01 7:00 AM, "Vitaly Repetenko" <vi...@mtu.ru> wrote:

> Hello!
> 
> Is it possible to use DataSourceResourceLoader?
> 
> I have built Velocity (nightly 2001-10-24) with jar-J2EE build target.
> It seems that DataSourceResourceLoader can not load properties.
> 
> [skip]
> Fri Oct 26 13:23:11 MSD 2001   [info] Resource Loader Instantiated:
> org.apache.velocity.runtime.resource.loader.DataSourceResourceLoader
> !!!!!!!!!!!!!!!!!!!!!
> Fri Oct 26 13:23:11 MSD 2001   [info] Resources Loaded From: null/null
> Fri Oct 26 13:23:11 MSD 2001   [info] Resource Loader using columns:
> null, null and null
> !!!!!!!!!!!!!!!!!!!!!
> Fri Oct 26 13:23:11 MSD 2001   [info] Resource Loader Initalized.
> [skip]
> Fri Oct 26 13:23:12 MSD 2001   [info] Velocimacro : initialization
> starting.
> Fri Oct 26 13:23:12 MSD 2001   [info] Velocimacro : adding VMs from VM
> library template : VM_global_library.vm
> Fri Oct 26 13:23:12 MSD 2001  [error] DataSourceResourceLoader Error:
> database problem trying to load resource VM_global_library.vm:
> java.lang.NullPointerException
> Fri Oct 26 13:23:12 MSD 2001  [error] ResourceManager : unable to find
> resource 'VM_global_library.vm' in any resource loader.
> Fri Oct 26 13:23:12 MSD 2001   [info] Velocimacro : error using  VM
> library template VM_global_library.vm :
> org.apache.velocity.exception.ResourceNotFoundException: Unable to find
> resource 'VM_global_library.vm'
> [skip]
> Fri Oct 26 13:23:12 MSD 2001   [info] Velocity successfully started.
> Fri Oct 26 13:23:12 MSD 2001  [error] DataSourceResourceLoader Error:
> database problem trying to load resource 10:
> java.lang.NullPointerException
> Fri Oct 26 13:23:12 MSD 2001  [error] ResourceManager : unable to find
> resource '10' in any resource loader.
> [END]
> 
> I was trying to use these properties:
> 
> resource.loader = datasource
> datasource.resource.loader.description = Velocity DataSource Resource
> Loader
> datasource.resource.loader.class =
> org.apache.velocity.runtime.resource.loader.DataSourceResourceLoader
> 
> datasource.resource.loader.datasource = jdbc/testDS
> datasource.resource.loader.table = temp
> datasource.resource.loader.keycolumn = id
> datasource.resource.loader.templatecolumn = template
> datasource.resource.loader.timestampcolumn = timestamp
> datasource.resource.loader.cache = false
> datasource.resource.loader.modificationCheckInterval = 60
> 
> datasource.resource.datasource = jdbc/testDS
> datasource.resource.table = temp
> datasource.resource.keycolumn = id
> datasource.resource.templatecolumn = template
> datasource.resource.timestampcolumn = timestamp
> datasource.resource.cache = false
> datasource.resource.modificationCheckInterval = 60
> 
> resource.datasource = jdbc/testDS
> resource.table = temp
> resource.keycolumn = id
> resource.templatecolumn = template
> resource.timestampcolumn = timestamp
> resource.loader.cache = false
> resource.loader.modificationCheckInterval  = 60
> 
> Result is same!
> 
> If I change this code in class DataSourceResourceLoader everything works
> correctly!
> 
>    public void init( ExtendedProperties configuration)
>    {
> /*
>       dataSourceName  =
> configuration.getString("resource.datasource");
>        tableName       = configuration.getString("resource.table");
>        keyColumn       =
> configuration.getString("resource.keycolumn");
>        templateColumn  =
> configuration.getString("resource.templatecolumn");
>        timestampColumn =
> configuration.getString("resource.timestampcolumn");
> */
>        dataSourceName = "jdbc/testDS";
>        tableName = "test";
>        keyColumn = "id";
>        templateColumn = "template";
>        timestampColumn = "timestamp";
> 
>        Runtime.info("Resources Loaded From: " + dataSourceName + "/" +
> tableName);
>        Runtime.info( "Resource Loader using columns: " + keyColumn +
> ", "
>                      + templateColumn + " and " + timestampColumn);
>        Runtime.info("Resource Loader Initalized.");
>    }
> 
> It seems that I use wrong names of properties.
> 
> Can I use my own ResourceLoader?
> 
> 
> Thanks in advance,
> Vitaly.
> 

-- 
Geir Magnusson Jr.                       geirm@optonline.net
System and Software Consulting
You're going to end up getting pissed at your software
anyway, so you might as well not pay for it. Try Open Source.