I am trying to use JDBCAppender to log to an H2 database in Grails (using GGTS). Since H2 is the default database in Grails, I shouldn't have to add the h2 jar to the CLASSPATH or set it as a dependency. But when I try to set the driver under the appender to org.h2.Driver, a java.lang.ClassNotFoundException is thrown. I've tried just about everything and cannot figure it out. It seems to be a JDBCAppender specific issue. Any solutions to this?
Related
In grails 3 spring security rest...config inside application.yaml is not being picked up but when i am trying with application.groovy everything works fine.Please help i am confused.
Do you receive an error, can you not login?
Have you migrated from an earlier version of grails and have copied the formatting over from groovy to yml?
I have my config in yml along the lines of the following with 4 spaces (rather than tabs) for the nesting.
grails:
plugin:
springsecurity:
active: true
useSecurityEventListener: false
Also I notice you've specified application.yaml as the file name, not sure if it makes any difference but I don't have the 'a' in my file i.e. application.yml
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.
If I create a new web profile app, and generate-all, it runs fine in my local and deploys without error to JBoss. But when I try to access the app all URLs return 404. I know the app started up successfully, because it created tables in the database.
Here's what I'm doing.
grails 3.1.4> create-app demo
create-domain-class Book
create-domain-class Author
Edit domain classes
generate-all *
change tomcat dependency from compile to provided in build.gradle
change dataSource in application.yml to use my JNDI Oracle connection
Add server: contextPath: /demo to application.yml
run-app -> Works
gradle war
Deploy to JBoss EAP 6.4.0.GA
JBoss says deployment and activation of the app was successful. There are no errors of any sort in any JBoss log file. And dbCreate: update made the DDL changes to my Oracle database, so I know it got that far. But all URLs for the app return 404.
This is a known bug: Issue-9481
It has been added to grails 3.1.5 milestone.
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 have Weceem 1.0 plugin installed in an empty Grails 1.3.7 application. I did the initial setup from the docs page, and I switched the devDB from "mem" to "file" storage.
I can create a space, populate some content, but then when I restart the application (grails run-app), my space and content is gone.
The devDB.script and other files show traces of Weceem data, but I lose the content in the newly started application.
What do I need to do to get it persistent?
You need to remove the settings dbCreate = "create/create-drop" and replace it by "update" or "none" in your DataSource.groovy file for development environment.
you can also start running a mongo database,
$ grails install-plugin mongodb
remove hibernate and add this to your domain class, to save your stuff to mongodb:
static mapWith="mongo"