Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails resources: Image is 404 even though it exists in the WAR

I've got 3 Grails 2.x projects. For this example they are:

ProjectCore    - A Grails plugin containing all reusable code (domains, taglibs, etc)
ProjectWeb     - Front facing web application.  Uses ProjectCore
ProjectAdmin   - Admin appliction.  Uses ProjectCore

Nearly all of the images, js, taglibs, services, etc are in ProjectCore, with only app specific controllers/views/services/js/css in the individual projects.

Everything runs fine locally, using NetBeans as my IDE. I War'd up the ProjectAdmin project, and deployed it to my Ubuntu server running Tomcat 6. Everything in the application is working as expected, except 1 image: avatar.png (which is contained in the ProjectCore app).

I'm using the g:resource tag to create all of the image links, and they are all resolving properly to the /static/images/some_image_name.png url's correctly, except this one image. I've also verified that the image is present within the war (located at plugins/ProjectCore/images where all of the other images are).

For this particular image, I'm using a taglib (AvatarTagLib) to create the link to this image if the user has not uploaded an avatar for themselves. This Taglib is in ProjectRoot, but is being called from the other projects. I believe the other images are being called from views within the specific projects, so that might be where the hangup is.

Initially when I had deployed the application, I had forgot to change the ownership of the war (and containing directory) to tomcat6:tomcat6, so I was having issues with not only this image, but the messages.properties file from SpringSecurityPlugin. I wiped all of it out, fixed the permissions, and that resolved all of the issues except this one.

Has anyone come across this behavior before, or know any other paths I can go down to sort this out?

Edit: One thing I forgot to mention. When I try to access the image directly, either via http://admin.mydomain.com/images/avatar.png or http://admin.mydomain.com/static/images/avatar.png, both return 404. However, I can access other images this way.

Edit 2: This isn't limited to a single image. It's affecting roughly half of the images that are in the plugin.

like image 390
aasukisuki Avatar asked Jul 31 '12 16:07

aasukisuki


2 Answers

Upgrading the resources plugin fixed this issue for me. I updated BuildConfig.groovy with runtime ":resources:1.2.RC2"

like image 192
kmuser Avatar answered Sep 21 '22 16:09

kmuser


Try to upgrade the resources plugin to 1.2-RC1.

I had a very similar issue, 3 of my png's would return 404 errors on direct access under both /images and /static/images. The images were named dot.png, calendar.png and dotted_vertical.png. If I renamed them (e.g. dotted_vertica.png or dotted_vertical1.png) they worked, but I couldn't find any other similarities or patterns. Weird indeed.

like image 26
andersaa Avatar answered Sep 24 '22 16:09

andersaa