# Routing issue with jruby-rack/app engine

**URL:** <https://www.ruby-forum.com/t/routing-issue-with-jruby-rack-app-engine/170798>\
**Category:** JRuby\
**Created:** [June 22, 2009, 11:59pm UTC](https://www.ruby-forum.com/t/routing-issue-with-jruby-rack-app-engine/170798 "2009-06-22T23:59:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Charles\_Falconer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c67d28/32.png) [@Charles\_Falconer](https://www.ruby-forum.com/u/Charles_Falconer)\
**Post date:** [June 22, 2009, 11:59pm UTC](https://www.ruby-forum.com/t/routing-issue-with-jruby-rack-app-engine/170798/1 "2009-06-22T23:59:27Z")

</div>

I’ve been using Nick S.'s jruby-rack rails sample for App Engine

> <https://github.com/nicksieger/jruby-rack/tree/8b5c5f1bca6e1bc072c205b476c655b5f693ba85/examples/rails>
>
> //github.com/nicksieger/jruby-rack/tree/8b5c5f1bca6e1bc072c205b476c655b5f693ba85/examples/rails

Everything has worked well except for a routing issue I’m having,  
despite  
using a rudimentary routes.rb file:

No route matches “/stylesheets/scaffold.css”

I tried adding the public/stylesheets folder as a resource in  
appengine-web.xml.

I also tried to kludge it by making a copy of the public/stylesheets  
folder  
and putting it under WEB-INF.

Maybe it’s premature to question whether jruby-rack is rewriting the url  
correctly but I’m running out of ideas.

My last resort is another kludge - serve static files using a custom  
controller in Rails by modifing Nick’s “AssetsController” which reads  
files  
off the file system and serves them for the app:

class AssetsController \< ApplicationController  
def show  
image\_name, image\_type = params[:id], params[:format]  
filename = PUBLIC\_ROOT + “/images/#{image\_name}.#{image\_type}”  
if File.file?(filename)  
image\_data = File.read filename  
response.headers[‘Content-Description’] = “This is  
#{image\_name}.#{image\_type}”  
response.headers[‘Last-Modified’] = File.mtime(filename).rfc822  
send\_data image\_data, :type =\> “image/#{image\_type}”, :disposition  
=\>  
‘inline’  
else  
render :text =\> “

# Not Found
”, :status =\> :not\_found  
end  
end  
end

Tell me there’s a better way!

---

<div class="post-metadata">

**Author:** ![Charles\_Falconer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c67d28/32.png) [@Charles\_Falconer](https://www.ruby-forum.com/u/Charles_Falconer)\
**Post date:** [June 23, 2009, 12:34am UTC](https://www.ruby-forum.com/t/routing-issue-with-jruby-rack-app-engine/170798/2 "2009-06-23T00:34:33Z")

</div>

Hi Charles,  
I would try to setup the style sheets as static files.

```
<static-files>
    <include path="/images/ **.**" />
    <include path="/stylesheets/**.css" />
    <include path="/favicon.ico"/>
</static-files>

```

I had the same problem where I would get a routing error. Setting the  
files  
to static fixed it for me

Josh

[http://www.codingforrent.com](http://www.codingforrent.com)

On Tue, Jun 23, 2009 at 5:58 AM, Charles Falconer  
\<removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![Charles\_Falconer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c67d28/32.png) [@Charles\_Falconer](https://www.ruby-forum.com/u/Charles_Falconer)\
**Post date:** [June 23, 2009, 2:13am UTC](https://www.ruby-forum.com/t/routing-issue-with-jruby-rack-app-engine/170798/3 "2009-06-23T02:13:59Z")

</div>

Hi Josh,

Thanks for the suggestion. I tried it out with several variations but  
couldn’t get this format to work without a routing error. Afterwards I  
looked at your App Engine template and noticed you are using symbolic  
links

- could it be that your ‘/stylesheets’ folder is actually in a different  
physical location from my ‘war/WEB-INF/public/stylesheets’ folder and  
that’s  
the reason these files are found in your app and not in mine?

Charles

---

<div class="post-metadata">

**Author:** ![Charles\_Falconer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c67d28/32.png) [@Charles\_Falconer](https://www.ruby-forum.com/u/Charles_Falconer)\
**Post date:** [June 23, 2009, 4:42am UTC](https://www.ruby-forum.com/t/routing-issue-with-jruby-rack-app-engine/170798/4 "2009-06-23T04:42:00Z")

</div>

On Mon, Jun 22, 2009 at 7:13 PM, Charles Falconer  
\<[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> wrote:

> Hi Josh,
> 
> Thanks for the suggestion. I tried it out with several variations but  
> couldn’t get this format to work without a routing error. Afterwards I  
> looked at your App Engine template and noticed you are using symbolic links
> 
> - could it be that your ‘/stylesheets’ folder is actually in a different  
> physical location from my ‘war/WEB-INF/public/stylesheets’ folder and that’s  
> the reason these files are found in your app and not in mine?
> 
> Charles

Try putting your images and stylesheets in war/stylesheets and  
war/images,  
etc. GAE won’t serve up any static files from WEB-INF, it’s a protected  
directory.

This is the exact reason why warbler takes care of this step for you to  
rearrange public files in the root of the war were GAE and other java  
application servers expect them.

Cheers,  
/Nick

---

<div class="post-metadata">

**Author:** ![Charles\_Falconer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c67d28/32.png) [@Charles\_Falconer](https://www.ruby-forum.com/u/Charles_Falconer)\
**Post date:** [June 23, 2009, 5:34am UTC](https://www.ruby-forum.com/t/routing-issue-with-jruby-rack-app-engine/170798/5 "2009-06-23T05:34:01Z")

</div>

Nick,

That worked. Thanks very much.

There’s only one minor issue now where it reports on the console:

\*WARNING: No file found for: /snoop.html  
\*  
when I navigate to

[http://localhost:8080/snoop](http://localhost:8080/snoop) [http://localhost:8080/questions](http://localhost:8080/questions)

But oddly the snoop view is displayed otherwise without a problem.

Since this warning doesn’t seem to correspond to any problem with the  
functioning of the app, I’m not going to worry about it.

Thanks!

Charles
