How to configure Grails to work with Apache Derby instead of HSQLDB
Install the derby driver into the lib folder of your application.
Configure the DataSource:
driverClassName = "org.apache.derby.jdbc.ClientDriver"
dbCreate = "create-drop"
url = "jdbc:derby://localhost:1527/theDatabase"
Start the derby server.
Create the empty database (through ij or a graphical sql client).
Start grails.
You need to have Derby libraries, and configure your DataSources.groovy appropriately. Check out this blog post. It's old, but the instructions might still work.
Configuration for grails 3 in application.yml
dataSource:
dbCreate: create-drop
driverClassName: org.apache.derby.jdbc.EmbeddedDriver
url: jdbc:derby:memory:db;create=true
And build.gradle
dependencies {
runtime 'org.apache.derby:derby:10.12.1.1'
//... other dependencies
}
Related
I'm using Grails Spring Security plugin version:
compile ":spring-security-core:2.0-RC4"
compile ":spring-security-acl:2.0-RC2"
is it possible to turn off password check somehow for my dev environment?
If what you want is diable security in the development environment, you can do this by adding this line in your development section of your grails configuration (depending on your version of grails, here Config.groovy, for grails 2.x):
environments {
development {
grails.plugin.springsecurity.active = false
}
}
In grails 3, you can do this in application.yml
environments:
development:
grails:
plugin:
springsecurity:
active: false
I recently deployed a Grails application to Tomcat and ran into the following exception on startup.
o.h.engine.jdbc.spi.SqlExceptionHelper
Im not sure whats going on. All supporting Domain objects are being created in BootStrap without issue locally, however it fails to create the same supporting data and throws the exception above when BootStrap.groovy go through its routine in production.
Grails version 3.2.8
I discovered that BootStrap data generation was failing because dbCreate in the application.yml was set to none in production. Simply change none to update.
Change from:
application.yml
production:
dataSource:
dbCreate: none
To:
application.yml
production:
dataSource:
dbCreate: update
This resolved my issue
I am trying to use a Grails Project as a Plugin to basically have my domain classes in the Plugin and then use them in multiple Grails projects.
I've done this:
grails create-app web
grails create-app plugin
create a settings.gradle in the root directory of both projects with
include 'plugin', 'web'
then I added spring security to the plugin and used s2-quickstart to create a user and a role domain class and added some default users to the Bootstrap.groovy.
Starting the plugin project alone doesn't show any issues.
Now I added the plugin as a dependency to the web project:
compile (':plugin')
This way I can access the domain classes from the plugin inside the web project, it compiles fine. I added the spring config to the application.groovy and am now trying to use the domain classes from the plugin inside the web project.
Trying this however my project does not correctly start and it tells me this:
java.lang.IllegalStateException: Either class [htcommon.HtRole] is not a domain class or GORM has not been initialized correctly or has already been shutdown. If you are unit testing your entities using the mocking APIs
as soon as my code tries to do new HtRole(...).save()
It seems the domain classes from the plugin are not recognized as GORM classes somehow.
The issue with the domain not being recognized as a GORM class was due to the constructors provided in them. These constructors were generated from s2-quickstart, but should be removed (it's a bug in spring-security-core). I removed the constructors and the one place you were using them I used map style default constructors. Then I fixed the call you had to get the current user.
The repaired source is in this repo on GitHub (patch-1 branch is working, master is the OP's original broken code)
I received the same error message when running a plugin containing GORM domains using grails run-app in Grails 3.1.6. I fixed the problem by providing explicit configuration for initialising Hibernate as follows:
build.gradle:
dependencies {
...
runtime "org.grails.plugins:hibernate4"
runtime "org.hibernate:hibernate-ehcache"
}
grails-app/conf/application.yml:
---
environments:
development:
hibernate:
cache:
queries: false
use_second_level_cache: true
use_query_cache: false
region.factory_class: 'org.hibernate.cache.ehcache.EhCacheRegionFactory'
dataSource:
pooled: true
jmxExport: true
driverClassName: org.h2.Driver
username: sa
password:
dbCreate: create-drop
url: jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
I am trying to deploy a Grails 2.3.5 application with a MySQL binding on AppFog. I did this successfully with a Grails 2.2.4 application using the following settings in DataSource.groovy:
production {
def envVar = System.env.VCAP_SERVICES
def credentials = envVar?grails.converters.JSON.parse(envVar)["mysql-5.1"][0]["credentials"]:null
dataSource {
pooled = true
dbCreate = "update"
driverClassName = "com.mysql.jdbc.Driver"
url = credentials?"jdbc:mysql://${credentials.hostname}:${credentials.port}/${credentials.name}?useUnicode=yes&characterEncoding=UTF-8":""
username = credentials?credentials.username:""
password = credentails?credentials.password:""
}
}
I also uncommented the runtime mysql connector statement in BuildConfig.groovy. My 2.2.4 app starts, allows data commits, and persists data after an application restart.
In my 2.3.5 application, I can deploy on AppFog without MySQL by setting the following in BuildConfig.groovy, which downgrades the build to Tomcat 6:
grails.servlet.version = "2.5"
and in the plugins section:
build ":tomcat:2.2.4"
The app starts and commits data, but since files do not persist, the H2 datafiles are deleted after an application restart. If I make the same changes as above to configure MySQL, I get the following error when the application starts:
Feb 12, 2014 6:05:44 PM org.apache.tomcat.jdbc.pool.ConnectionPool init
SEVERE: Unable to create initial connections of pool.
java.sql.SQLException: Access denied for user 'uqVkBpKILRjxS'#'10.0.13.117' (using password: NO)
The logs contain much more, but that seems to be the offending error. Did something else change in Grails 2.3.5 that I need to add to my config files? Thanks for the help.
I am a newbie for log4j and sl4j, I am using grails 2.0.4 and in config.groovy there is a line
grails.logging.jul.usebridge = false for prod
&
grails.logging.jul.usebridge = true for dev
I followed this article, As it says that use of grails.logging.jul.usebridge is to implement the swapping logic of logging frameworks such as
log4j
java.util.logging
commons logging
logback
Is this the only use of grails.logging.jul.usebridge in config.groovy, or is there any other uses
And one more question
which is the recommended logging framework to use in production environment
I definitely recommend you using Log4j. It has no dependencies and is tested (or even included) in various web app servers. You can configure it easily via DSL in Config.groovy or in separate config file in production environment.
Both commons-logging and SLF4J are wrappers for Log4j and use it underneath.
The grails.logging.jul.usebridge = true is used to put java.util.logging through SLF4J, as described here.