how to access grails application on Tomcat - grails

I'm trying to deploy a simple grails application on my test-server which is tomcat. I've built the WAR with grails war command so I've got a war file named: simplgrailsapp-0.1.war
When I deploy this to tomcat I'm getting a lot of errors which I'm going to resolve one-by-one. But the URL for the app from tomcat manager (mytestserver:8080/manager) is http://mytestserver:8080/simplegrailsapp-0.1/ which doesn't seem correct. Because when I run the app locally the url is: localhost:8080/simplegrailsapp
I've also tried to access the app by http://mytestserver:8080/simplegrailsapp but that doesn't work either.
How can I fix this?

By default, when you deploy a WAR to tomcat it will fall under the context of the name of the WAR file. So in your case, the context becomes simplegrailsapp-0.1. You can:
rename your war file to whatever you want the context to be before you deploy it
define a Context for the application in Tomcat
If you go with defining a context this can be added to the WAR file by creating a META-INF folder in the web-app folder of your project and creating the context.xml file there.

Related

Grails .slcache is not getting recreated on a new build

I'm running a Grails build. For some reason, the .war file created sometimes does not get the appropriate .jar files loaded into the WEB-INF/lib folder. A subsequent Tomcat deployment fails. A co-worker that encountered this issue said to get rid of the .slcache in the user home folder on my windows server. I deleted the folder under c:/Users/myuser/.grails/.slcache. I re-ran a build and the .slcache is not getting recreated and I am still missing the .jar files.
Any idea what is happening and how to resolve?
Did you try changing the spark plugs (or at a minimum cleaning and re-gapping them) in your car? That'll be about as helpful.
The .slcache directory is created by spring-loaded, which Grails uses for class reloading when running the app with grails run-app. It has absolutely nothing to do with creating war files.

Can't access JasperReports after deploying Grails WAR to AWS Elastic Beanstalk

I have a Grails 2.4 application that uses JasperReports to produce PDF vouchers. I have everything working fine I run as dev environment on localhost.
I want to deploy to AWS on an Elastic Beanstalk instance but once I have uploaded the WAR and deployed it, everything works fine apart from JasperReport creation. When I click on the PDF icon if waits for some time and then give the error "An error has occurred" and no report is downloaded.
I have researched and found that the web-app/reports directory (this is where my jasper report files are) is not by default included in WAR creation so I have included the following in my BuildConfig.groovy and now the WAR contains the jasper report files correctly.
grails.war.copyToWebApp = { args ->
fileset(dir:"web-app") {
include(name: "js/**")
include(name: "css/**")
include(name: "WEB-INF/**")
include(name: "reports/**")
include(name: "images/**")
}
}
After deploying again it still does not work and it seems that the app cannot access them.
Do I need to include any other files / directories in the WAR file I might be missing?
Is there a change in a config file I need to make to make this work - for example does deploying to a WAR change the directory structure in anyway that might effect a path in config file?
Just to add for clarity - I have compile ":jasper:1.11.0" in my BuildConfig.groovy already.
* UPDATE *
I couldnt find an actual solution to this on Elasticbeanstalk but I have fixed the problem for me by changing to use an EC2 instance of Ubuntu and installing apache, tomcat, java etc myself and deloying there and I know have it working no problems.

creating a config file in grails

I am attempting to get a Grails project working but need help setting it up. I have an Ubuntu server running on a VM that has Redis installed. The project won't run unless I create a config file that can use Redis on the Ubuntu server. This is the settings I pulled down from GitHub located in the grails-app/conf/Config.groovy file.
http://snag.gy/eYhUY.jpg
I was told I need to create a separate config file that will override these parameters so my project will talk to the ubuntu server on my machine. This is a noob question but where do I create a config file? I can't seem to find a .grails folder. I know I'm suppose to reference my config file, once i've created one, in the grails-app/conf/Config.groovy file
http://snag.gy/SpGGt.jpg
Look at the grails.config.locations specified in your Config.grooy and you can create any of those locations for creating the external Config file.
I prefer using the classpath route. Here is what I would do.
Create a folder (say appConfig) and place it in the tomcat/conf folder.
Add the application config file (proghorn-config.groovy in your case) to the folder, with the required configurations in the file.
Add the folder to the Tomcat classpath by updating either the tomcat/conf/catalina.properties or by creating the tomcat/bin/setenv.sh
The location of the .grails folder depends upon the user account running the container (Tomcat, Jetty, etc.) which hosts your Grails application.
For example on Debian 6 running Tomcat 6.x the location is:
/usr/share/tomcat6/.grails/
You can also use static paths as well:
file:/usr/local/tomcat/conf/myspecific-config.groovy

Grails war deployement on WSAS

I generate a war using grails war, but when I deploy it to Websphere I have errors, what features I need to add so I can run my war under WSAS, here are the errors → http://paste.ubuntu.com/6179593/
Note: The web page show me this error → Context Root Not Found
According log there is no problem and application has started successfully.
Check your Virtual Hosts settings.
There is good article about grails application deployment.

EJB calls from grails to glassfish

I need to use EJB remote calls from my grails application. For this in previouse Servlet application I used client glassfish jar(gf-client.jar) and is's worked.
How I can include gf-client.jar into build path in grails app for call EJB methodth?
thank you.
the answer was to copy all libraries of GlassFish application server to client mashine (directory with gf-client.jar and 2 levels up, check dependencies in gf-client.jar) and add only gf-client.jar to classpath of application. Ather dependencies will loaded automatically, when gf-client will loaded.
note 1: in my case for grails application witch I deploying to tomcat servlet container write full path to gf-client.jar to shared.loader section of catalina.properties file in conf dir, and restart tomcat.
note 2: for GlassFish v3.1 and up, replace gf-client.jar with gf-client-module.jar
Put gf-client.jar into the lib directory of your grails app. Any jar files in the lib directory of your grails app will automatically be included when you run your application as well as be packaged in generated war files.

Resources