有人请帮忙......我能跑:
grails run-app
并在localhost:8080上访问我的应用程序。但是,我没有运气在Ubuntu 14.04.1LTS上部署到Tomcat 7.052。 war文件使用Tomcat Web Manager成功上传,但是在通过浏览器访问时出现HTTP错误404。我点击Tomcat Web Manager上的应用程序链接来访问应用程序。我尝试从Tomcat示例部署sample.war文件,它可以工作。
以下是我的尝试:
1)我从:
更改了build.gradle文件...
compile "org.springframework.boot:spring-boot-starter-tomcat"
...
为:
...
provided "org.springframework.boot:spring-boot-starter-tomcat"
...
2)我跑了:
grails war
生成war文件,然后使用Tomcat Web Manager成功上传。
3)我也试过重启tomcat服务。
这是我的grails-app / conf / application.yml文件:
---
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
答案 0 :(得分:0)
在深入了解下面嵌入的日志文件(catalina.out)后,我发现Tomcat使用的是Java 7,而我的grails应用程序使用的是Java 8.这就是我所做的:
1)我在我的服务器上安装了Java 8并设置了Tomcat来使用它。这显然减慢了我的Tomcat。
2)然后我在grails-app / conf / application.yml中配置了我的dataSource,以包含MySQL数据库的正确配置。这些配置位于dataSource下的Grails 3.x文档中。
3)最后,我加入了
runtime 'mysql:mysql-connector-java:5.1.29'
在我的gradle.build依赖项中。
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)