You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by John Shott <sh...@stanford.edu> on 2008/02/26 03:38:13 UTC
SQL task and resource collections ...
Ant community:
I'm trying to upgrade my build.xml to be ant 1.7.0 compatible and seem
to be stumbling on changes in the SQL task related to resource collections.
I have been trying:
<sql driver="${jdbc_driver_class}" url="${jdbc_url}"
userid="${this.user}" password="${this.password}"
keepformat="true" delimiter="/" escapeprocessing="false"
print="true"
onerror="continue">
<fileset dir="${this.dir}">
<include name="*.sql"/>
<modified>
<param name="cache.cachefile" value="./sql.properties"/>
</modified>
</fileset>
<classpath>
<pathelement location="${build.dir}/${jdbc.jar}"/>
</classpath>
</sql>
I keep getting the error message: "Source file or resource collection,
transactions, or sql statement must be set!". I thought that a fileset
WAS a resource collection and the manual says:
> You can specify multiple sources via nested resource collection
> elements. Each resource of the collection will be run in a transaction
> of its own. Prior to Ant 1.7 only filesets were supported. Use a sort
> resource collection to get a predictable order of transactions.
>
which, to me at least, indicates that a fileset should still be supported.
Can anyone shed some light on this or help me to see what I've fouled up
here? I can't seem to figure out what I'm doing wrong.
Thanks for your consideration,
John
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
RE: SQL task and resource collections ...
Posted by Chun Ji <CJ...@pro-unlimited.com>.
How about you create a new sql file that calls the rest of your Sqls , and just here is your simple ant target:
<sql
driver="org.database.jdbcDriver"
url="jdbc:database-url"
userid="sa"
password="pass"
src="xxx.sql"/>
That is how my code works.
-c
-----Original Message-----
From: John Shott [mailto:shott@stanford.edu]
Sent: Tuesday, February 26, 2008 1:32 PM
To: Ant Users List
Subject: Re: SQL task and resource collections ...
Steve:
Thanks for your informative response and your suspicion that I may have
a problem with the size() of my fileset.
Since I can't seem to find a simple method of trying to test the size of
my fileset, in advance of my call of the sql task, I've now tried to
modify my target to first create a fileset, then created a property
based on a pathcovert of that fileset, and then tried to run the sql
task based on a test of that property. While this looks a little ugly
and kludgey, it was the only way (I thought) to make sure that I was
guaranteed to not run the sql task if the fileset was empty.
My current target that includes the sql task now looks like:
<!-- build.xml snippet starts here -->
<target name="loadStoredProcedures">
<basename property="this.user" file="${this.dir}"/>
<echo message="Loading stored procedures from ${this.dir}."/>
<fileset dir="${this.dir}" id="this.fileset">
<include name="*.sql"/>
<modified>
<param name="cache.cachefile" value="config/.sql${sfx}.properties"/>
</modified>
</fileset>
<!-- The following path convert is a trick to simply set a property -->
<!-- named ${new.files} only if there are any files to be processed -->
<!-- in refid="this.fileset". -->
<pathconvert property="new.files" refid="this.fileset"
setonempty="false" targetos="unix"/>
<if> <isset property="new.files"/>
<then>
<echo message="Property new.files is set to ${new.files}."/>
<sql driver="${jdbc_driver_class}" url="${jdbc_url}"
userid="${this.user}" password="${coral.db.password}"
keepformat="true" delimiter="/" escapeprocessing="false"
print="true"
onerror="continue">
<fileset refid="this.fileset"/>
<classpath>
<pathelement location="${build.dir}/ext/${jdbc.jar}"/>
</classpath>
</sql>
</then>
</if>
</target>
<!-- build.xml snippet ends here -->
I still believe that I am still seeing a failure during the sql task and
have included what I believe to be the relevant results of the call 'ant
-debug loadStoredProcedures 2>&1 | tee sql_debug.log'
Apache Ant version 1.7.0 compiled on December 13 2006
Buildfile: build.xml
Adding reference: ant.PropertyHelper
Detected Java version: 1.5 in: /usr/java/jdk1.5.0_14/jre
Detected OS: Linux
Finding class net.sf.antcontrib.logic.IfTask
Loaded from /opencoral/ext/ant/ant-contrib-0.6.jar
net/sf/antcontrib/logic/IfTask
.class
Class org.apache.tools.ant.taskdefs.condition.ConditionBase loaded from
parent lo
ader (parentFirst)
Class net.sf.antcontrib.logic.IfTask loaded from ant loader (parentFirst)
Finding class net.sf.antcontrib.logic.IfTask$ElseIf
Loaded from /opencoral/ext/ant/ant-contrib-0.6.jar
net/sf/antcontrib/logic/IfTask
$ElseIf.class
Class net.sf.antcontrib.logic.IfTask$ElseIf loaded from ant loader
(parentFirst)
+Datatype if net.sf.antcontrib.logic.IfTask
loadStoredProcedures:
Setting project property: this.user -> accmgr
[echo] Loading stored procedures from
/opencoral/build-rhel4/sql/storedProce
dures/accmgr.
Adding reference: this.fileset
fileset: Setup scanner in dir
/opencoral/build-rhel4/sql/storedProcedures/accmgr
with patternSet{ includes: [*.sql] excludes: [] }
[pathconvert] Set property new.files =
/opencoral/build-rhel4/sql/storedProcedure
s/accmgr/accounting_summary_source.sql:/opencoral/build-rhel4/sql/storedProcedure
s/accmgr/load_rates_source.sql:/opencoral/build-rhel4/sql/storedProcedures/accmgr
/raw_accounting_source.sql:/opencoral/build-rhel4/sql/storedProcedures/accmgr/usa
ge_summary_source.sql
Setting project property: new.files ->
/opencoral/build-rhel4/sql/storedProcedure
s/accmgr/accounting_summary_source.sql:/opencoral/build-rhel4/sql/storedProcedure
s/accmgr/load_rates_source.sql:/opencoral/build-rhel4/sql/storedProcedures/accmgr
/raw_accounting_source.sql:/opencoral/build-rhel4/sql/storedProcedures/accmgr/usa
ge_summary_source.sql
[echo] Property new.files is set to
/opencoral/build-rhel4/sql/storedProcedu
res/accmgr/accounting_summary_source.sql:/opencoral/build-rhel4/sql/storedProcedu
res/accmgr/load_rates_source.sql:/opencoral/build-rhel4/sql/storedProcedures/accm
gr/raw_accounting_source.sql:/opencoral/build-rhel4/sql/storedProcedures/accmgr/u
sage_summary_source.sql.
fileset: Setup scanner in dir
/opencoral/build-rhel4/sql/storedProcedures/accmgr
with patternSet{ includes: [*.sql] excludes: [] }
[antcall] Exiting /opencoral/build.xml.
BUILD FAILED
/opencoral/build.xml:1571: The following error occurred while executing
this line
:
/opencoral/build.xml:1594: Source file or resource collection,
transactions or sq
l statement must be set!
at
org.apache.tools.ant.ProjectHelper.addLocationToBuildException(Project
Helper.java:541)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:418)
at
org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
ava:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
orImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at
org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:62)
at net.sf.antcontrib.logic.ForEach.executeSequential(Unknown Source)
at net.sf.antcontrib.logic.ForEach.execute(Unknown Source)
at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
orImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExec
utor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
at org.apache.tools.ant.Main.runBuild(Main.java:698)
at org.apache.tools.ant.Main.startAnt(Main.java:199)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Caused by: /opencoral/build.xml:1594: Source file or resource
collection, transac
tions or sql statement must be set!
at org.apache.tools.ant.taskdefs.SQLExec.execute(SQLExec.java:390)
at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
orImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at
org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:62)
at net.sf.antcontrib.logic.IfTask.execute(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
ava:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
orImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
:105)
at org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:134)
at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
orImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
at
org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleC
heckExecutor.java:38)
at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416)
... 26 more
--- Nested Exception ---
/opencoral/build.xml:1594: Source file or resource collection,
transactions or sq
l statement must be set!
at org.apache.tools.ant.taskdefs.SQLExec.execute(SQLExec.java:390)
at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
orImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at
org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:62)
at net.sf.antcontrib.logic.IfTask.execute(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
ava:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
orImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
:105)
at org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:134)
at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
orImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
at
org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleC
heckExecutor.java:38)
at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416)
at
org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
ava:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
orImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at
org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:62)
at net.sf.antcontrib.logic.ForEach.executeSequential(Unknown Source)
at net.sf.antcontrib.logic.ForEach.execute(Unknown Source)
at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
orImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExec
utor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
at org.apache.tools.ant.Main.runBuild(Main.java:698)
at org.apache.tools.ant.Main.startAnt(Main.java:199)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Total time: 5 seconds
So, it looks, based on my pathcovert ${new.files} property that it
thinks that the fileset should contain 4 files. But, I still seem to be
generating an error when I try to load that fileset as a "refid" fileset.
Any insights or further tests .... or cleaner ways of testing for a
non-empty fileset .... would be greatly appreciated.
Thanks,
John
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: SQL task and resource collections ...
Posted by Matt Benson <gu...@yahoo.com>.
--- John Shott <sh...@stanford.edu> wrote:
> Matt:
>
> Thanks for your quick response ... I had been
> unaware of the
> <resourcecount> task/condition and will begin
> reading up on it
> immediately as that is clearly a useful feature in
> cases such as this one.
>
> I particularly appreciate the fact that you and
> Steve have both taken
> the time to look into my particular case despite
> what I'm assuming is a
> busy schedule as key contributors to the ant
> development team.
Well, actually, there were several things working in
your favor: I've seen that type of problem before,
and the test db server at my day job was down; I
needed it for some integration testing I was doing, so
this gave me some free time. It also didn't hurt that
I'd had lunch that day with an old colleague who asked
how much Ant work I'd been doing lately, so I had a
little fresh guilt to motivate me. :) In any event,
you're welcome.
-Matt
>
> Thank you for your contributions,
>
> John
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
>
>
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: SQL task and resource collections ...
Posted by John Shott <sh...@stanford.edu>.
Matt:
Thanks for your quick response ... I had been unaware of the
<resourcecount> task/condition and will begin reading up on it
immediately as that is clearly a useful feature in cases such as this one.
I particularly appreciate the fact that you and Steve have both taken
the time to look into my particular case despite what I'm assuming is a
busy schedule as key contributors to the ant development team.
Thank you for your contributions,
John
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: SQL task and resource collections ...
Posted by Matt Benson <gu...@yahoo.com>.
--- Matt Benson <gu...@yahoo.com> wrote:
> Pardon the top post, all.
>
> We have had trouble here and there with the
> difference
> between "no resources specified" (an error to be
> reported) and "no resources found" (usu. ignore and
> continue). This sounds like that kind of situation
> and I will try to look into it.
>
> As for your question about an easy way to check the
> size of a fileset, Ant 1.7 shipped with the
> <resourcecount> task/condition for just this
> purpose.
Note that this issue is fixed in svn trunk as of now.
br,
Matt
>
> HTH,
> Matt
>
> --- John Shott <sh...@stanford.edu> wrote:
>
> > Steve:
> >
> > Thanks for your informative response and your
> > suspicion that I may have
> > a problem with the size() of my fileset.
> >
> > Since I can't seem to find a simple method of
> trying
> > to test the size of
> > my fileset, in advance of my call of the sql task,
> > I've now tried to
> > modify my target to first create a fileset, then
> > created a property
> > based on a pathcovert of that fileset, and then
> > tried to run the sql
> > task based on a test of that property. While this
> > looks a little ugly
> > and kludgey, it was the only way (I thought) to
> make
> > sure that I was
> > guaranteed to not run the sql task if the fileset
> > was empty.
> >
> > My current target that includes the sql task now
> > looks like:
> >
> > <!-- build.xml snippet starts here -->
> >
> > <target name="loadStoredProcedures">
> > <basename property="this.user"
> > file="${this.dir}"/>
> > <echo message="Loading stored procedures from
> > ${this.dir}."/>
> > <fileset dir="${this.dir}" id="this.fileset">
> > <include name="*.sql"/>
> > <modified>
> > <param name="cache.cachefile"
> > value="config/.sql${sfx}.properties"/>
> > </modified>
> > </fileset>
> > <!-- The following path convert is a trick to
> > simply set a property -->
> > <!-- named ${new.files} only if there are any
> > files to be processed -->
> > <!-- in refid="this.fileset". -->
> > <pathconvert property="new.files"
> > refid="this.fileset"
> > setonempty="false" targetos="unix"/>
> > <if> <isset property="new.files"/>
> > <then>
> > <echo message="Property new.files is set
> to
> > ${new.files}."/>
> > <sql driver="${jdbc_driver_class}"
> > url="${jdbc_url}"
> > userid="${this.user}"
> > password="${coral.db.password}"
> > keepformat="true" delimiter="/"
> > escapeprocessing="false"
> > print="true"
> > onerror="continue">
> > <fileset refid="this.fileset"/>
> > <classpath>
> > <pathelement
> > location="${build.dir}/ext/${jdbc.jar}"/>
> > </classpath>
> > </sql>
> > </then>
> > </if>
> > </target>
> >
> > <!-- build.xml snippet ends here -->
> >
> > I still believe that I am still seeing a failure
> > during the sql task and
> > have included what I believe to be the relevant
> > results of the call 'ant
> > -debug loadStoredProcedures 2>&1 | tee
> > sql_debug.log'
> >
> > Apache Ant version 1.7.0 compiled on December 13
> > 2006
> > Buildfile: build.xml
> > Adding reference: ant.PropertyHelper
> > Detected Java version: 1.5 in:
> > /usr/java/jdk1.5.0_14/jre
> > Detected OS: Linux
> > Finding class net.sf.antcontrib.logic.IfTask
> > Loaded from /opencoral/ext/ant/ant-contrib-0.6.jar
>
> > net/sf/antcontrib/logic/IfTask
> > .class
> > Class
> >
>
org.apache.tools.ant.taskdefs.condition.ConditionBase
> > loaded from
> > parent lo
> > ader (parentFirst)
> > Class net.sf.antcontrib.logic.IfTask loaded from
> ant
> > loader (parentFirst)
> > Finding class
> net.sf.antcontrib.logic.IfTask$ElseIf
> > Loaded from /opencoral/ext/ant/ant-contrib-0.6.jar
>
> > net/sf/antcontrib/logic/IfTask
> > $ElseIf.class
> > Class net.sf.antcontrib.logic.IfTask$ElseIf loaded
> > from ant loader
> > (parentFirst)
> > +Datatype if net.sf.antcontrib.logic.IfTask
> >
> > loadStoredProcedures:
> > Setting project property: this.user -> accmgr
> > [echo] Loading stored procedures from
> > /opencoral/build-rhel4/sql/storedProce
> > dures/accmgr.
> > Adding reference: this.fileset
> > fileset: Setup scanner in dir
> > /opencoral/build-rhel4/sql/storedProcedures/accmgr
> > with patternSet{ includes: [*.sql] excludes: [] }
> > [pathconvert] Set property new.files =
> > /opencoral/build-rhel4/sql/storedProcedure
> >
>
s/accmgr/accounting_summary_source.sql:/opencoral/build-rhel4/sql/storedProcedure
> >
>
s/accmgr/load_rates_source.sql:/opencoral/build-rhel4/sql/storedProcedures/accmgr
> >
>
/raw_accounting_source.sql:/opencoral/build-rhel4/sql/storedProcedures/accmgr/usa
> > ge_summary_source.sql
> > Setting project property: new.files ->
> > /opencoral/build-rhel4/sql/storedProcedure
> >
>
s/accmgr/accounting_summary_source.sql:/opencoral/build-rhel4/sql/storedProcedure
> >
>
s/accmgr/load_rates_source.sql:/opencoral/build-rhel4/sql/storedProcedures/accmgr
> >
>
/raw_accounting_source.sql:/opencoral/build-rhel4/sql/storedProcedures/accmgr/usa
> > ge_summary_source.sql
> > [echo] Property new.files is set to
> > /opencoral/build-rhel4/sql/storedProcedu
> >
>
res/accmgr/accounting_summary_source.sql:/opencoral/build-rhel4/sql/storedProcedu
> >
>
res/accmgr/load_rates_source.sql:/opencoral/build-rhel4/sql/storedProcedures/accm
> >
>
gr/raw_accounting_source.sql:/opencoral/build-rhel4/sql/storedProcedures/accmgr/u
> > sage_summary_source.sql.
> > fileset: Setup scanner in dir
> > /opencoral/build-rhel4/sql/storedProcedures/accmgr
> > with patternSet{ includes: [*.sql] excludes: [] }
> > [antcall] Exiting /opencoral/build.xml.
> >
> > BUILD FAILED
> > /opencoral/build.xml:1571: The following error
> > occurred while executing
> > this line
> > :
> > /opencoral/build.xml:1594: Source file or resource
> > collection,
> > transactions or sq
> > l statement must be set!
> > at
> >
>
org.apache.tools.ant.ProjectHelper.addLocationToBuildException(Project
> > Helper.java:541)
> > at
> >
>
org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:418)
> > at
> >
>
org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
> > at
> >
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> > Method)
> > at
> >
>
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
> > ava:39)
> > at
> >
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> > orImpl.java:25)
> > at
> > java.lang.reflect.Method.invoke(Method.java:585)
> > at
> >
>
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
> > :105)
> > at
> > org.apache.tools.ant.Task.perform(Task.java:348)
> > at
> >
>
org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:62)
> > at
> >
>
net.sf.antcontrib.logic.ForEach.executeSequential(Unknown
> > Source)
> > at
> > net.sf.antcontrib.logic.ForEach.execute(Unknown
> > Source)
> > at
> >
>
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
> > at
> >
> sun.reflect.GeneratedMethodAccessor2.invoke(Unknown
> > Source)
> > at
> >
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> > orImpl.java:25)
> > at
> > java.lang.reflect.Method.invoke(Method.java:585)
> > at
> >
>
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
> > :105)
> > at
> > org.apache.tools.ant.Task.perform(Task.java:348)
> > at
> >
> org.apache.tools.ant.Target.execute(Target.java:357)
> > at
> >
>
org.apache.tools.ant.Target.performTasks(Target.java:385)
> > at
> >
>
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
> > at
> >
>
org.apache.tools.ant.Project.executeTarget(Project.java:1298)
> > at
> >
>
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExec
> > utor.java:41)
> > at
> >
>
org.apache.tools.ant.Project.executeTargets(Project.java:1181)
> > at
> > org.apache.tools.ant.Main.runBuild(Main.java:698)
> > at
> > org.apache.tools.ant.Main.startAnt(Main.java:199)
> > at
> >
>
org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
> > at
> >
>
org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
> > Caused by: /opencoral/build.xml:1594: Source file
> or
> > resource
> > collection, transac
> > tions or sql statement must be set!
> > at
> >
>
org.apache.tools.ant.taskdefs.SQLExec.execute(SQLExec.java:390)
> > at
> >
>
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
> > at
> >
> sun.reflect.GeneratedMethodAccessor2.invoke(Unknown
> > Source)
> > at
> >
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> > orImpl.java:25)
> > at
> > java.lang.reflect.Method.invoke(Method.java:585)
> > at
> >
>
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
> > :105)
> > at
> > org.apache.tools.ant.Task.perform(Task.java:348)
> > at
> >
>
org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:62)
> > at
> > net.sf.antcontrib.logic.IfTask.execute(Unknown
> > Source)
> > at
> >
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> > Method)
> > at
> >
>
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
> > ava:39)
> > at
> >
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> > orImpl.java:25)
> > at
> > java.lang.reflect.Method.invoke(Method.java:585)
> > at
> >
>
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
> > :105)
> > at
> >
>
org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:134)
> > at
> >
>
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
> > at
> >
> sun.reflect.GeneratedMethodAccessor2.invoke(Unknown
> > Source)
> > at
> >
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> > orImpl.java:25)
> > at
> > java.lang.reflect.Method.invoke(Method.java:585)
> > at
> >
>
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
> > :105)
> > at
> > org.apache.tools.ant.Task.perform(Task.java:348)
> > at
> >
> org.apache.tools.ant.Target.execute(Target.java:357)
> > at
> >
>
org.apache.tools.ant.Target.performTasks(Target.java:385)
> > at
> >
>
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
> > at
> >
>
org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleC
> > heckExecutor.java:38)
> > at
> >
>
org.apache.tools.ant.Project.executeTargets(Project.java:1181)
> > at
> >
>
org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416)
> > ... 26 more
> > --- Nested Exception ---
> > /opencoral/build.xml:1594: Source file or resource
> > collection,
> > transactions or sq
> > l statement must be set!
> > at
> >
>
org.apache.tools.ant.taskdefs.SQLExec.execute(SQLExec.java:390)
> > at
> >
>
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
> > at
> >
> sun.reflect.GeneratedMethodAccessor2.invoke(Unknown
> > Source)
> > at
> >
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> > orImpl.java:25)
> > at
> > java.lang.reflect.Method.invoke(Method.java:585)
> > at
> >
>
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
> > :105)
> > at
> > org.apache.tools.ant.Task.perform(Task.java:348)
> > at
> >
>
org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:62)
> > at
> > net.sf.antcontrib.logic.IfTask.execute(Unknown
> > Source)
> > at
> >
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> > Method)
> > at
> >
>
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
> > ava:39)
> > at
> >
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> > orImpl.java:25)
> > at
> > java.lang.reflect.Method.invoke(Method.java:585)
> > at
> >
>
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
> > :105)
> > at
> >
>
org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:134)
> > at
> >
>
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
> > at
> >
> sun.reflect.GeneratedMethodAccessor2.invoke(Unknown
> > Source)
> > at
> >
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> > orImpl.java:25)
> > at
> > java.lang.reflect.Method.invoke(Method.java:585)
> > at
> >
>
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
> > :105)
> > at
> > org.apache.tools.ant.Task.perform(Task.java:348)
> > at
> >
> org.apache.tools.ant.Target.execute(Target.java:357)
> > at
> >
>
org.apache.tools.ant.Target.performTasks(Target.java:385)
> > at
> >
>
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
> > at
> >
>
org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleC
> > heckExecutor.java:38)
> > at
> >
>
org.apache.tools.ant.Project.executeTargets(Project.java:1181)
> > at
> >
>
org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416)
> > at
> >
>
org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
> > at
> >
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> > Method)
> > at
> >
>
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
> > ava:39)
> > at
> >
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> > orImpl.java:25)
> > at
> > java.lang.reflect.Method.invoke(Method.java:585)
> > at
> >
>
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
> > :105)
> > at
> > org.apache.tools.ant.Task.perform(Task.java:348)
> > at
> >
>
org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:62)
> > at
> >
>
net.sf.antcontrib.logic.ForEach.executeSequential(Unknown
> > Source)
> > at
> > net.sf.antcontrib.logic.ForEach.execute(Unknown
> > Source)
> > at
> >
>
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
> > at
> >
> sun.reflect.GeneratedMethodAccessor2.invoke(Unknown
> > Source)
> > at
> >
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> > orImpl.java:25)
> > at
> > java.lang.reflect.Method.invoke(Method.java:585)
> > at
> >
>
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
> > :105)
> > at
> > org.apache.tools.ant.Task.perform(Task.java:348)
> > at
> >
> org.apache.tools.ant.Target.execute(Target.java:357)
> > at
> >
>
org.apache.tools.ant.Target.performTasks(Target.java:385)
> > at
> >
>
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
> > at
> >
>
org.apache.tools.ant.Project.executeTarget(Project.java:1298)
> > at
> >
>
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExec
> > utor.java:41)
> > at
> >
>
org.apache.tools.ant.Project.executeTargets(Project.java:1181)
> > at
> > org.apache.tools.ant.Main.runBuild(Main.java:698)
> > at
> > org.apache.tools.ant.Main.startAnt(Main.java:199)
> > at
> >
>
org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
> > at
> >
>
org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
> >
> > Total time: 5 seconds
> >
> > So, it looks, based on my pathcovert ${new.files}
> > property that it
> > thinks that the fileset should contain 4 files.
> > But, I still seem to be
> > generating an error when I try to load that
> fileset
> > as a "refid" fileset.
> >
> > Any insights or further tests .... or cleaner ways
> > of testing for a
> > non-empty fileset .... would be greatly
> appreciated.
> >
> > Thanks,
> >
> > John
> >
> >
> >
> >
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > user-unsubscribe@ant.apache.org
> > For additional commands, e-mail:
> > user-help@ant.apache.org
> >
> >
>
>
>
>
>
____________________________________________________________________________________
> Never miss a thing. Make Yahoo your home page.
> http://www.yahoo.com/r/hs
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
>
>
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: SQL task and resource collections ...
Posted by Matt Benson <gu...@yahoo.com>.
Pardon the top post, all.
We have had trouble here and there with the difference
between "no resources specified" (an error to be
reported) and "no resources found" (usu. ignore and
continue). This sounds like that kind of situation
and I will try to look into it.
As for your question about an easy way to check the
size of a fileset, Ant 1.7 shipped with the
<resourcecount> task/condition for just this purpose.
HTH,
Matt
--- John Shott <sh...@stanford.edu> wrote:
> Steve:
>
> Thanks for your informative response and your
> suspicion that I may have
> a problem with the size() of my fileset.
>
> Since I can't seem to find a simple method of trying
> to test the size of
> my fileset, in advance of my call of the sql task,
> I've now tried to
> modify my target to first create a fileset, then
> created a property
> based on a pathcovert of that fileset, and then
> tried to run the sql
> task based on a test of that property. While this
> looks a little ugly
> and kludgey, it was the only way (I thought) to make
> sure that I was
> guaranteed to not run the sql task if the fileset
> was empty.
>
> My current target that includes the sql task now
> looks like:
>
> <!-- build.xml snippet starts here -->
>
> <target name="loadStoredProcedures">
> <basename property="this.user"
> file="${this.dir}"/>
> <echo message="Loading stored procedures from
> ${this.dir}."/>
> <fileset dir="${this.dir}" id="this.fileset">
> <include name="*.sql"/>
> <modified>
> <param name="cache.cachefile"
> value="config/.sql${sfx}.properties"/>
> </modified>
> </fileset>
> <!-- The following path convert is a trick to
> simply set a property -->
> <!-- named ${new.files} only if there are any
> files to be processed -->
> <!-- in refid="this.fileset". -->
> <pathconvert property="new.files"
> refid="this.fileset"
> setonempty="false" targetos="unix"/>
> <if> <isset property="new.files"/>
> <then>
> <echo message="Property new.files is set to
> ${new.files}."/>
> <sql driver="${jdbc_driver_class}"
> url="${jdbc_url}"
> userid="${this.user}"
> password="${coral.db.password}"
> keepformat="true" delimiter="/"
> escapeprocessing="false"
> print="true"
> onerror="continue">
> <fileset refid="this.fileset"/>
> <classpath>
> <pathelement
> location="${build.dir}/ext/${jdbc.jar}"/>
> </classpath>
> </sql>
> </then>
> </if>
> </target>
>
> <!-- build.xml snippet ends here -->
>
> I still believe that I am still seeing a failure
> during the sql task and
> have included what I believe to be the relevant
> results of the call 'ant
> -debug loadStoredProcedures 2>&1 | tee
> sql_debug.log'
>
> Apache Ant version 1.7.0 compiled on December 13
> 2006
> Buildfile: build.xml
> Adding reference: ant.PropertyHelper
> Detected Java version: 1.5 in:
> /usr/java/jdk1.5.0_14/jre
> Detected OS: Linux
> Finding class net.sf.antcontrib.logic.IfTask
> Loaded from /opencoral/ext/ant/ant-contrib-0.6.jar
> net/sf/antcontrib/logic/IfTask
> .class
> Class
>
org.apache.tools.ant.taskdefs.condition.ConditionBase
> loaded from
> parent lo
> ader (parentFirst)
> Class net.sf.antcontrib.logic.IfTask loaded from ant
> loader (parentFirst)
> Finding class net.sf.antcontrib.logic.IfTask$ElseIf
> Loaded from /opencoral/ext/ant/ant-contrib-0.6.jar
> net/sf/antcontrib/logic/IfTask
> $ElseIf.class
> Class net.sf.antcontrib.logic.IfTask$ElseIf loaded
> from ant loader
> (parentFirst)
> +Datatype if net.sf.antcontrib.logic.IfTask
>
> loadStoredProcedures:
> Setting project property: this.user -> accmgr
> [echo] Loading stored procedures from
> /opencoral/build-rhel4/sql/storedProce
> dures/accmgr.
> Adding reference: this.fileset
> fileset: Setup scanner in dir
> /opencoral/build-rhel4/sql/storedProcedures/accmgr
> with patternSet{ includes: [*.sql] excludes: [] }
> [pathconvert] Set property new.files =
> /opencoral/build-rhel4/sql/storedProcedure
>
s/accmgr/accounting_summary_source.sql:/opencoral/build-rhel4/sql/storedProcedure
>
s/accmgr/load_rates_source.sql:/opencoral/build-rhel4/sql/storedProcedures/accmgr
>
/raw_accounting_source.sql:/opencoral/build-rhel4/sql/storedProcedures/accmgr/usa
> ge_summary_source.sql
> Setting project property: new.files ->
> /opencoral/build-rhel4/sql/storedProcedure
>
s/accmgr/accounting_summary_source.sql:/opencoral/build-rhel4/sql/storedProcedure
>
s/accmgr/load_rates_source.sql:/opencoral/build-rhel4/sql/storedProcedures/accmgr
>
/raw_accounting_source.sql:/opencoral/build-rhel4/sql/storedProcedures/accmgr/usa
> ge_summary_source.sql
> [echo] Property new.files is set to
> /opencoral/build-rhel4/sql/storedProcedu
>
res/accmgr/accounting_summary_source.sql:/opencoral/build-rhel4/sql/storedProcedu
>
res/accmgr/load_rates_source.sql:/opencoral/build-rhel4/sql/storedProcedures/accm
>
gr/raw_accounting_source.sql:/opencoral/build-rhel4/sql/storedProcedures/accmgr/u
> sage_summary_source.sql.
> fileset: Setup scanner in dir
> /opencoral/build-rhel4/sql/storedProcedures/accmgr
> with patternSet{ includes: [*.sql] excludes: [] }
> [antcall] Exiting /opencoral/build.xml.
>
> BUILD FAILED
> /opencoral/build.xml:1571: The following error
> occurred while executing
> this line
> :
> /opencoral/build.xml:1594: Source file or resource
> collection,
> transactions or sq
> l statement must be set!
> at
>
org.apache.tools.ant.ProjectHelper.addLocationToBuildException(Project
> Helper.java:541)
> at
>
org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:418)
> at
>
org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
> at
>
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
> ava:39)
> at
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> orImpl.java:25)
> at
> java.lang.reflect.Method.invoke(Method.java:585)
> at
>
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
> :105)
> at
> org.apache.tools.ant.Task.perform(Task.java:348)
> at
>
org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:62)
> at
>
net.sf.antcontrib.logic.ForEach.executeSequential(Unknown
> Source)
> at
> net.sf.antcontrib.logic.ForEach.execute(Unknown
> Source)
> at
>
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
> at
> sun.reflect.GeneratedMethodAccessor2.invoke(Unknown
> Source)
> at
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> orImpl.java:25)
> at
> java.lang.reflect.Method.invoke(Method.java:585)
> at
>
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
> :105)
> at
> org.apache.tools.ant.Task.perform(Task.java:348)
> at
> org.apache.tools.ant.Target.execute(Target.java:357)
> at
>
org.apache.tools.ant.Target.performTasks(Target.java:385)
> at
>
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
> at
>
org.apache.tools.ant.Project.executeTarget(Project.java:1298)
> at
>
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExec
> utor.java:41)
> at
>
org.apache.tools.ant.Project.executeTargets(Project.java:1181)
> at
> org.apache.tools.ant.Main.runBuild(Main.java:698)
> at
> org.apache.tools.ant.Main.startAnt(Main.java:199)
> at
>
org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
> at
>
org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
> Caused by: /opencoral/build.xml:1594: Source file or
> resource
> collection, transac
> tions or sql statement must be set!
> at
>
org.apache.tools.ant.taskdefs.SQLExec.execute(SQLExec.java:390)
> at
>
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
> at
> sun.reflect.GeneratedMethodAccessor2.invoke(Unknown
> Source)
> at
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> orImpl.java:25)
> at
> java.lang.reflect.Method.invoke(Method.java:585)
> at
>
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
> :105)
> at
> org.apache.tools.ant.Task.perform(Task.java:348)
> at
>
org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:62)
> at
> net.sf.antcontrib.logic.IfTask.execute(Unknown
> Source)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
> at
>
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
> ava:39)
> at
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> orImpl.java:25)
> at
> java.lang.reflect.Method.invoke(Method.java:585)
> at
>
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
> :105)
> at
>
org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:134)
> at
>
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
> at
> sun.reflect.GeneratedMethodAccessor2.invoke(Unknown
> Source)
> at
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> orImpl.java:25)
> at
> java.lang.reflect.Method.invoke(Method.java:585)
> at
>
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
> :105)
> at
> org.apache.tools.ant.Task.perform(Task.java:348)
> at
> org.apache.tools.ant.Target.execute(Target.java:357)
> at
>
org.apache.tools.ant.Target.performTasks(Target.java:385)
> at
>
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
> at
>
org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleC
> heckExecutor.java:38)
> at
>
org.apache.tools.ant.Project.executeTargets(Project.java:1181)
> at
>
org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416)
> ... 26 more
> --- Nested Exception ---
> /opencoral/build.xml:1594: Source file or resource
> collection,
> transactions or sq
> l statement must be set!
> at
>
org.apache.tools.ant.taskdefs.SQLExec.execute(SQLExec.java:390)
> at
>
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
> at
> sun.reflect.GeneratedMethodAccessor2.invoke(Unknown
> Source)
> at
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> orImpl.java:25)
> at
> java.lang.reflect.Method.invoke(Method.java:585)
> at
>
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
> :105)
> at
> org.apache.tools.ant.Task.perform(Task.java:348)
> at
>
org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:62)
> at
> net.sf.antcontrib.logic.IfTask.execute(Unknown
> Source)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
> at
>
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
> ava:39)
> at
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> orImpl.java:25)
> at
> java.lang.reflect.Method.invoke(Method.java:585)
> at
>
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
> :105)
> at
>
org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:134)
> at
>
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
> at
> sun.reflect.GeneratedMethodAccessor2.invoke(Unknown
> Source)
> at
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> orImpl.java:25)
> at
> java.lang.reflect.Method.invoke(Method.java:585)
> at
>
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
> :105)
> at
> org.apache.tools.ant.Task.perform(Task.java:348)
> at
> org.apache.tools.ant.Target.execute(Target.java:357)
> at
>
org.apache.tools.ant.Target.performTasks(Target.java:385)
> at
>
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
> at
>
org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleC
> heckExecutor.java:38)
> at
>
org.apache.tools.ant.Project.executeTargets(Project.java:1181)
> at
>
org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416)
> at
>
org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
> at
>
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
> ava:39)
> at
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> orImpl.java:25)
> at
> java.lang.reflect.Method.invoke(Method.java:585)
> at
>
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
> :105)
> at
> org.apache.tools.ant.Task.perform(Task.java:348)
> at
>
org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:62)
> at
>
net.sf.antcontrib.logic.ForEach.executeSequential(Unknown
> Source)
> at
> net.sf.antcontrib.logic.ForEach.execute(Unknown
> Source)
> at
>
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
> at
> sun.reflect.GeneratedMethodAccessor2.invoke(Unknown
> Source)
> at
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
> orImpl.java:25)
> at
> java.lang.reflect.Method.invoke(Method.java:585)
> at
>
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
> :105)
> at
> org.apache.tools.ant.Task.perform(Task.java:348)
> at
> org.apache.tools.ant.Target.execute(Target.java:357)
> at
>
org.apache.tools.ant.Target.performTasks(Target.java:385)
> at
>
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
> at
>
org.apache.tools.ant.Project.executeTarget(Project.java:1298)
> at
>
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExec
> utor.java:41)
> at
>
org.apache.tools.ant.Project.executeTargets(Project.java:1181)
> at
> org.apache.tools.ant.Main.runBuild(Main.java:698)
> at
> org.apache.tools.ant.Main.startAnt(Main.java:199)
> at
>
org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
> at
>
org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
>
> Total time: 5 seconds
>
> So, it looks, based on my pathcovert ${new.files}
> property that it
> thinks that the fileset should contain 4 files.
> But, I still seem to be
> generating an error when I try to load that fileset
> as a "refid" fileset.
>
> Any insights or further tests .... or cleaner ways
> of testing for a
> non-empty fileset .... would be greatly appreciated.
>
> Thanks,
>
> John
>
>
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
>
>
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: SQL task and resource collections ...
Posted by John Shott <sh...@stanford.edu>.
Steve:
Thanks for your informative response and your suspicion that I may have
a problem with the size() of my fileset.
Since I can't seem to find a simple method of trying to test the size of
my fileset, in advance of my call of the sql task, I've now tried to
modify my target to first create a fileset, then created a property
based on a pathcovert of that fileset, and then tried to run the sql
task based on a test of that property. While this looks a little ugly
and kludgey, it was the only way (I thought) to make sure that I was
guaranteed to not run the sql task if the fileset was empty.
My current target that includes the sql task now looks like:
<!-- build.xml snippet starts here -->
<target name="loadStoredProcedures">
<basename property="this.user" file="${this.dir}"/>
<echo message="Loading stored procedures from ${this.dir}."/>
<fileset dir="${this.dir}" id="this.fileset">
<include name="*.sql"/>
<modified>
<param name="cache.cachefile" value="config/.sql${sfx}.properties"/>
</modified>
</fileset>
<!-- The following path convert is a trick to simply set a property -->
<!-- named ${new.files} only if there are any files to be processed -->
<!-- in refid="this.fileset". -->
<pathconvert property="new.files" refid="this.fileset"
setonempty="false" targetos="unix"/>
<if> <isset property="new.files"/>
<then>
<echo message="Property new.files is set to ${new.files}."/>
<sql driver="${jdbc_driver_class}" url="${jdbc_url}"
userid="${this.user}" password="${coral.db.password}"
keepformat="true" delimiter="/" escapeprocessing="false"
print="true"
onerror="continue">
<fileset refid="this.fileset"/>
<classpath>
<pathelement location="${build.dir}/ext/${jdbc.jar}"/>
</classpath>
</sql>
</then>
</if>
</target>
<!-- build.xml snippet ends here -->
I still believe that I am still seeing a failure during the sql task and
have included what I believe to be the relevant results of the call 'ant
-debug loadStoredProcedures 2>&1 | tee sql_debug.log'
Apache Ant version 1.7.0 compiled on December 13 2006
Buildfile: build.xml
Adding reference: ant.PropertyHelper
Detected Java version: 1.5 in: /usr/java/jdk1.5.0_14/jre
Detected OS: Linux
Finding class net.sf.antcontrib.logic.IfTask
Loaded from /opencoral/ext/ant/ant-contrib-0.6.jar
net/sf/antcontrib/logic/IfTask
.class
Class org.apache.tools.ant.taskdefs.condition.ConditionBase loaded from
parent lo
ader (parentFirst)
Class net.sf.antcontrib.logic.IfTask loaded from ant loader (parentFirst)
Finding class net.sf.antcontrib.logic.IfTask$ElseIf
Loaded from /opencoral/ext/ant/ant-contrib-0.6.jar
net/sf/antcontrib/logic/IfTask
$ElseIf.class
Class net.sf.antcontrib.logic.IfTask$ElseIf loaded from ant loader
(parentFirst)
+Datatype if net.sf.antcontrib.logic.IfTask
loadStoredProcedures:
Setting project property: this.user -> accmgr
[echo] Loading stored procedures from
/opencoral/build-rhel4/sql/storedProce
dures/accmgr.
Adding reference: this.fileset
fileset: Setup scanner in dir
/opencoral/build-rhel4/sql/storedProcedures/accmgr
with patternSet{ includes: [*.sql] excludes: [] }
[pathconvert] Set property new.files =
/opencoral/build-rhel4/sql/storedProcedure
s/accmgr/accounting_summary_source.sql:/opencoral/build-rhel4/sql/storedProcedure
s/accmgr/load_rates_source.sql:/opencoral/build-rhel4/sql/storedProcedures/accmgr
/raw_accounting_source.sql:/opencoral/build-rhel4/sql/storedProcedures/accmgr/usa
ge_summary_source.sql
Setting project property: new.files ->
/opencoral/build-rhel4/sql/storedProcedure
s/accmgr/accounting_summary_source.sql:/opencoral/build-rhel4/sql/storedProcedure
s/accmgr/load_rates_source.sql:/opencoral/build-rhel4/sql/storedProcedures/accmgr
/raw_accounting_source.sql:/opencoral/build-rhel4/sql/storedProcedures/accmgr/usa
ge_summary_source.sql
[echo] Property new.files is set to
/opencoral/build-rhel4/sql/storedProcedu
res/accmgr/accounting_summary_source.sql:/opencoral/build-rhel4/sql/storedProcedu
res/accmgr/load_rates_source.sql:/opencoral/build-rhel4/sql/storedProcedures/accm
gr/raw_accounting_source.sql:/opencoral/build-rhel4/sql/storedProcedures/accmgr/u
sage_summary_source.sql.
fileset: Setup scanner in dir
/opencoral/build-rhel4/sql/storedProcedures/accmgr
with patternSet{ includes: [*.sql] excludes: [] }
[antcall] Exiting /opencoral/build.xml.
BUILD FAILED
/opencoral/build.xml:1571: The following error occurred while executing
this line
:
/opencoral/build.xml:1594: Source file or resource collection,
transactions or sq
l statement must be set!
at
org.apache.tools.ant.ProjectHelper.addLocationToBuildException(Project
Helper.java:541)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:418)
at
org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
ava:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
orImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at
org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:62)
at net.sf.antcontrib.logic.ForEach.executeSequential(Unknown Source)
at net.sf.antcontrib.logic.ForEach.execute(Unknown Source)
at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
orImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExec
utor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
at org.apache.tools.ant.Main.runBuild(Main.java:698)
at org.apache.tools.ant.Main.startAnt(Main.java:199)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Caused by: /opencoral/build.xml:1594: Source file or resource
collection, transac
tions or sql statement must be set!
at org.apache.tools.ant.taskdefs.SQLExec.execute(SQLExec.java:390)
at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
orImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at
org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:62)
at net.sf.antcontrib.logic.IfTask.execute(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
ava:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
orImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
:105)
at org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:134)
at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
orImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
at
org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleC
heckExecutor.java:38)
at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416)
... 26 more
--- Nested Exception ---
/opencoral/build.xml:1594: Source file or resource collection,
transactions or sq
l statement must be set!
at org.apache.tools.ant.taskdefs.SQLExec.execute(SQLExec.java:390)
at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
orImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at
org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:62)
at net.sf.antcontrib.logic.IfTask.execute(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
ava:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
orImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
:105)
at org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:134)
at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
orImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
at
org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleC
heckExecutor.java:38)
at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416)
at
org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
ava:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
orImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at
org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:62)
at net.sf.antcontrib.logic.ForEach.executeSequential(Unknown Source)
at net.sf.antcontrib.logic.ForEach.execute(Unknown Source)
at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess
orImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExec
utor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
at org.apache.tools.ant.Main.runBuild(Main.java:698)
at org.apache.tools.ant.Main.startAnt(Main.java:199)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Total time: 5 seconds
So, it looks, based on my pathcovert ${new.files} property that it
thinks that the fileset should contain 4 files. But, I still seem to be
generating an error when I try to load that fileset as a "refid" fileset.
Any insights or further tests .... or cleaner ways of testing for a
non-empty fileset .... would be greatly appreciated.
Thanks,
John
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: SQL task and resource collections ...
Posted by Steve Loughran <st...@apache.org>.
John Shott wrote:
> Ant community:
>
> I'm trying to upgrade my build.xml to be ant 1.7.0 compatible and seem
> to be stumbling on changes in the SQL task related to resource collections.
>
> I have been trying:
>
> <sql driver="${jdbc_driver_class}" url="${jdbc_url}"
> userid="${this.user}" password="${this.password}"
> keepformat="true" delimiter="/" escapeprocessing="false"
> print="true"
> onerror="continue">
> <fileset dir="${this.dir}">
> <include name="*.sql"/>
> <modified>
> <param name="cache.cachefile" value="./sql.properties"/>
> </modified>
> </fileset>
> <classpath>
> <pathelement location="${build.dir}/${jdbc.jar}"/>
> </classpath>
> </sql>
>
> I keep getting the error message: "Source file or resource collection,
> transactions, or sql statement must be set!". I thought that a fileset
> WAS a resource collection and the manual says:
>
>> You can specify multiple sources via nested resource collection
>> elements. Each resource of the collection will be run in a transaction
>> of its own. Prior to Ant 1.7 only filesets were supported. Use a sort
>> resource collection to get a predictable order of transactions.
>>
> which, to me at least, indicates that a fileset should still be supported.
> Can anyone shed some light on this or help me to see what I've fouled up
> here? I can't seem to figure out what I'm doing wrong.
>
the fileset should be supported; as you say -it is an RC.
1. you see that message if you have nothing to ussue
if (srcFile == null && sqlCommand.length() == 0
&& resources.size() == 0) {
if (transactions.size() == 0) {
throw new BuildException("Source file or resource
collection, "
+ "transactions or sql
statement "
+ "must be set!",
getLocation());
}
2. adding a fileset adds it as a resource
/**
* Adds a set of files (nested fileset attribute).
* @param set a set of files contains SQL commands, each File is run in
* a separate transaction.
*/
public void addFileset(FileSet set) {
add(set);
}
/**
* Adds a collection of resources (nested element).
* @param rc a collection of resources containing SQL commands,
* each resource is run in a separate transaction.
* @since Ant 1.7
*/
public void add(ResourceCollection rc) {
resources.add(rc);
}
So, assuming the file is added, maybe size() function returns 0.
public synchronized int size() {
if (isReference()) {
return ((BaseResourceCollectionContainer)
getCheckedRef()).size();
}
dieOnCircularReference();
return cacheCollection().size();
}
So, it just returns the size of the #of added elements. Which should be
>0. In theory, all should be well.
What does a -debug run say?
--
Steve Loughran http://www.1060.org/blogxter/publish/5
Author: Ant in Action http://antbook.org/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org