开发者

Grails - Plugin view pages issue

I have a plugin with domain, controller and view pages. (Using grails 1.3.6)

I run the plugin as standalone, the views work fine. URL: http://localhost:8080/sample-plugin/gp/list. I am able to view the list page.

I installed the plugin into a main application i.e. plugin-test. Start as run-app within STS and开发者_高级运维 browse to http://localhost:8080/plugin-test/gp/list. I am able to view the list page.

I bundle the application as war i.e. plugin-test.war and deploy to tomcat. When I browse to http://localhost:8181/plugin-test/gp/list I get a 404 error! I am not sure what I am doing wrong.

I have been trying to resolve it for quite sometime now and still no luck. The same main application works fine in STS but not in tomcat.

HTTP Status 404 - /plugin-test/WEB-INF/grails-app/views/gp/list.jsp

type Status report

message /plugin-test/WEB-INF/grails-app/views/gp/list.jsp

description The requested resource (/plugin-test/WEB-INF/grails-app/views/gp/list.jsp) is not available.

Please help.

Thank you.

Jay Chandran.


This sounds worryingly familiar, as I spent a while figuring out this (or a very similar) issue. I ended up raising this Grails bug report:

Plugin layout not found in war when installed from BuildConfig.groovy

Have you installed the plugin as using the new BuidConfig dependency technique? The JIRA documents my workaround.


Sharing some of my lessons learned after experiencing the same exact issue (1.3.7):

  • Double check your HTML source to make sure that your template really isn't being included. Mine was being included, but my CSS/image URLs were wrong (only while running as a war)...so I wrongly assumed that my template wasn't there.
  • Don't use the ui performance tags for referencing your static content...doesn't appear to work, even if the plugin attribute is specified.
  • Don't name your layout main.gsp. You're guaranteed to have conflicts.
  • Don't use absolute=true on your g:resource tags. This doesn't appear to append the pluginContextPath to the absolute url, even if you specify dir="${pluginContextPath}"
  • Don't use pluginContextPath, as it's no longer required: http://grails.org/doc/latest/guide/single.html#6.3%20Tag%20Libraries (search "Plugin Paths")
  • In your g:resource tags in your plugin layout, make sure you specify the plugin attribute. Set it to the name of your plugin.
  • Move your static images/css from your plugin to a web server. If each application using your plugin has its own copy, your users aren't going to benefit from caching when bouncing between apps.

Note that all of the above applies to the layout gsp in your plugin project, not your consuming application.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