spring boot data jpa can't connect to mysql database - java

I try to connect to mysql using spring-boot-starter-data-jpa and hibernate by this example but get
...
2016-07-28 13:20:49.021 ERROR 7765 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name
'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration':
Injection of autowired dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Could not
autowire field: private javax.sql.DataSource
org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.dataSource;
nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'dataSource' defined in class path resource
[org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]:
Bean instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to
instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw
exception; nested exception is
org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException:
Cannot determine embedded database driver class for database type
NONE. If you want an embedded database please put a supported one on
the classpath. If you have database settings to be loaded from a
particular profile you may need to active it (no profiles are
currently active)
...
application.properties:
# DataSource settings: set here your own configurations for the database
# connection. In this example we have "netgloo_blog" as database name and
# "root" as username and password.
spring.datasource.url = jdbc:mysql://localhost:3306/db
spring.datasource.username = db
spring.datasource.password = pass
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
# Keep the connection alive if idle for a long time (needed in production)
spring.datasource.testWhileIdle = true
spring.datasource.validationQuery = SELECT 1
# Show or not log for each sql query
spring.jpa.show-sql = true
# Hibernate ddl auto (create, create-drop, update)
spring.jpa.hibernate.ddl-auto = update
# Naming strategy
spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
# Use spring.jpa.properties.* for Hibernate native properties (the prefix is
# stripped before adding them to the entity manager)
# The SQL dialect makes Hibernate generate better SQL for the chosen database
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
project structure in eclipse:
build.gradle :
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle- plugin:1.3.6.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
jar {
baseName = 'gs-accessing-data-jpa'
version = '0.1.0'
}
repositories {
mavenCentral()
maven { url "https://repository.jboss.org/nexus/content/repositories/releases" }
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.3.6.RELEASE'
compile group: 'mysql', name: 'mysql-connector-java', version: '6.0.3'
//also tried
runtime group: 'mysql', name: 'mysql-connector-java', version: '6.0.3'
runtime "org.apache.tomcat:tomcat-jdbc:7.0.47"
testCompile("junit:junit")
}
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}

You did not add the driver class
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
Check for these dependencies as well

Can you add runtime dependency in gradle as opposed to compile time dependency on the MYSQL Driver jar ?
dependencies {
//compile "mysql:mysql-connector-java:6.0.3"
runtime "mysql:mysql-connector-java:6.0.3"
runtime "org.apache.tomcat:tomcat-jdbc:7.0.47"
}

do you have database driver on the classpath?
have you set property spring.datasource.driver-class-name?
For more details, see
http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-sql.html

Related

Springboot external file db configuration

