commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james_strac...@yahoo.co.uk>
Subject Re: [Jelly] Using Ant <parallel> and <thread> tags
Date Tue, 08 Oct 2002 12:58:47 GMT
Just for the benefit of the list, this issue is now fixed in CVS HEAD and
the latest Jelly snapshot.

There's an example of this test case in action via

    maven demo:async

(which requires the latest snapshot to be installed in your Maven build for
it to work).

James
-------
http://radio.weblogs.com/0112098/
----- Original Message -----
From: "Vincent Massol" <vmassol@octo.com>
To: "'Jakarta Commons Developers List'" <commons-dev@jakarta.apache.org>
Sent: Monday, October 07, 2002 7:53 PM
Subject: RE: [Jelly] Using Ant <parallel> and <thread> tags


> James,
>
> I have narrowed the problem to the fact that the "context" instance
> variable in the Werkz ProjectTag object is null, as the code fails on:
>
> project = (Project) context.findVariable(
> "org.apache.commons.jelly.werkz.Project" );
>
> with a NullPointerException.
>
> The problem is that I don't know why and how it can be null...
>
> Any idea?
>
> Here's some simple code to reproduce the problem:
>
> <?xml version="1.0"?>
> <project xmlns:j="jelly:core">
>
>   <goal name="xx">
>
>     <j:thread>
>       <attainGoal name="yy"/>
>     </j:thread>
>
>     <echo>XXXX</echo>
>
>   </goal>
>
>   <goal name="yy">
>     <echo>YYYY</echo>
>   </goal>
>
> </project>
>
> then type "maven xx".
>
>
> The "funny" part is that it works it I remove any code after the closing
> </j:thread> tag but fails if I have any code there. Thus:
>
>   <goal name="xx">
>
>     <j:thread>
>       <attainGoal name="yy"/>
>     </j:thread>
>
>   </goal>
>
> works. However, there is no "YYYY" printed on the screen ...
>
> I have added a e.printStackTrace(); in TagScript's handleException()
> call to get the real error as it is otherwise hidden. Here's the stack
> trace I get:
>
> cactus:xx:
> [ERROR] java.lang.NullPointerException
> [ERROR]         at
> org.apache.commons.jelly.tags.werkz.ProjectTag.getProject(ProjectTag.jav
> a:96)
> [ERROR]         at
> org.apache.commons.jelly.tags.werkz.AttainGoalTag.doTag(AttainGoalTag.ja
> va:109)
> [ERROR]         at
> org.apache.commons.jelly.impl.TagScript.run(TagScript.java:268)
> [ERROR]         at
> org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:134)
> [ERROR]         at
> org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:190)
> [ERROR]         at
> org.apache.commons.jelly.tags.core.ThreadTag$1.run(ThreadTag.java:93)
> [ERROR]         at java.lang.Thread.run(Thread.java:479)
> [ERROR] org.apache.commons.jelly.JellyException:
> java.lang.NullPointerException File: E:\Vma\Projets
> \Encours\ICOM\Icom\environment\tools\maven\plugins\maven-cactus-plugin-1
> .0\plugin.jelly At tag <attainGoal>: line: 31 column: 34
> [ERROR]         at
> org.apache.commons.jelly.impl.TagScript.handleException(TagScript.java:5
> 12)
> [ERROR]         at
> org.apache.commons.jelly.impl.TagScript.run(TagScript.java:274)
> [ERROR]         at
> org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:134)
> [ERROR]         at
> org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:190)
> [ERROR]         at
> org.apache.commons.jelly.tags.core.ThreadTag$1.run(ThreadTag.java:93)
> [ERROR]         at java.lang.Thread.run(Thread.java:479)
>     [echo] XXXX
>
> Thanks
> -Vincent
>
>
> > -----Original Message-----
> > From: Vincent Massol [mailto:vmassol@octo.com]
> > Sent: 07 October 2002 17:59
> > To: 'Jakarta Commons Developers List'
> > Subject: RE: [Jelly] Using Ant <parallel> and <thread> tags
> >
> >
> >
> > > -----Original Message-----
> > > From: James Strachan [mailto:james_strachan@yahoo.co.uk]
> > > Sent: 07 October 2002 16:08
> > > To: Jakarta Commons Developers List
> > > Subject: Re: [Jelly] Using Ant <parallel> and <thread> tags
> > >
> > > From: "Vincent Massol" <vmassol@octo.com>
> > > > I am porting the following code Jelly:
> > > >
> > > >     <parallel>
> > > >       <antCall target="cactus:tomcat-4x-start"/>
> > > >       <sequential>
> > > >         <waitfor maxwaitunit="millisecond" checkevery="500">
> > > >           <http
> > > >
> >
> url="http://localhost:${maven.cactus.port}/test/ServletRedirector?Cactus
> > > > _Service=RUN_TEST"/>
> > > >         </waitfor>
> > > >         <antCall name="cactus:tomcat-4x-stop"/>
> > > >       </sequential>
> > > >     </parallel>
> > > >
> > > > Of course, replacing <antCall> by <attainGoal> will not work
(I
> > think
> > > > Jelly will execute before Ant, right?).
> > >
> > > If you kept the above as using Ant tasks then it would work fine in
> > Jelly.
> >
> > I tried the following (in a Maven plugin.jelly script):
> >
> > <goal name="cactus:tomcat-4x-run">
> >   <antcall target="testxxx"/>
> > </goal>
> >
> > <target name="testxxx">
> >   <echo>xxxx</echo>
> > </target>
> >
> > However, I get the following error:
> >
> > [ERROR] BUILD FAILED
> > [ERROR] File......
> >
> E:\Vma\Projets\Encours\ICOM\Icom\environment\tools\maven\plugins\maven-c
> > actus-plugin-1.0\plugin.jelly
> > [ERROR] Element... antcall
> > [ERROR] Line...... 33
> > [ERROR] Column.... 34
> > [ERROR] java.io.FileNotFoundException:
> > E:\Vma\Projets\Encours\junitbook\junitbook\chapter09\build.xml (The
> > system cannot find the file specified)
> >
> >
> > > However mixing Maven's <attainGoal> with the Ant tasks probably
> won't
> > > work.
> > >
> > >
> > > > I imagined using the jelly <core:thread> tag. However, I have to
> > specify
> > > > either an org.apache.commons.jelly.XMLOutput object or a file
> > attribute.
> > > >
> > > > I would like to have the output be printed in the console (same as
> > the
> > > > other Jelly outputs). How can I do that?
> > >
> > >
> > > I've just patched the thread tag to just default to System.out if no
> > > xmlOutput or File is specified.
> > >
> >
> > ok. Cool. Thanks.
> >
> > I've tried it with:
> >
> > <j:thread>
> >   <attainGoal name="cactus:tomcat-4x-start"/>
> > </j:thread>
> > <echo>XXXXXXXXXX</echo>
> >
> > but it fails with:
> >
> > [ERROR] org.apache.commons.jelly.JellyException:
> > java.lang.NullPointerException File: file:/E:/Vma/
> >
> rojets/Encours/ICOM/Icom/environment/tools/maven/plugins/maven-cactus-pl
> > ugin-1.0/scripts/tomcat.4x.jelly At tag <attainGoal>: line: 50 column:
> > 46
> > [ERROR]         at
> >
> org.apache.commons.jelly.impl.TagScript.handleException(TagScript.java:5
> > 12)
> > [ERROR]         at
> > org.apache.commons.jelly.impl.TagScript.run(TagScript.java:274)
> > [ERROR]         at
> > org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:134)
> >     [echo] XXXXXXXXXX
> >     [echo] [ERROR]      at
> > org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:190)
> >     [echo] [ERROR]      at
> > org.apache.commons.jelly.tags.core.ThreadTag$1.run(ThreadTag.java:93)
> >     [echo] [ERROR]      at java.lang.Thread.run(Thread.java:479)
> >
> > Any idea? Can I refer to objects in the main jelly context form within
> > the <thread> tag?
> >
> > >
> > > > BTW, is that the correct approach (to use the jelly <thread> tag)?
> > >
> > > Sure. The missing part that you need is synchronizing things again.
> > > There's
> > > no <waitfor> in Jelly, though you should be able to reuse the
> existing
> > Ant
> > > tasks for this if you like.
> >
> > Yes, that's what I imagine doing.
> >
> > >
> > > There are efforts ongoing to build a BPEL4WS engine using Jelly. One
> > of
> > > the
> > > key features of this is to support parallel execution of 'actions'
> and
> > > then
> > > coordinate them as they complete, either synchronously (via blocking
> a
> > > thread) or asynchronously (via receiving some kind of message and
> > > correlating things together). So there will be better support for
> this
> > > kind
> > > of thing in Jelly soon.
> >
> > Cool.
> >
> > >
> > > Until then using just the Ant tasks seems the easiest approach;
> maybe
> > we
> > > just need a way of making things like <attainGoal> act like an Ant
> > task
> > > when
> > > used with <parallel> and <sequential> in a Jelly script?
> >
> > Maybe ... but I don't know enough to know if it's a good idea or not
> ...
> > :-)
> >
> > Thanks James,
> > -Vincent
> >
> > >
> > > James
> > > -------
> > > http://radio.weblogs.com/0112098/
> > >
> > > __________________________________________________
> > >
> > > Do You Yahoo!?
> > >
> > > Everything you'll ever need on one web page
> > >
> > > from News and Sport to Email and Music Charts
> > >
> > > http://uk.my.yahoo.com
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:   <mailto:commons-dev-
> > > unsubscribe@jakarta.apache.org>
> > > For additional commands, e-mail: <mailto:commons-dev-
> > > help@jakarta.apache.org>
> >
> >
> >
> > --
> > To unsubscribe, e-mail:   <mailto:commons-dev-
> > unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail: <mailto:commons-dev-
> > help@jakarta.apache.org>
>
>
>
> --
> To unsubscribe, e-mail:
<mailto:commons-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:commons-dev-help@jakarta.apache.org>
>

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message