configuring the root url for a Heroku Grails app - grails

I'm using the Grails stack on Heroku to deploy an app. I'd like to be able to serve my app with a root of myapp.herokuapp.com/xyz as opposed to myapp.herokuapp.com, in the same way I'm able to serve from root of localhost:8080/xyz in development. I've tried adding a grails.app.context in Config.groovy like so:
environments {
production {
grails.app.context = "/xyz"
}
}
But it doesn't seem to have an effect in deployment. Do I have to configure something with Heroku? Any ideas?

It looks like you have to add a jetty-web.xml file to the WEB-INF directory to set the context path:
<?xml version="1.0" encoding="UTF-8"?>
<!-- File: web-app/WEB-INF/jetty-web.xml -->
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
<Set name="contextPath">/xyz</Set>
</Configure>
If this helps proper credit goes to this site, which was linked from an article on Grails and Heroku by Tomas Lin.

I don't think you can set context path with the current Grails build pack. If you feel like it, you can fork the build pack and hack it to support setting context (see build pack doc for more info on build packs).
Another option is to build your Grails app locally into a WAR file and deploy the WAR file using WAR deployment. The WAR deployment process will use the webapp-runner utility to run your app with Tomcat and it supports configuring the context path. Here's the help output for webapp-runner 7.0.22.3 (what I happened to have installed, might be slightly out of date):
Tomcat Runner runs a Java web application that is represented as an exploded war in a Tomcat container
Usage: java -jar tomcat-runner.jar [arguments...] path/to/webapp
Arguments:
--session-timeout The number of minutes of inactivity before a user's session is timed out
--port The port that the server will accept http requests on
--context_xml The parth to the context xml to use
--path context path (default is /)
--session_manager session store to use (valid options are 'memcache')
--session_manager_operation_timeoutoperation timeout for the memcached session manager. (default is 5000ms)
--session_manager_locking_modeSession locking mode for use with memcache session store. (default is all)
--session_manager_ignore_patternRequest pattern to not track sessions for. Valid only with memcache session store. (default is '.*\.(png|gif|jpg|css|js)$'
As explained in the WAR deploy doc, you can set webapp-runner options for your webapp using the WEBAPP_RUNNER_OPTS config var.

Related

MSDeploy Not Updating Correct Path at Destination

I'm trying to configure a build and release pipeline in VSTS so that I can push a build to a variety of environments. To accomplish this, I'm leveraging the parameters.xml file for MSDeploy, as well as using a Tokenizer task to overwrite the tokens that are set in the SetParameters.xml file after.
When I deploy to the site, it does reach the destination computer and deploy there, but the path is incorrect. Instead of copying to the virtual directory of the web application that I've specified in parameters.xml, it seems to take the path that is in the package and copies that (so, C:\agent_work...).
I know that the tokenizer and at least part of parameters.xml and SetParameters.xml is working and correctly transforming connection strings, as the generated web.config does have those values correct, but the IIS Web Application Name parameter doesn't seem to be working.
I did get this to work if I create my own publish profile and hard code the site name in the DeployIisAppPath and use that to package instead. This isn't ideal, though, as I want to have the site name as a parameter.
Here are all relevant files. Let me know if you need more info. Thanks so much in advance!
parameters.xml
<parameters>
<parameter name="IIS Web Application Name"
description="Please specify the IIS Web Application Name"
defaultValue="__IISWebApplicationName__">
<parameterentry kind="ProviderPath"
scope="IisApp"
match="#defaultValue">
</parameterentry>
</parameter>
</parameters>
VS Solution Build Task Arguments
/p:PackageAsSingleFile=true
/p:SkipInvalidConfigurations=true
/p:PackageLocation=$(build.artifactstagingdirectory)
/p:AllowUntrustedCertificate=true
/p:IncludeSetAclProviderOnDestination=False
/p:DeployOnBuild=true
/p:AllowUntrustedCertificate=true
/p:WebPublishMethod=Package
/p:SkipInvalidConfigurations=true
/p:DisableAllVSGeneratedMSDeployParameter=true
SetParameters.xml after packaging
<?xml version="1.0" encoding="utf-8"?>
<parameters>
<setParameter name="IIS Web Application Name" value="__IISWebApplicationName__" />
</parameters>
Release Task Environment Variable Configuration
Name = IISWebApplicationName
Value = Site Name
MSDeploy Configuration
Destination Provider: auto
Destination Computer: https://{server}:8172/msdeploy.axd?site=$(IISWebApplicationName)
MSDeploy Commmand
msdeploy.exe -verb:sync -source:package='C:\agent\_work\r4\a\{buildName}\drop\{packageName}' -dest:auto,computerName='https://{server}:8172/msdeploy.axd?site=Site Name',userName='xxx',password='xxx',authType='basic',includeAcls='False' -allowUntrusted -setParamFile=C:\path\to\param\file -verbose
You can deploy web app to IIS by using IIS Web App Deploy task, then you just need to specify Website name with variable directly.
Configure Deployment group
Edit release definition
Add Run on deployment group
Add IIS Web App Deploy task and specify website name
On the other hand, the WinRM: IIS Web App Deployment task in IIS Web App Deployment Using WinRM extension works fine two (Do not need to configure deployment group.)

Grails 3 plugins configuration

New to Grails 3- starting to port.
Have tried placing config values in application.groovy and application.yml within plugin conf dir to no avail - trying to read values from within plugin service fails. Adding values to the main application's application.groovy works.
What is the secret here? Previously I could load specific conf files via config.locations simply by naming them which was nice and simple. I've seen some resolutions that include needing to setup env vars with paths to config files which I'd like to avoid. Then they set up file URIs for dev and classpath URIs for other envs that will be war packaged - don't really want to do any of this.
Do we no longer have the ability to place config within a plugin and have that automatically merged with the applications config?
The plugin may provide config settings in grails-app/conf/plugin.yml.

Keycloak Unknown authentication mechanism

I need help with using keycloak in an Errai app. I am getting an error about "unknown authentication method" for "KEYCLOAK" ? I have the keycloak-appliance running (on a different port though), and the Errai app has a with KEYCLOAK in the web.xml file inside WEB-INF
When I run the Errai app with mvn gwt:run, I get : RuntimeException caused by "Unknown authentication mechanism KEYCLOAK". I have no idea how to go around this issue .
Just wanted to add a little more detail to #cfsnyder's answer. In order for your application server to recognize a definition in the web.xml that looks like this:
<login-config>
<auth-method>KEYCLOAK</auth-method>
<realm-name>internal</realm-name>
</login-config>
you'll need to tell jboss (in this instance) how to interpret that particular auth method. At the time of my answer, this is in section 8.2 of the Keycloak docs.
First, download the keycloak adapter (remember, this is not the same as the Keycloak Server). Next, unzip the download in the wildfly home directory. With your application server running, just use the following command to install the Keycloak configuration into the appropriate files:
jboss-cli.sh -c --file=adapter-install.cli
When this script completes, your configuration file will have the new entry added to accommodate the KEYCLOAK entry in your web.xml. The script will add something like this to either a domain.xml or standalone.xml:
<security-domain name="keycloak">
<authentication>
<login-module code="org.keycloak.adapters.jboss.KeycloakLoginModule" flag="required"/>
</authentication>
</security-domain>
Once you have the Keycloak module files provided by the adapter + the security domain configuration to link the KEYCLOAK method to the appropriate LoginModule, you should be all set.
You will need to install and configure the Wildfly adapter in order for your Errai app to recognize the "KEYCLOAK" authentication method. See section 7.2 of the Keycloak documentation.
To add to #josh-cain's answer, you might also need following additions in your domain.xml or standalone.xml:
To <extensions></extensions>, add:
<extension module="org.keycloak.keycloak-adapter-subsystem"/>
To <profile></profile>, add:
<subsystem xmlns="urn:jboss:domain:keycloak:1.1"/>
The adapter installation cli scripts can fail for various reasons so you might need to add these entries manually.

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.

Highcharts Export Server Configuration Settings

Highcharts (Highcharts), just released an update to their offering with a bundled export server. This is to enable you to generate charts serverside and include them automatically in emails/pdfs/etc.
Their instructions on how to prepare this is: Github instructions
I'm running XAMPP on Mountain Lion. I have successfully built the war package and opened the demo page.
I am now preparing a war for the production environment (centOS 6). The production site is running the Yii framework.
What I do not understand, the variables that need to be configured:
app.properties = weburl
dev.properties = weburl
prod.properties = weburl
In a MVC framework environment (such as yii) what should these url's be?
2.After the war is created, the github tutorial says to upload this file. But, what other files are required? The entire exporting-server directory? If so, where on the server should these files be placed? Is the file location the url path that should be referenced in the weburl variables?
Greater clarification on how to setup/deploy the export server would be much appreciated.
The created .war file should be uploaded to an Java application server, such as Tomcat, Jboss, TC-server, Glassfish, etc.
It's not suitable to run in a PHP environment.

Resources