Grails resources plugin and cloudfoundry - grails

I tried to deploy my app to cloudfoundry, everything goes smooth however none of my static resources that use the resources plugin can be found.
In the logs i get lots of errors like the below
2012-01-31 13:36:41,352 [http-46220-3] WARN util.ResourceMetaStore -
Cannot locate resource [/static/css/jquery-ui-1.8.17.custom.css]
I first thought that this is due to cloudfoundry not having any disk space allocated but based on this thread it should work out of the box
http://grails.1312388.n4.nabble.com/Cloud-foundry-and-resources-plugin-with-js-css-td4243619.html
The test application i am running is running on one instance and i am using version 1.1.6 of the resources plugin.
Anybody else experiencing similar problems?

Make sure you are not missing the following line in your Config.groovy
grails.resources.adhoc.patterns = ['/images/*', '/css/*', '/js/*', '/plugins/*']

I had the similar problem on heroku platform. It seems that problem is related with resources plugin and load balancing. My be the following will be useful:
Heroku, Grails: Missing resources if using multiple web dynos

Can you confirm 100% that this works in "production" environment locally?

I have a Grails 2.0 application on Cloud Foundry (http://tripplanner-ali.cloudfoundry.com/trip/create). It is using the resources plugin (1.1.5) along with cloud-support and cloud-foundry and jquery of course. I would suggest you to have your STS setup with Grails 2.0 if you haven't done so and try to create a sample application and deploy it to CF. Here is where you can get STS with Grails 2.0 working (http://static.springsource.org/sts/docs/2.7.0/reference/html/grails/grails20.html).
Once you have this setup, All you have to do is create a new Grails project and you will get the resources plugin along with jquery by default.

Related

"Another unnamed CacheManager already exists in the same VM"-error when deploying Grails 3.1.4 app to Elastic Beanstalk

Ever since about a week ago after doing a prod dbm-update I started getting this error when deploying the WAR-file to EB (run-app works fine both in dev and prod setting):
Caused by: org.hibernate.cache.CacheException: net.sf.ehcache.CacheException: Another unnamed CacheManager already exists in the same VM. Please provide unique names for each CacheManager in the config or do one of following: 1. Use one of the CacheManager.create() static factory methods to reuse same CacheManager with same name or create one if necessary 2. Shutdown the earlier cacheManager before creating new one with same name.
Grails 2.5.0 release notes suggested setting beans.cacheManager.shared to true. Didn't help.
Other people facing similar issues suggested replacing Hibernate cache factory_class from org.hibernate.cache.ehcache.EhCacheRegionFactory to org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory - this post. I think it eliminated the unnamed cacheManager issue, but created another one:
Caused by: java.io.FileNotFoundException: class path resource [db/changelog/db.changelog-master.yaml] cannot be resolved to URL because it does not exist
Setting "liquibase.checkChangeLogLocation = false" and "liquibase.enabled = false" triggers yet another:
Caused by: org.grails.core.exceptions.GrailsConfigurationException: Error configuring dynamic methods for plugin [springSecurityCore:3.0.4]: null
I'm using: Grails 3.1.4 with the AngularJS profile, Spring Security 3.0.4, Spring Security Rest 2.0.0.M2, Database Migration 2.0.0.RC4
I've also tried:
switching to Spring Security 3.0.2, 3.0.3
termimating the EC2 instance
re-building the entire EB environment and creating a new database
setting hibernate use_second_level_cache to false
downgrading to Grails 3.1.0
setting sourceSets { main { resources { srcDir 'grails-app/migrations'}}}
I'm running out of ideas and nothing has helped so far. Does anyone have an idea? Or is facing similar problems?
Did you recently upgrade to Hibernate 5.1.0.Final ? If so, then you might have the same issue as this one. No solution seems to have been found, but you might want to downgrade to Hibernate 5.0.9.Final to avoid this issue for now.
It turned out to be an issue with the Grails 3 AWS SDK plugin. I reverted all my changes and just replaced the plugin with the AWS SDK for Java through Gradle.
You can see from the plugin page that it supports Grails up to 3.1.1, but downgrading from 3.1.4 to 3.1.1 didn't make any difference either. But yes, using AWS SDK without the plugin worked. Woo!
I used Spring Security Core plugin v3.0.4 and got this error too on Grails v3.1.4. Upgrading the SSC pluign to v3.1.1. fixed the issue for me.

Grails 2.5.0 endpoints located sans application context

I am upgrading an existing Grails 2.2.4 app to 2.5.0.
For some reason, endpoints whose URLs included the app context in 2.2.4 no longer include the app context in 2.5.0.
e.g., for app context = app, old endpoint in 2.2.4 was:
/app/a/b/c
but in 2.5.0 is now:
/a/b/c
I have tried many things to fix this, including:
in application.properties:
app.name=app
app.context=/app
in Config.groovy, for testing on localhost:8080:
grails.app.context = "/${appName}"
grails.serverURL = http://localhost:8080 and grails.serverURL = http://localhost:8080/${appName}, at different times
app.grails.serverURL = http://localhost:8080 and app.grails.serverURL = http://localhost:8080/${appName}, at different times
I've verified that "${appName}" == 'app'.
I have upgraded all of the plugins to the newest version, but I'm continuing to use the resources plugin instead of the asset-pipeline plugin.
I am not using scaffolding.
Any suggestions?
UrlMappings.groovy contained some mappings with (parseRequest:true), which is no longer supported by Grails. Removing that fixed it.

Rails application issue after deployment - 404 error

I'm new to RoR.
I was able to install Rails and host it in Webrick (Sample App with "Welcome" controller) in my windows.
Now i have a Unix Weblogic Server along with a dedicated domian.
After exporting the .WAR file using Warbler, i accessed the Oracle Admin Console from where i deployed the .WAR file in the dedicated domain. I did all this for the Sample app with only the Welcome controller in it.
But even after deploying the WAR file, on accessing the Domain along with the Port Number (:9002) i ended up with 404 file not found error On looking at the server logs,there wasn't any records relating to any error. The Application must have been deployed properly. I assume that i must have missed out on some basic configurations in the routes.rb or similar files before deploying. Can anyone Guess what are all the possibilities and if possible can anyone help me by pointing to any tuts that cover the Steps to be carried out for configuration before deployment. do i need to install both JRuby and Rails inside the server before depolyment?
I can't really guess with Eror 404 only.
You can try mapping your rails app rack config to a different base_uri.
All you need to do is wrap the existing 'run' command in a map block
try doing this in your rails 'config.ru' file:
map '/mydepartment' do
run Myapp::Application
end
Now when you 'rails server' the app should be at localhost:3000/mydepartment .
Not sure if this will give you the desired outcome, but worth a try.
One more thing you also add this to your config/environments/production.rb and config/environments/development.rb (if on production mode):
config.action_controller.asset_path = proc { |path| "/abc#{path}" }
otherwise when you call your helpers such as stylesheet_link_tag in your views, they will generate links without the "/abc".
Also, find some guides you may refer for good support.
JRubyOnRailsOnBEAWeblogic.
Use JRuby with JMX for Oracle WebLogic Server 11g
Let me know if it is not resolved.

Running jRuby + Rails inside of Tomcat

I am currently using a platform where multiple web applications must interact with each other in a frameset. This set of web applications and the frameset is hosted on Tomcat.
Now the application we're working on is developed with jRuby and Rails. Is there anyway I can run my development environment inside of Tomcat similar to just running the jRuby -S Rails Server command so I can effectively debug?
The only way I've found is to generate a war using warble and then modifying the exploded war which seems really hacky. Any thoughts?
EDIT: I think my best bet is to generate a war, gut it, use symbolic links and figure out what gems / libs I need to copy from the war generation process. It's the best way I can think of.
one option to explore: deploy a little servlet to Tomcat which returns
HTTP/1.1 301 Moved Permanently
Location: http://localhost:3000
So far the best solution I have found is to setup a reverse proxy with Tomcat and point it to the Rails development server. This allows it to run, as expected on the client side, while still giving me debug control.
When I get a chance to do some more testing I'll edit my answer to include additional information.
go to the webapps folder in tomcat where you have deployed the war file, then find the web.xml file inside the expanded war file
The path to this file is generally /var/lib/tomcat7/webapps/your-project-here/WEB-INF/web.xml and inside this file you should find the
Changing this is one way to go about.
<context-param>
<param-name>rails.env</param-name>
<param-value>production</param-value>
</context-param>

Why are grails plugin assets not copied in the right place when packaging as a war?

I am using the Calendar Plaugin in my application and on local testing it works great. It loads its assets from
http://localhost:8080/YYYYYY/plugins/calendar-1.2.1/js/calendar.js
However, when deployed as a war the gsp file looks for the assets at
http://XXXX/YYYYYY/js/calendar.js (i.e. no /plugins/calendar-1.2.1/)
and fails. My question is why is the packaged file looking for the plugin assets in the root when deployed as a war when they are packaged into the plugins/calendar-1.2.1/ sub directory? If they are looked up in the root should some code be copying them that is not configured or working properly?
Resources plugin
Basically if you have the resources plugin installed and are using any of the <r:require and <r:layoutResources tags in your layouts and views you are using the framework.
The plugin handles resources such as css, javascript, images and their dependencies and I believe the plugin is installed by default in 2.0.1 so it might be worth looking into it as the missing link in your problem.

Resources