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
Related
I'm currently learning microservices. After creating my first microservice, I tried to connect my microservice to a PostgreSQL database but I have the following error:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
With this exception:
Exception encountered during context initialization - cancelling
refresh attempt:
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'dataSourceScriptDatabaseInitializer'
defined in class path resource
[org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]:
Unsatisfied dependency expressed through method
'dataSourceScriptDatabaseInitializer' parameter 0; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'dataSource' defined in class path resource
[org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]:
Bean instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to
instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method
'dataSource' threw exception; nested exception is
org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException:
Failed to determine a suitable driver class
2022-12-06 22:33:04.408 INFO 2012 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
Here's my application.yml
server:
port: 8080
spring:
application:
name: player
datasource:
password: "MySecretPassword!"
url: jdbc:postgresql://localhost:5432/genjiservices
username: saucegenji
jpa:
hibernate:
ddl-auto: update
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
format_sql: true
show-sql: true
I couldn't post my pom because it says it was a spam.
I tried to find solutions first, but couldn't find one that works for me. I think my application is ignoring my application.yml could that be the case? My application.yml is in the resources folder like it should be, so I don't really understand.
Check if the following is present in the pom file.Also check for JPA dependencies in pom.
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
The goal is, to have dev and prod environments. For the local run to use application-dev.yml and for deploying to the server to use application-prod.yml
I have 3 configuration files
application.yml
spring:
main:
banner-mode: off
application-dev.yml
spring:
datasource:
password: dev-user-pwd
username: dev-user
url: jdbc:mysql://localhost:3306/db
driver-class-name: com.mysql.cj.jdbc.Driver
application-prod.yml
spring:
datasource:
password: prod-user-pwd
username: prod-user
url: jdbc:mysql://localhost:3306/db
driver-class-name: com.mysql.cj.jdbc.Driver
In the server, I have maven installed and trying to run
mvn clean package -Dspring.profiles.active=prod
Here is the error log that I'm getting
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 10.966 s <<< FAILURE! - in com.partplug.api.ApiApplicationTests
contextLoads Time elapsed: 0.005 s <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration': Unsatisfied dependency expressed through method 'setConfigurers' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.data.web.config.SpringDataWebConfiguration': Injection of autowired dependencies failed; nested exception is java.lang.NoClassDefFoundError: org/xmlbeam/config/XMLFactoriesConfig
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.data.web.config.SpringDataWebConfiguration': Injection of autowired dependencies failed; nested exception is java.lang.NoClassDefFoundError: org/xmlbeam/config/XMLFactoriesConfig
Caused by: java.lang.NoClassDefFoundError: org/xmlbeam/config/XMLFactoriesConfig
Caused by: java.lang.ClassNotFoundException: org.xmlbeam.config.XMLFactoriesConfig
In short: the error says that, datasource and all sub-properties are not defined. Meaning, maven packager doesn't change the active profile to prod.
What am I doing wrong?
I've recently managed to upgrade a jhipster generated app (Spring Boot + Angular)
Issue comes after cleaning code and adapting a few annotations, now I get success when doing a maven clean - install skipping tests but when I try to start the app I get the error mentioned in the title
I've checked pom for duplicated dependencies and had a clean out of the properties file, to no result
This is the full error:
2017-11-30 10:12:57.821 INFO 4320 --- [ restartedMain] o.w.d.DrugQualityDataManagerApp : Starting DrugQualityDataManagerApp on steven-OptiPlex-7040 with PID 4320 (/home/steven/Desktop/Upgraded_MQ/target/classes started by steven in /home/steven/Desktop/Upgraded_MQ)
2017-11-30 10:12:57.821 INFO 4320 --- [ restartedMain] o.w.d.DrugQualityDataManagerApp : The following profiles are active: swagger,dev
2017-11-30 10:12:57.874 ERROR 4320 --- [ restartedMain] o.s.boot.SpringApplication : Application startup failed
java.lang.NoClassDefFoundError: org/springframework/beans/factory/config/EmbeddedValueResolver
at org.springframework.context.support.ApplicationContextAwareProcessor.<init>(ApplicationContextAwareProcessor.java:72)
at org.springframework.context.support.AbstractApplicationContext.prepareBeanFactory(AbstractApplicationContext.java:634)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:518)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at org.wwarn.drugquality.DrugQualityDataManagerApp.main(DrugQualityDataManagerApp.java:66)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.lang.ClassNotFoundException: org.springframework.beans.factory.config.EmbeddedValueResolver
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 13 common frames omitted
2017-11-30 10:12:58.127 WARN 4320 --- [ restartedMain] ationConfigEmbeddedWebApplicationContext : Exception thrown from LifecycleProcessor on context close
java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#350e9339: startup date [Thu Nov 30 10:12:57 GMT 2017]; root of context hierarchy
at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:427)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:999)
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:958)
at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:750)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
at org.wwarn.drugquality.DrugQualityDataManagerApp.main(DrugQualityDataManagerApp.java:66)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Disconnected from the target VM, address: '127.0.0.1:43599', transport: 'socket'
Process finished with exit code 1
My pom.xml (I had to embed it in a jsFiddle as it's too long for the body of an SO post)
Properties file:
spring:
profiles:
active: dev
include: swagger
devtools:
restart:
enabled: true
livereload:
enabled: false # we use gulp + BrowserSync for livereload
jackson:
serialization.indent_output: true
datasource:
url: jdbc:mysql://localhost:3306/myDB?useUnicode=true&characterEncoding=utf8
username: myDB
password: myDB
h2:
console:
enabled: false
jpa:
database-platform: org.hibernate.dialect.MySQLDialect
database: MYSQL
show_sql: false
generate-ddl: true
hibernate:
ddl-auto: update
naming:
physical-strategy: org.wwarn.drugquality.config.HibernateAuditTablesNamingStrategy
properties:
hibernate.id.new_generator_mappings: true
hibernate.cache.use_second_level_cache: true
hibernate.cache.use_query_cache: false
hibernate.generate_statistics: true
hibernate.cache.region.factory_class: org.hibernate.cache.jcache.JCacheRegionFactory
data:
elasticsearch:
cluster-name:
cluster-nodes:
properties:
path:
logs: target/elasticsearch/log
data: target/elasticsearch/data
mail:
host: localhost
port: 25
username:
password:
messages:
cache-seconds: 1
thymeleaf:
cache: false
liquibase:
contexts: dev
server:
port: 8080
jhipster:
http:
version: V_1_1 # To use HTTP/2 you will need SSL support (see above the "server.ssl" configuration)
cache: # Cache configuration
ehcache: # Ehcache configuration
time-to-live-seconds: 3600 # By default objects stay 1 hour in the cache
max-entries: 100 # Number of objects in each cache entry
# CORS is only enabled by default with the "dev" profile, so BrowserSync can access the API
cors:
allowed-origins: "*"
allowed-methods: "*"
allowed-headers: "*"
allow-credentials: true
max-age: 1800
security:
remember-me:
# security key (this key should be unique for your application, and kept secret)
key: daKey
mail: # specific JHipster mail property, for standard properties see MailProperties
from: DrugQualityDataManager#localhost
base-url: http://127.0.0.1:8080
metrics: # DropWizard Metrics configuration, used by MetricsConfiguration
jmx.enabled: true
graphite: # Use the "graphite" Maven profile to have the Graphite dependencies
enabled: false
host: localhost
port: 2003
prefix: DrugQualityDataManager
prometheus: # Use the "prometheus" Maven profile to have the Prometheus dependencies
enabled: false
endpoint: /prometheusMetrics
logs: # Reports Dropwizard metrics in the logs
enabled: false
report-frequency: 60 # in seconds
logging:
logstash: # Forward logs to logstash over a socket, used by LoggingConfiguration
enabled: false
host: localhost
port: 5000
queue-size: 512
# ===================================================================
# Application specific properties
# Add your own application properties here, see the ApplicationProperties class
# to have type-safe configuration, like in the JHipsterProperties above
#
# More documentation is available at:
# http://www.jhipster.tech/common-application-properties/
# ===================================================================
application:
In your fiddled pom there is this dep:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.2.9.RELEASE</version>
</dependency>
The EmbeddedValueResolver was introduced in Spring 4.3
You might want to clean up your dependencies. Perhaps it's sufficient to pull spring-beans up to 4.3
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
Someone help please...I am able to run:
grails run-app
and access my application on localhost:8080. However, I have no luck deploying to Tomcat 7.052 on Ubuntu 14.04.1LTS. The war file uploads successfully using the Tomcat Web Manager but I get HTTP error 404 upon accessing via the browser. I am clicking on the application link on the Tomcat Web Manager to access the applications. I tried deploying the sample.war file from Tomcat examples and it works.
Here is what I have tried:
1) I changed my build.gradle file from:
...
compile "org.springframework.boot:spring-boot-starter-tomcat"
...
to:
...
provided "org.springframework.boot:spring-boot-starter-tomcat"
...
2) I ran:
grails war
to generate a war file in which I then uploaded successfully using Tomcat Web Manager.
3) I also tried restarting the tomcat service.
Here is my grails-app/conf/application.yml file:
---
grails:
profile: web
codegen:
defaultPackage: myApp
info:
app:
name: '#info.app.name#'
version: '#info.app.version#'
grailsVersion: '#info.app.grailsVersion#'
spring:
groovy:
template:
check-template-location: false
---
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
---
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:
environments:
development:
dataSource:
dbCreate: create-drop
url: jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
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:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
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
After digging into the log files (catalina.out) embedded below, I found out that Tomcat was using Java 7 whilst my grails application had used Java 8. Here is what I did:
1) I installed Java 8 on my server and set Tomcat to use it. This has significantly slowed down my Tomcat though.
2) I then configured my dataSource in grails-app/conf/application.yml to include the correct configurations for MySQL database. These configuration are in Grails 3.x documentation under dataSource.
3) Lastly, I included
runtime 'mysql:mysql-connector-java:5.1.29'
in my gradle.build dependencies.
Sep 09, 2015 2:47:32 AM org.apache.catalina.util.Introspection loadClass
FINE: Failed to load class [{0}]
java.lang.UnsupportedClassVersionError: myApp/ApplicationLoader : Unsupported major.minor version 52.0 (unable to load class myApp.ApplicationLoader)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2948)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1208)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1688)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1569)
at org.apache.catalina.util.Introspection.loadClass(Introspection.java:143)
at org.apache.catalina.startup.ContextConfig.checkHandlesTypes(ContextConfig.java:2117)
at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2056)
at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2030)
at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2023)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1288)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:873)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:371)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5355)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1073)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)