You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Peter Stavrinides <p....@albourne.com> on 2007/04/16 11:55:38 UTC

Trouble reading a file with relative paths

Hi Everyone,

In my application (Tap 4.1.1) I am trying to implement a parser to parse 
an xml file, which works well enough with an absolute path, but when I 
retrieve the file using a relative path Tapestry returns an empty 
java.io.ByteArrayInputStream. If the path is specified incorrectly an 
exception is thrown, so I am pretty confident that the path is okay.

This is what I tried:

@Asset("context:/XML/irmsitemap.xml")
 public abstract IAsset getNavigationMap();

InputStream stream = getNavigationMap().getResourceAsStream();

I also tried:
InputStream stream = 
getServletContext().getResourceAsStream("/XML/irmsitemap.xml");

My folder structure looks like this:

+context
    -CSS
       ...
   - XML
       irmsitemap.xml
    - WEB-INF
        classes
        lib      

    etc...

any ideas?
Thanks
Peter



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Trouble reading a file with relative paths

Posted by Jesse Kuhnert <jk...@gmail.com>.
Upgrade to 4.1.2 where asset path resolutions are more deterministic.

On 4/16/07, Peter Stavrinides <p....@albourne.com> wrote:
>
> Hi Everyone,
>
> In my application (Tap 4.1.1) I am trying to implement a parser to parse
> an xml file, which works well enough with an absolute path, but when I
> retrieve the file using a relative path Tapestry returns an empty
> java.io.ByteArrayInputStream. If the path is specified incorrectly an
> exception is thrown, so I am pretty confident that the path is okay.
>
> This is what I tried:
>
> @Asset("context:/XML/irmsitemap.xml")
> public abstract IAsset getNavigationMap();
>
> InputStream stream = getNavigationMap().getResourceAsStream();
>
> I also tried:
> InputStream stream =
> getServletContext().getResourceAsStream("/XML/irmsitemap.xml");
>
> My folder structure looks like this:
>
> +context
>     -CSS
>        ...
>    - XML
>        irmsitemap.xml
>     - WEB-INF
>         classes
>         lib
>
>     etc...
>
> any ideas?
> Thanks
> Peter
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com