Search code examples
grailsgrails-plugin

Accessing images from grails in-line plugin when deployed in a tomcat server


I have two grails applications and created an inline plugin named cmcore. I placed some images in cmcore/web-app/images so that both of my applications have access on the said images. Images are successfully accessed by both applications in development environment but whenever I build WAR files of my applications in test environment and deploy it in a tomcat server, the images in cmcore becomes not accessible resulting to a resource not found error.

I extracted the generated WAR file and found out that the images from my inline plugin are not present in the images directory of the extracted WAR file, instead I found it in plugins/cmcore-0.1/images.

I've already tried the code below to do the job but it still didn't work.

<img src="${resource(dir: 'images', file: 'logo.jpg')}" height="30" width="30">

How can the application access those images whenever packaged in a WAR file and deployed in a server?

Thanks in advance.


Solution

  • What you want is to get acces to images in 'plugin'? Try this:

    <img src="${resource(dir: 'images', file: 'logo.jpg', plugin: 'cmcore')}" height="30" width="30">