commons-user 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] Re: Junit error in script used by j:include, reportsgeneric error
Date Fri, 04 Apr 2003 16:00:10 GMT

On Tuesday, April 1, 2003, at 05:35 PM, Bill Brown wrote:

> Hi James,
>     Thanks for getting back to me.  I am definitely specifying a 
> filename
> which, since it worked, seemed OK by me.
> ex:
>        <j:include uri="run.jelly"/>
>
> run.jelly is a jelly file in the current directory of the executing 
> script.

Actually the URI will be resolved using the current context URL in the 
JellyContext, which isn't the same as the current working directory. 
This is a little like web applications with servlet contexts; Jelly 
allows a similar model of URI's both absolute to some root context or 
relative to the current Jelly script.

It might be easier for you to just use files instead. I've just patched 
the <include> tag to allow a File to be specified.

<j:include file="..."/>

Though right now the type of the argument is of type File, so right now 
typing a String file name won't work. You'd have to do something 
verbose like...

<j:new var="aFile" class="java.io.File">
	<j:arg value="foo.jelly"/>
</j:new>
<j:include file="${aFile}"/>

I'm hoping a change to beanutils will fix this and allow simple things 
like..

<j:include file="foo.jelly"/>




> I am using jelly:junit, which I assume is the same thing as jellyunit.
>
> In order to get around my problem, I added the following truly ugly
> System.out.println line into IncludeTag.java within the doTag method.
> I have included enough context so that you can figure out where I added
> it.
>
>        catch (JellyException e) {
>             System.out.println(e.getMessage());  // Mighty ugly, but 
> it works
>             throw new JellyTagException("could not include jelly 
> script",e);
>         }
>
> With the addition of this line, the error in the included script is no 
> longer
> hidden.
> I am pretty sure that whatever code catches the include tag's 
> exception is
> not printing out any information from the "cause" exception, included 
> in the
> "could not include jelly script" exception.  The println does  print 
> out the
> real error.
>
> Can you suggest a better fix?

I've patched the code to be more descriptive on errors including the 
name of the resource being opened and the reason it failed.


> By the by, while I have your ear, I suspect that the "new" tag does not
> "return a value" in the same manner in which the "invoke" tag does.  
> This
> makes it difficult to embed the "new" tag within other tags like the  
> "arg"
> tag.  I will attempt to confirm this problem/issue.

It should be easy to make the new tag behave like invoke in this regard.


> Also, as another basic problem with the base tags, I have found no way
> to call a class method on an object.  I could have gotten around the
> problem I had with the "new" tag by using invoke tag to call the 
> initializer
> directly on the class.  But, this doesn't seem possible.


The invoke tag does this doesn't it?

Also you could just use expressions inside your Jelly script. e.g.

<j:set var="result" value="${someBean.someMethod(1234)}/>



> So, are these problems or do I not know what I am doing?  I produced
> a small tool that provided an XML syntax for running java code in a
> previous life.  The ability to call class methods was really handy.
>
> Thanks very much for you time James.

No problem. Sorry it took me a while to get to this; have been on 
holiday, have switched laptops (to a Mac!) and am playing email catch 
up right now...

James
-------
http://radio.weblogs.com/0112098/


Mime
View raw message