You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Simon Stanlake <si...@tradebytes.com> on 2006/02/09 22:03:28 UTC

using resource:// protocol

Hi,
I'm having trouble using the 'resource://' protocol from my web-app.
 
I've got the default cocoon web-app installed (2.1.8) on tomcat 5.5.9. I
have a sub-directory called myApp containing my application like:

tomcat
  |
   ->webapps
     |
      ->cocoon
          |
           ->myApp

I have copied some stuff from the samples in order to get cforms to
work.

myApp/sitemap.xmap:

	<map:pipeline>
	     <map:match pattern="resources/*/**">
	       <map:read
src="resource://org/apache/cocoon/{1}/resources/{2}"/>
	     </map:match>
	</map:pipeline>

I then want to have stuff like CSS's in a resources folder. What I don't
understand is where to put the resources folder, and if I have to
configure something else (in web.xml?) to get it to work.

if I browse to http://localhost:8080/cocoon/myApp/resources/css/my.css I
get "Resource Not Found". I've tried putting the css under...

cocoon/resources/css
cocoon/WEB-INF/resources/css
cocoon/WEB-INF/css
cocoon/myApp/resources/css

all with no luck.

I've stepped through all the ResourceReader code down until it passes
off to the Tomcat WebappClassLoader, which returns null.

Thanks -
Simon Stanlake

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


Re: using resource:// protocol

Posted by Simone Gianni <s....@thebug.it>.
Hi Simon
the resource protocol gives access to the java resource system, that is 
files which reside inside the classpath, so or packed in a jar or in a 
"classes" directory.

In a web application context, this mean tou can put your files inside 
the WEB-INF/classes/ directory, so for example :

tomcat
  webapps
    cocoon
      WEB-INF
        classes
          myresources
             mystyle.css

can then be access with resource://myresources/mystyle.css

OR, you can put them inside a jar, with all their folders, for example :

# jar -tf resjar.jar
/myresources/mystyle.css

The you put the jar in WEB-INF/lib/ and you can access them same as above.

Mind that when accessing resources in a jar (and maybe also in the 
classes directory), you will have probably to restart the server, or 
reload the context or something similar to have them loaded correctly if 
you modify them, but this depends on your container. With the default 
jetty that comes with cocoon you have to reload it when you modify a jar.


Regards,
Simone

-- 
Simone Gianni

Simon Stanlake wrote:

>Hi,
>I'm having trouble using the 'resource://' protocol from my web-app.
> 
>I've got the default cocoon web-app installed (2.1.8) on tomcat 5.5.9. I
>have a sub-directory called myApp containing my application like:
>
>tomcat
>  |
>   ->webapps
>     |
>      ->cocoon
>          |
>           ->myApp
>
>I have copied some stuff from the samples in order to get cforms to
>work.
>
>myApp/sitemap.xmap:
>
>	<map:pipeline>
>	     <map:match pattern="resources/*/**">
>	       <map:read
>src="resource://org/apache/cocoon/{1}/resources/{2}"/>
>	     </map:match>
>	</map:pipeline>
>
>I then want to have stuff like CSS's in a resources folder. What I don't
>understand is where to put the resources folder, and if I have to
>configure something else (in web.xml?) to get it to work.
>
>if I browse to http://localhost:8080/cocoon/myApp/resources/css/my.css I
>get "Resource Not Found". I've tried putting the css under...
>
>cocoon/resources/css
>cocoon/WEB-INF/resources/css
>cocoon/WEB-INF/css
>cocoon/myApp/resources/css
>
>all with no luck.
>
>I've stepped through all the ResourceReader code down until it passes
>off to the Tomcat WebappClassLoader, which returns null.
>
>Thanks -
>Simon Stanlake
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>  
>



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


Re: using resource:// protocol

Posted by Andre Juffer <aj...@sun3.oulu.fi>.
Simon,

could it be that you have to put your css in the directory

org/apache/cocoon/{1}/resources/{2}

(with {1}, {2} replaced with the appropriate names)

I have not used resource protocol myself, but I think you have to put 
your CSS file in the classpath under org/apache/cocoon/... (e.g. in a 
jar file in the WEB-INF/lib directory).

Simon Stanlake wrote:
> Hi,
> I'm having trouble using the 'resource://' protocol from my web-app.
>  
> I've got the default cocoon web-app installed (2.1.8) on tomcat 5.5.9. I
> have a sub-directory called myApp containing my application like:
> 
> tomcat
>   |
>    ->webapps
>      |
>       ->cocoon
>           |
>            ->myApp
> 
> I have copied some stuff from the samples in order to get cforms to
> work.
> 
> myApp/sitemap.xmap:
> 
> 	<map:pipeline>
> 	     <map:match pattern="resources/*/**">
> 	       <map:read
> src="resource://org/apache/cocoon/{1}/resources/{2}"/>
> 	     </map:match>
> 	</map:pipeline>
> 
> I then want to have stuff like CSS's in a resources folder. What I don't
> understand is where to put the resources folder, and if I have to
> configure something else (in web.xml?) to get it to work.
> 
> if I browse to http://localhost:8080/cocoon/myApp/resources/css/my.css I
> get "Resource Not Found". I've tried putting the css under...
> 
> cocoon/resources/css
> cocoon/WEB-INF/resources/css
> cocoon/WEB-INF/css
> cocoon/myApp/resources/css
> 
> all with no luck.
> 
> I've stepped through all the ResourceReader code down until it passes
> off to the Tomcat WebappClassLoader, which returns null.
> 
> Thanks -
> Simon Stanlake
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 


-- 
Andre H. Juffer              | Phone: +358-8-553 1161
The Biocenter and            | Fax: +358-8-553-1141
     the Dep. of Biochemistry | Email: Andre.Juffer@oulu.fi
University of Oulu, Finland  | WWW: www.biochem.oulu.fi/Biocomputing/

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