I'm writing a Grails plugin for internal Grails apps to use. I need the plugin to install a truststore (and inside of it, an added SSL cert) and make it available to whatever Grails app includes it as a compile-time plugin.
Hence, if my truststore is called cacerts.jks, and the name of the SSL cert stored therein is called myssl.cer, when the user adds the following to their Grails app's BuildConfig.groovy:
plugins {
compile ":myplugin:VERSION"
}
...then the Grails app will trust the myssl.cer that is stored in its JKS.
Any ideas as to how to accomplish this?
Related
I am trying to build an automatic deploy system for Magnolia 5.4 EE. For this, I exported the license config node /config/modules/enterprise/license to a file config.modules.enterprise.license.xml and attached this to the mgnl-bootstrap/my-module-directory of my module.
In this bootstrap-directory, other xml configuration files are present and are entered as expected into the configuration database. However, after deploy Magnolia still asks me to enter the license key - everything else works fine, my product is deployed, etc.
I tried to find information in the Magnolia documentation, but to no avail. Anyone here who was able to automatically deploy a Magnolia EE?
It should work if you add a dependency to enterprise magnolia module in your my-module descriptor file. This way the enterprise module will be installed before your module, and you just add a new node to its config.
Another option is to add the license import file to WEB-INF/bootstrap/common, the difference here is that everything in that folder gets bootstrapped after all modules are started.
So, I have founded a blog showing that in order to configure transport-guarantee confidential in a grails application I have to first install template executing:
grails install-templates
Really? It does not exist a configuration that I can do on grails classes and/or config files to accomplish that? This command install a lot more files than I need...
The blog url:
http://www.intelligrape.com/blog/2012/06/29/how-to-configure-ssl-on-tomcat-server-and-run-grailsjava-application-on-https/
Grails 2.3.7 and the cached resources plugin, at least with lesscss resources are not working properly.
The cached plugin returns an erro which is the same error as described in this thread:
<dt>Class</dt><dd>java.lang.NullPointerException</dd><dt>Message</dt><dd>Cannot invoke method cache() on null object</dd></dl><h2>Around line 31 of <span class="filename">grails-app/resourceMappers/org/grails/plugin/cachedresources/HashAndCacheResourceMapper.groovy</span></h2>
<pre class="snippet"><code class="line"><span class="lineNumber">28:</span> if (log.debugEnabled) {</code><code class="line"><span class="lineNumber">29:</span> log.debug "Setting caching headers on ${req.requestURI
http://grails.1312388.n4.nabble.com/Grails-resources-bug-Unable-to-load-resources-at-startup-td4652307.html
The problem is that cacheHeadersService is not injected or null in the cacheheaders plugin.
Trying to solve this I copied the contents of the cached-resources-plugin 1.1 from target/work/plugins to a local folder and added the following line:
grails.plugin.location.'cached-resources' = "../grailsplugins/cached-resources-1.1"
The intention was to fix this bug myself.
However, strangely enough, when the plugin is locally used the problem with injecting the cacheHeadersService is gone!
How can the plugin act differently when used locally versus when installed normally?
Perhaps it is a loader issue where now the cache-resources-plugin is loaded after whatever is declaring the service, but nonetheless worth reporting.
In the dependencies.groovy in the cache-resources plugin it declares the dependency:
compile ":cache-headers:1.0.4"
but obviosuly it is not loaded before the plugin unless loaded from local directory, strange!
I am also wondering, since the cache-resources plugin declares a dependency on tomcat :
build(":tomcat:$grailsVersion",
":release:2.0.3",
":rest-client-builder:1.0.2") {
export = false
}
is tomcat a requirement? Trying to change to Jetty in the main application the build process fails, saying that tomcat can not be found in the repository.
build ":jetty:2.0.3"// ":tomcat:7.0.52.1"
I just found these similar questions as well:
Cached-resources plugin is not working?
Grails Cache resources not working
Resource not found on grails appliction with cache plugins
I'm developing with Grails 2.1.1 and now I want to integrate Logback (http://logback.qos.ch) as the default logging framework as it should provide some better logging features and could be also configured via Groovy.
As Logback 1.0.7 (latest) does only work with slf4j 1.6.6 I want to upgrade the Grails dependeny. Grails 2.1.1 is using slf4j 1.6.2. How to do this properly?
I tried the following: in BuildConfig.groovy I exclude grails-plugin-log4j and slf4j-api
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
excludes "grails-plugin-log4j", "slf4j-api"
}
...
}
and I try to load slf4j-api 1.6.6 in compile build and runtime along with the other necessary libraries
grails.project.dependency.resolution = {
...
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
compile "org.slf4j:slf4j-api:1.6.6"
build "org.slf4j:slf4j-api:1.6.6",
"ch.qos.logback:logback-core:1.0.7",
"ch.qos.logback:logback-classic:1.0.7"
runtime "org.slf4j:slf4j-api:1.6.6",
"org.slf4j:log4j-over-slf4j:1.6.6", // logback dependency for classic module, as seen on http://logback.qos.ch/dependencies.html
"ch.qos.logback:logback-core:1.0.7",
"ch.qos.logback:logback-classic:1.0.7"
}
...
}
now, if I want to do anything from the Grails commandline, either grails compile or grails clean, it's complaining that it couldn't execute the script because it couldn't find the LoggerFactory class:
| Loading Grails 2.1.1
| Configuring classpath
| Error Error executing script Compile: org/slf4j/LoggerFactory (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:156)
at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:272)
at org.springframework.core.io.support.PathMatchingResourcePatternResolver.<clinit>(PathMatchingResourcePatternResolver.java:169)
| Error Error executing script Compile: org/slf4j/LoggerFactory
How can I upgrade the underlying slf4j-api properly?
If I don't exclude the slf4j-api first, I get a conflict with the "old" 1.6.2 api marked as evicted when calling grails dependency-report...
Also, I'd love to have an external config file for Logback. How would I implement it? With Log4j I just declared a log4jConfigurer bean within the conf/spring/resources.groovy file - how would it be done with Logback?
Has anybody experience in logging Grails 2.1.1 with Logback and could give me any advice for this issue?
As I think that this question would be also a matter of fact for other developers willing to implement the Logback Logging Framework with Grails, I'll share my progress on the topic within this answer - trying not to overload the initial question with progress information.
I still had no luck in updating slf4j within Grails, so I stuck
with the solution to simply overload the slf4j-api dependency.
Grails would show no error on grails dependency-report, just an
"eviction notice" on the older slf4j dependency (1.6.2). This seems
to work but I'll keep on searching for a better solution on this
topic.
I'm now able to load an external config file for Logback through
a ServletContextListener and a ConfigLoader class
implemented in grails-app/src/java, with the
ServletContextListener registered within the web.xml file. (to
get the web.xml simply execute grails install-templates on the
commandline. You'll find it under
grails-app/src/templates/war/web.xml) Be sure to make it the first
<listener/> entry within your web.xml so that Logback gets
configured and loaded as soon as possible.
I found this solution along with the full code sample over at
https://bowerstudios.com/node/896 which was the best and shortest
example I found on this topic which seems to work!
This solution just loaded the external configuration file and used
it within the ConfigLoader class but didn't set it for the whole
Grails application. So I googled around a bit more and I found a
solution from Logback, available at GitHub (https://github.com/qos-ch/logback-extensions) and integrating with the
Spring Framework, so I took these classes from this page and
the LogbackConfigurer class from here and tweaked them to fit
my needs.
Now everything works like a charm and I'am able to create an external configuration file and - what I like best - it's hooking in
with the log object which is injected to e.g. Controller classes
by default.
Hope this is also a help for other developers too ;)
If you've got a better or more "groovy" solution for this, pleas let me know!
I have a Grails app that uses the Rest plugin
When I drop my war into my JBoss deploy directory and start it up, the deployment of the app fails because of the following error:
2012-11-01 15:48:33,931 ERROR [org.jboss.web.tomcat.service.deployers.JBossContextConfig] XML error parsing: context.xml
org.jboss.xb.binding.JBossXBRuntimeException: Failed to create a new SAX parser
I believe this refers to the grails app containing a version on xercesImpl as well as JBoss having it's own. We usually rectify this by removing xercesImpl from our apps or setting them to "provided" scope.
I'm trying to figure out how I fix this deploy issue. I'm assuming I have to edit the BuildConfig.groovy script and tell it, somehow, to exclude xerces right? How would I do that for this plugin? If this were a "dependency" that appears to be easy to specify the exclusions. But I'm not sure how to do it for this plugin...
any ideas?
In your BuildConfig.groovy add this:
inherits('global') {
excludes 'serializer'
}
It turns out, doing the following in the plugin section of my BuildConfig.groovy did the trick after all...
compile(":rest:0.7"){
excludes "xercesImpl"
}