cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anil <anilksha...@btinternet.com>
Subject Re: cocoon.context.getRealPath & cocoon 2.2
Date Tue, 15 Jan 2008 11:36:13 GMT

Hi -

Just to update this posting with my investigations - I've managed to extract
the file contents within my spring bean.

The basic problem was the way I was creating the file object - the path
returned by the cocoon.context.getRealPath() method was a URI & when
instantiating my File object I needed to create a URI object first.

Therefore it was:

URI fileURI = new URI("<output of cocoon.context.getRealPath>");
File file = new File(fileURI);

rather than just new File("<output of cocoon.context.getRealPath>");

Sorry - I should have noticed this - I assumed that I should be able to pass
the abstract path into File object directly - I blame it on the late nights!

One thing I still don't really understand though is that I'm still unable to
get a path to the resource that I want to access through my spring bean as
cocoon.context.getRealPath("xqy/test.xqy") still returns null. In order to
get round this I do:

var fullPath = cocoon.context.getRealPath("/") + "xqy/test.xqy";

If anyone could clear up that confusion I'd be very grateful.

Many thanks,
Anil.


anil wrote:
> 
> Hi -
> 
> I was wondering if someone could clear up some confusion for me & point me
> in the right direction.
> 
> I'm trying to get the full path location of a file from within flowscript
> as I need to pass the file location to a spring bean.
> 
> In cocoon 2.1 I have seen the cocoon.context.getRealPath("<relative path
> from sitemap>") return the correct value, but this doesn't seem to work in
> cocoon 2.2 with the new block structure.
> 
> I can do:
> 
> cocoon.context.getRealPath("/")
> 
> and get the correct path back from the context - i.e.:
> 
> file:///C:/Workspace/cmc-rmm-webapp/target/work/blocks/rmm-xforms//
> 
> but if I try:
> 
> cocoon.context.getRealPath("/xqy/test.xqy")
> 
> I get no output at all.
> 
> Why is this?
> 
> To try and get around this problem when passing the file location to my
> spring bean I simply tried:
> 
> cocoon.context.getRealPath("/xqy/test.xqy") + "/xqy/test.xqy"
> 
> but when I instantiate the file object at that location I get a
> FileNotFoundException:
> 
> java.io.FileNotFoundException:
> file:\C:\Workspace\cmc-rmm-webapp\target\work\blocks\rmm-xforms\xqy\retrieveChapterList.xqy
> (The filename, directory name, or volume label syntax is incorrect)
> 
> Is this something to do with permissions or something?
> 
> Also, if there are any other approaches I could take to try and pass a
> file location into a spring bean I'd be very interested in hearing it.
> 
> Any help would be very much appreciated.
> 
> Many thanks,
> Anil.
> 

-- 
View this message in context: http://www.nabble.com/cocoon.context.getRealPath---cocoon-2.2-tp14818755p14837955.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.


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


Mime
View raw message