I have application.properties with that code:
spring.config.additional-location=file:///C:/Users/user/Desktop/project/cfg.properties
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect
spring.jpa.hibernate.ddl-auto=validate
spring.jpa.show-sql=true
and in cfg.properties it looks like that:
spring.datasource.url=jdbc:oracle:thin:#correctDbUrl
spring.datasource.username=user
spring.datasource.password=pass
I think there is something wrong with the path - can't it be outside the project or what happened? This is an error (url is correct, it works when placed directly in application.properties):
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine suitable jdbc url
Gradle:
buildscript {
ext {
springBootVersion = '2.0.3.RELEASE'
}
repositories {
maven { url "someRepository" }
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group = 'com.abc'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
maven { url "someRepository" }
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
compileOnly('org.projectlombok:lombok')
testCompile('org.springframework.boot:spring-boot-starter-test')
compile(group: 'com.hynnet', name: 'oracle-driver-ojdbc6', version: '12.1.0.1')
compile("org.springframework.boot:spring-boot-starter-data-jpa")
}
Set the following environment variable.
SET SPRING_CONFIG_LOCATION=classpath:/application.properties,file:C:/Users/user/Desktop/project/cfg.properties
you can remove "spring.config.additional-location" from the property file.

Spring: Error creating bean with name 'entityManagerFactory'

I am following the tutorial at https://spring.io/guides/tutorials/bookmarks/ . I used the initializer and decided to use gradle. When attemting to build the application or directly run it, I'm getting the error:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
I guess that's caused by the spring-boot-starter-data-jpa or com.h2database:h2, and probably related to some version mismatch. However, I don't know what to do about it.
My gradle.build:
buildscript {
ext {
springBootVersion = '2.0.0.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-
plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group = 'sfs.examples'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 9.0
repositories {
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-web')
runtime('com.h2database:h2')
testCompile('org.springframework.boot:spring-boot-starter-test')
}

springboot 1.5.2 + hibernate-search-orm

I want to use springboot and hibernate-search-orm but can't get the project to compile.
I think it is because of compatability issues between hibernate versions?
I am using Gradle and Intellij Idea.
build.gradle
buildscript {
ext {
springBootVersion = '1.5.2.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
ext["thymeleaf.version"] = "3.0.2.RELEASE"
ext["thymeleaf-layout-dialect.version"] = "2.0.1"
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
version = '0.0.5-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-jdbc')
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
compile('org.springframework.boot:spring-boot-starter-web')
compile 'org.springframework.boot:spring-boot-starter-security'
compile ("org.thymeleaf.extras:thymeleaf-extras-springsecurity4:3.0.0.RELEASE")
compile group: 'org.springframework.boot', name: 'spring-boot-starter-logging', version: '1.5.2.RELEASE'
compile group: 'org.thymeleaf.extras', name: 'thymeleaf-extras-springsecurity4', version: '2.1.2.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-autoconfigure', version: '1.5.2.RELEASE'
compile group: 'org.hibernate', name: 'hibernate-search-orm',
version: '5.1.0.Final'
compile("org.springframework.boot:spring-boot-devtools")
compile('mysql:mysql-connector-java')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
bootRun {
addResources = true
}
And the output when I run build
5:40:30 PM: Executing external task 'build'...
C:\Users\Owner\IdeaProjects\test\src\main\java\com\example\controllers\planController.java:27: warning: sym is internal proprietary API and may be removed in a future release
import static com.sun.org.apache.xalan.internal.xsltc.compiler.sym.error;
^
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 warning
:compileJava
:processResources UP-TO-DATE
:classes
:findMainClass
:jar
:bootRepackage
:assemble
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test
com.example.Demo3ApplicationTests > contextLoads FAILED
java.lang.IllegalStateException
Caused by: org.springframework.beans.factory.BeanCreationException
Caused by: java.lang.AbstractMethodError
1 test completed, 1 failed
:test FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':test'.
> There were failing tests. See the report at: file:///C:/Users/Owner/IdeaProjects/test/build/reports/tests/test/index.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 23.392 secs
There were failing tests. See the report at: file:///C:/Users/Owner/IdeaProjects/test/build/reports/tests/test/index.html
5:40:54 PM: External task execution finished 'build'.
I don't think hibernate-search-orm is part of springboot so I have added it to my build.gradle file explicitly.
If I try to run my project the root error appears to be:
Error handling failed (Error creating bean with name 'delegatingApplicationListener' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' available)
You need to Specify the versions of dependencies that you are using. And they should be compatible to each other.Go through https://mvnrepository.com and find your spring boot version and check Compile Dependencies. Do it with all other dependencies that you are using .

Flyway for Existing PUBLIC schema

#Configuration
#ComponentScan("com.sammy")
#EnableTransactionManagement
public class DataSourceConfig {
#Bean(destroyMethod = "shutdown")
public DataSource dataSource(){
EmbeddedDatabaseBuilder databaseBuilder = new EmbeddedDatabaseBuilder();
databaseBuilder.setType(EmbeddedDatabaseType.H2);
databaseBuilder.addScript("classpath:db/migration/V1__Create_Books_Table.sql");
databaseBuilder.addScript("classpath:db/migration/V2__Add_Books.sql");
return databaseBuilder.build();
}
#Bean(name = "entityManagerFactory")
public EntityManagerFactory managerFactory(){
HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
vendorAdapter.setGenerateDdl(true);
Properties jpaProperties = new Properties();
jpaProperties.put("hibernate.hbm2ddl.auto", "create-drop");
jpaProperties.put("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
LocalContainerEntityManagerFactoryBean managerFactoryBean = new LocalContainerEntityManagerFactoryBean();
managerFactoryBean.setDataSource(dataSource());
managerFactoryBean.setPackagesToScan("com.sammy");
managerFactoryBean.setJpaVendorAdapter(vendorAdapter);
managerFactoryBean.setJpaProperties(jpaProperties);
managerFactoryBean.afterPropertiesSet();
return managerFactoryBean.getObject();
}
#Bean
public PlatformTransactionManager transactionManager(){
JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(managerFactory());
return transactionManager;
}
}
Above is my data configuration class.
buildscript {
repositories {
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.com.boxfuse.client:flyway-release:${flywayVersion}"
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:${sonarVersion}"
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
}
}
apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'org.sonarqube'
apply plugin: 'org.flywaydb.flyway'
apply plugin: 'org.springframework.boot'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
jar{
group 'com.sammy'
version '1.0-SNAPSHOT'
}
dependencies {
testCompile "junit:junit:${junitVersion}"
testCompile "info.cukes:cucumber-java:${cucumberVersion}"
testCompile "info.cukes:cucumber-junit:${cucumberVersion}"
//testCompile "info.cukes:cucumber-spring:${cucumberVersion}"
testCompile 'org.springframework.boot:spring-boot-starter-test'
compile 'com.h2database:h2'
compile "org.flywaydb:flyway-core:${flywayVersion}"
compile "org.projectlombok:lombok:${lombokVersion}"
compile("org.springframework.boot:spring-boot-starter-web") {
exclude module: "spring-boot-starter-tomcat"
}
compile 'org.springframework.boot:spring-boot-starter-aop'
compile 'org.springframework.boot:spring-boot-starter-jetty'
compile "io.springfox:springfox-swagger2:${swaggerVersion}"
compile "io.springfox:springfox-swagger-ui:${swaggerVersion}"
compile 'org.springframework.boot:spring-boot-starter-actuator'
compile 'org.springframework.cloud:spring-cloud-starter-config'
compile 'org.springframework.boot:spring-boot-starter-data-jpa'
//compile 'org.springframework.boot:spring-boot-starter-data-mongodb'
}
flyway{
user = 'sa'
schema = ['PUBLIC', 'testdb']
url = 'jdbc:h2:mem:testdb'
baselineVersion = 7.0
baselineOnMigrate = false
baselineDescription = "Base Migration"
}
flywayMigrate{
dependsOn flyway
}
task wrapper(type :Wrapper){
gradleVersion = '3.4.1'
}
I have got that build.gradle file which attempts to configure flyway for use within a SpringBoot application. I'm trying to migrate data to an in-memory H2 database but keep getting the error below:
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.api.FlywayException: Found non-empty schema(s) "PUBLIC" without metadata table! Use baseline() or set baselineOnMigrate to true to initialize the metadata table.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
at org.springframework.context.annotation.AnnotationConfigApplicationContext.<init>(AnnotationConfigApplicationContext.java:84)
at com.sammy.SpringDataTutorials.main(SpringDataTutorials.java:18)
Caused by: org.flywaydb.core.api.FlywayException: Found non-empty schema(s) "PUBLIC" without metadata table! Use baseline() or set baselineOnMigrate to true to initialize the metadata table.
at org.flywaydb.core.Flyway$1.execute(Flyway.java:954)
at org.flywaydb.core.Flyway$1.execute(Flyway.java:930)
at org.flywaydb.core.Flyway.execute(Flyway.java:1413)
at org.flywaydb.core.Flyway.migrate(Flyway.java:930)
at org.springframework.boot.autoconfigure.flyway.FlywayMigrationInitializer.afterPropertiesSet(FlywayMigrationInitializer.java:66)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
... 11 more
I have read some many possible solutions on here but still no joy and even read the official boxfuse website to make sense of what to do but still being able to find a solution. My files are in src/main/resources/db.migration and named as V1__Create_Books_Table.sql and V2__Add_Books.sql. I also see the log message:
[main] DEBUG org.flywaydb.core.internal.command.DbSchemas - Schema "PUBLIC" already exists. Skipping schema creation.
Any help to solve this will be much appreciated. Thanks guys!
I've solved this problem by adding the Spring boot flyway definitions within the application.properties for flyway.baseline-version instead of using the boxfuse gradle plugin.

Error deploying grails 3 app to glassfish server [duplicate]

This question already has answers here:
Unable to deploy Spring Boot App on Glassfish 4.1
(2 answers)
Closed 6 years ago.
I'm trying to deploy a grails 3 packaged war to a Glassfish 4.1.1 server. Initially I was using GF v. 4.1 but it has some bugs, so I decided to update, but it still gives me a error:
remote failure: Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsApplicationPostProcessor': BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: void org.springframework.transaction.annotation.AbstractTransactionManagementConfiguration.setConfigurers(java.util.Collection); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDatastore': Cannot resolve reference to bean 'sessionFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.jboss.logging.LoggerProviders. Please see server.log for more details.
Command deploy failed.
when deploying from console.
My build.gradle:
buildscript {
ext {
grailsVersion = project.grailsVersion
}
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.8.2"
classpath "org.grails.plugins:hibernate4:5.0.10"
}
}
version "20161012-01"
group "mofel"
apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"war"
apply plugin:"org.grails.grails-web"
apply plugin:"org.grails.grails-gsp"
apply plugin:"asset-pipeline"
ext {
grailsVersion = project.grailsVersion
gradleWrapperVersion = project.gradleWrapperVersion
}
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencyManagement {
imports {
mavenBom "org.grails:grails-bom:$grailsVersion"
}
applyMavenExclusions false
}
grails {
exploded = true
plugins {
//some local plugins already packaged
}
}
dependencies {
compile files("lib/not-yet-commons-ssl-0.3.11.jar", "lib/commons-codec-1.6.jar","lib/cfdi32.jar","lib/xmlbeans-2.3.0.jar", "lib/cfdi-commons-0.0.1-SNAPSHOT.jar", "lib/itext-2.1.0.jar", "lib/core-renderer-r8.jar")
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.jboss.logging:jboss-logging:3.2.0.Final"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.grails:grails-core"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.grails:grails-dependencies"
compile "org.grails:grails-web-boot"
compile "org.grails.plugins:cache"
compile "org.grails.plugins:scaffolding"
compile "org.grails.plugins:hibernate4"
compile "org.hibernate:hibernate-ehcache"
compile 'org.apache.poi:poi:3.8'
compile 'org.apache.poi:poi-ooxml:3.8'
compile 'org.apache.xmlbeans:xmlbeans:2.6.0'
//Local Plugins
compile "org.crsh:crsh.site:1.2.0-cr8"
compile "org.springframework.boot:spring-boot-starter-batch"
console "org.grails:grails-console"
profile "org.grails.profiles:web"
compile 'org.grails.plugins:spring-security-core:3.0.3'
compile "org.springframework.boot:spring-boot-starter-tomcat"
runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.8.2"
runtime "org.postgresql:postgresql:9.4.1208.jre7"
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:geb"
testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
}
assets {
minifyJs = true
minifyCss = true
}
And the application.yml:
---
hibernate:
cache:
queries: false
use_second_level_cache: true
use_query_cache: false
region.factory_class: org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory
dataSource:
pooled: true
jmxExport: true
driverClassName: org.postgresql.Driver
username: someuser
password: somepassword
environments:
development:
dataSource:
dbCreate: update
#url: jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
url: jdbc:postgresql://server:port:databaseName
test:
dataSource:
dbCreate: update
url: jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
production:
dataSource:
dbCreate: update
url: jdbc:postgresql://server:port:databaseName
properties:
jmxEnabled: true
initialSize: 5
maxActive: 50
minIdle: 5
maxIdle: 25
maxWait: 10000
maxAge: 600000
timeBetweenEvictionRunsMillis: 5000
minEvictableIdleTimeMillis: 60000
validationQuery: SELECT 1
validationQueryTimeout: 3
validationInterval: 15000
testOnBorrow: true
testWhileIdle: true
testOnReturn: false
jdbcInterceptors: ConnectionState
defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED
---
---
grails:
profile: web
codegen:
defaultPackage: mofel
spring:
transactionManagement:
proxies: false
info:
app:
name: '#info.app.name#'
version: '#info.app.version#'
grailsVersion: '#info.app.grailsVersion#'
spring:
groovy:
template:
check-template-location: false
# Spring Actuator Endpoints are Disabled by Default
endpoints:
enabled: false
jmx:
enabled: true
---
grails:
mime:
disable:
accept:
header:
userAgents:
- Gecko
- WebKit
- Presto
- Trident
types:
all: '*/*'
atom: application/atom+xml
css: text/css
csv: text/csv
form: application/x-www-form-urlencoded
html:
- text/html
- application/xhtml+xml
js: text/javascript
json:
- application/json
- text/json
multipartForm: multipart/form-data
pdf: application/pdf
rss: application/rss+xml
text: text/plain
hal:
- application/hal+json
- application/hal+xml
xml:
- text/xml
- application/xml
urlmapping:
cache:
maxsize: 1000
controllers:
defaultScope: singleton
converters:
encoding: UTF-8
views:
default:
codec: html
gsp:
encoding: UTF-8
htmlcodec: xml
codecs:
expression: html
scriptlets: html
taglib: none
staticparts: none
endpoints:
jmx:
unique-names: true
java -version
openjdk version "1.8.0_91"
(Tried with oracle JDK 1.8)
Any idea or suggestion?
Thanks in advance
As #jny pointed, only thing I was missing was to create a file called glassfish-web.xml inside src/main/webapp/WEB-INF.
The content of the file its:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
<class-loader delegate="false"/>
</glassfish-web-app>
as pointed in:
Unable to deploy Spring Boot App on Glassfish 4.1

Categories

Resources