Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play! 2.3.1 - main.css 404 (public assets not routing?)

I just loaded the Play Java Seed from the UI to create a new app. I wrote some CSS code in public/stylesheets/main.css, and this is the only change I made to this project. After compiling and running the app, the Chrome console says

GET http://localhost:9000/assets/stylesheets/main.css 404 (Not Found)
GET http://localhost:9000/assets/javascripts/hello.js 404 (Not Found) 

I've read the Asset controller documentations here but cannot figure out where I'm going wrong.

In my main.scala.html file (unchanged from seed), I have:

<head>
    <title>@title</title>
    <link rel="stylesheet" media="screen" href="@routes.Assets.at("stylesheets/main.css")">
    <link rel="shortcut icon" type="image/png" href="@routes.Assets.at("images/favicon.png")">
    <script src="@routes.Assets.at("javascripts/hello.js")" type="text/javascript"></script>
</head>

And in my routes file (also unchanged from seed):

# Map static resources from the /public folder to the /assets URL path
GET     /assets/*file               controllers.Assets.at(path="/public", file)

The favicon shows up in the tab, but when I go to http://localhost:9000/assets/images/favicon.png, the page is also not available, just like with main.css and the hello.js script.

like image 212
ypan Avatar asked Jul 08 '14 22:07

ypan


2 Answers

It also seems to happen (on play 2.3.8) when running from a packaged tarball created by:

$ activator universal:package-zip-tarball

, then..

$ [tarball-extract-path]/bin/[project-name]

On a local dev build the files download fine, but on remote test server I get 404 (Not found).

like image 143
Peter Nel Avatar answered Sep 19 '22 07:09

Peter Nel


For me the issue disappears when i start my project for production:

activator start

This is just a workaround but i hope it helps some of you guy's.

I suspect this is a bug in play and will hopefully be gone on a new play version.

like image 26
Ostkontentitan Avatar answered Sep 21 '22 07:09

Ostkontentitan