te')); return $arr; } /* 遍历用户所有主题 * @param $uid 用户ID * @param int $page 页数 * @param int $pagesize 每页记录条数 * @param bool $desc 排序方式 TRUE降序 FALSE升序 * @param string $key 返回的数组用那一列的值作为 key * @param array $col 查询哪些列 */ function thread_tid_find_by_uid($uid, $page = 1, $pagesize = 1000, $desc = TRUE, $key = 'tid', $col = array()) { if (empty($uid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('uid' => $uid), array('tid' => $orderby), $page, $pagesize, $key, $col); return $arr; } // 遍历栏目下tid 支持数组 $fid = array(1,2,3) function thread_tid_find_by_fid($fid, $page = 1, $pagesize = 1000, $desc = TRUE) { if (empty($fid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('fid' => $fid), array('tid' => $orderby), $page, $pagesize, 'tid', array('tid', 'verify_date')); return $arr; } function thread_tid_delete($tid) { if (empty($tid)) return FALSE; $r = thread_tid__delete(array('tid' => $tid)); return $r; } function thread_tid_count() { $n = thread_tid__count(); return $n; } // 统计用户主题数 大数量下严谨使用非主键统计 function thread_uid_count($uid) { $n = thread_tid__count(array('uid' => $uid)); return $n; } // 统计栏目主题数 大数量下严谨使用非主键统计 function thread_fid_count($fid) { $n = thread_tid__count(array('fid' => $fid)); return $n; } ?>Grails (6.2.3) generated war file not running on tomcat 1011 - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Grails (6.2.3) generated war file not running on tomcat 1011 - Stack Overflow

programmeradmin4浏览0评论

I have created a grails project using grails version 6.2.3. After this this added the quartz job dependencies and then create the class for schedule job. Command : grails create-app testApp grails create-job runjob

in the create class added the "println" line to print the date. verified the working using "grails run-app", it is printing the output on console Executing RunJob at Tue Feb 18 12:12:45 EST 2025

now used the "grails war" to generate the war file. When I deploy the war file on tomcat 11 job is not starting. Possibly it is not running because of javax is changed to jakarta in tomcat 11. I tried different combination of dependencies to change the javax to jakarta in build.gradle but none worked. What changes i need to make in my project to build a war file which will work in tomcat 11.

build.gradle

buildscript {
    repositories {
        maven { url "/" }
        maven { url "; }
    }
    dependencies {
        classpath ".grails:grails-gradle-plugin:$grailsGradlePluginVersion"
        classpath "gradle.plugin.github.erdi.webdriver-binaries:webdriver-binaries-gradle-plugin:2.6"
        classpath ".grails.plugins:hibernate5:7.3.0"
        classpath "com.bertramlabs.plugins:asset-pipeline-gradle:3.4.7"
    }
}

version "0.1"
group "jobapp"

apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"war"
apply plugin:".grails.grails-web"
apply plugin:"com.github.erdi.webdriver-binaries"
apply plugin:".grails.grails-gsp"
apply plugin:"com.bertramlabs.asset-pipeline"

repositories {
    mavenCentral()
    maven { url "; }
}

configurations {
    developmentOnly
    runtimeClasspath {
        extendsFrom developmentOnly
    }
}

dependencies {
    developmentOnly(".springframework.boot:spring-boot-devtools")
    compileOnly "io.micronaut:micronaut-inject-groovy"
    console ".grails:grails-console"
    implementation ".springframework.boot:spring-boot-starter-logging"
    implementation ".springframework.boot:spring-boot-starter-validation"
    implementation ".springframework.boot:spring-boot-autoconfigure"
    implementation ".grails:grails-core"
    implementation ".springframework.boot:spring-boot-starter-actuator"
    implementation ".springframework.boot:spring-boot-starter-tomcat"
    implementation ".grails:grails-web-boot"
    implementation ".grails:grails-logging"
    implementation ".grails:grails-plugin-rest"
    implementation ".grails:grails-plugin-databinding"
    implementation ".grails:grails-plugin-i18n"
    implementation ".grails:grails-plugin-services"
    implementation ".grails:grails-plugin-url-mappings"
    implementation ".grails:grails-plugin-interceptors"
    implementation ".grails.plugins:cache"
    implementation ".grails.plugins:async"
    implementation ".grails.plugins:scaffolding"
    implementation ".grails.plugins:hibernate5"
    implementation ".hibernate:hibernate-core:5.6.11.Final"
    implementation ".grails.plugins:events"
    implementation ".grails.plugins:gsp"
    
    implementation '.grails.plugins:quartz:3.0.0'
    implementation ".quartz-scheduler:quartz:2.5.0"
    implementation 'com.mysql:mysql-connector-j:9.2.0'
    
    profile ".grails.profiles:web"
    runtimeOnly ".glassfish.web:el-impl:2.2.1-b05"
    runtimeOnly "com.h2database:h2"
    runtimeOnly ".apache.tomcat:tomcat-jdbc"
    runtimeOnly "javax.xml.bind:jaxb-api:2.3.1"
    runtimeOnly "com.bertramlabs.plugins:asset-pipeline-grails:3.4.7"
    testImplementation "io.micronaut:micronaut-inject-groovy"
    testImplementation ".grails:grails-gorm-testing-support"
    testImplementation ".mockito:mockito-core"
    testImplementation ".grails:grails-web-testing-support"
    testImplementation ".grails.plugins:geb"
    testImplementation ".seleniumhq.selenium:selenium-remote-driver:4.0.0"
    testImplementation ".seleniumhq.selenium:selenium-api:4.0.0"
    testImplementation ".seleniumhq.selenium:selenium-support:4.0.0"
    testRuntimeOnly ".seleniumhq.selenium:selenium-chrome-driver:4.0.0"
    testRuntimeOnly ".seleniumhq.selenium:selenium-firefox-driver:4.0.0"
}

bootRun {
    ignoreExitValue true
    jvmArgs(
        '-Dspring.output.ansi.enabled=always', 
        '-noverify', 
        '-XX:TieredStopAtLevel=1',
        '-Xmx1024m')
    sourceResources sourceSets.main
    String springProfilesActive = 'spring.profiles.active'
    systemProperty springProfilesActive, System.getProperty(springProfilesActive)
}

tasks.withType(GroovyCompile) {
    configure(groovyOptions) {
        forkOptions.jvmArgs = ['-Xmx1024m']
    }
}

tasks.withType(Test) {
    useJUnitPlatform()
}

webdriverBinaries {
    if (!System.getenv().containsKey('GITHUB_ACTIONS')) {
        chromedriver {
            version = '2.45.0'
            fallbackTo32Bit = true
        }
        geckodriver '0.30.0'
    }
}

tasks.withType(Test) {
    systemProperty "geb.env", System.getProperty('geb.env')
    systemProperty "geb.build.reportsDir", reporting.file("geb/integrationTest")
    if (!System.getenv().containsKey('GITHUB_ACTIONS')) {
        systemProperty 'webdriver.chrome.driver', System.getProperty('webdriver.chrome.driver')
        systemProperty 'webdriver.gecko.driver', System.getProperty('webdriver.gecko.driver')
    } else {
        systemProperty 'webdriver.chrome.driver', "${System.getenv('CHROMEWEBDRIVER')}/chromedriver"
        systemProperty 'webdriver.gecko.driver', "${System.getenv('GECKOWEBDRIVER')}/geckodriver"
    }
}


assets {
    minifyJs = true
    minifyCss = true
}

gradle.properties

grailsVersion=6.2.3
grailsGradlePluginVersion=6.2.4
groovyVersion=3.0.23
gorm.version=8.1.2
.gradle.daemon=true
.gradle.parallel=true
.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx1024M

To fix the issue, I changed the dependencies of javax to jakarta, updated all other dependency to latest including spring, i expect it to work but not worked, when deployed, job is not getting started.

Second, I tried tomcat 10. inside to it create a webapps-javaee folder and paste the war file there to upgrade the dependency, in this job is not getting register and giving exception.

Caused by: java.lang.IllegalArgumentException: GrailsVersion snapshot is not in the expected format
            at .grails.datastore.mapping.core.grailsversion.Snapshot.<init>(Snapshot.groovy:49)

I have created a grails project using grails version 6.2.3. After this this added the quartz job dependencies and then create the class for schedule job. Command : grails create-app testApp grails create-job runjob

in the create class added the "println" line to print the date. verified the working using "grails run-app", it is printing the output on console Executing RunJob at Tue Feb 18 12:12:45 EST 2025

now used the "grails war" to generate the war file. When I deploy the war file on tomcat 11 job is not starting. Possibly it is not running because of javax is changed to jakarta in tomcat 11. I tried different combination of dependencies to change the javax to jakarta in build.gradle but none worked. What changes i need to make in my project to build a war file which will work in tomcat 11.

build.gradle

buildscript {
    repositories {
        maven { url "https://plugins.gradle./m2/" }
        maven { url "https://repo.grails./grails/core" }
    }
    dependencies {
        classpath ".grails:grails-gradle-plugin:$grailsGradlePluginVersion"
        classpath "gradle.plugin.github.erdi.webdriver-binaries:webdriver-binaries-gradle-plugin:2.6"
        classpath ".grails.plugins:hibernate5:7.3.0"
        classpath "com.bertramlabs.plugins:asset-pipeline-gradle:3.4.7"
    }
}

version "0.1"
group "jobapp"

apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"war"
apply plugin:".grails.grails-web"
apply plugin:"com.github.erdi.webdriver-binaries"
apply plugin:".grails.grails-gsp"
apply plugin:"com.bertramlabs.asset-pipeline"

repositories {
    mavenCentral()
    maven { url "https://repo.grails./grails/core" }
}

configurations {
    developmentOnly
    runtimeClasspath {
        extendsFrom developmentOnly
    }
}

dependencies {
    developmentOnly(".springframework.boot:spring-boot-devtools")
    compileOnly "io.micronaut:micronaut-inject-groovy"
    console ".grails:grails-console"
    implementation ".springframework.boot:spring-boot-starter-logging"
    implementation ".springframework.boot:spring-boot-starter-validation"
    implementation ".springframework.boot:spring-boot-autoconfigure"
    implementation ".grails:grails-core"
    implementation ".springframework.boot:spring-boot-starter-actuator"
    implementation ".springframework.boot:spring-boot-starter-tomcat"
    implementation ".grails:grails-web-boot"
    implementation ".grails:grails-logging"
    implementation ".grails:grails-plugin-rest"
    implementation ".grails:grails-plugin-databinding"
    implementation ".grails:grails-plugin-i18n"
    implementation ".grails:grails-plugin-services"
    implementation ".grails:grails-plugin-url-mappings"
    implementation ".grails:grails-plugin-interceptors"
    implementation ".grails.plugins:cache"
    implementation ".grails.plugins:async"
    implementation ".grails.plugins:scaffolding"
    implementation ".grails.plugins:hibernate5"
    implementation ".hibernate:hibernate-core:5.6.11.Final"
    implementation ".grails.plugins:events"
    implementation ".grails.plugins:gsp"
    
    implementation '.grails.plugins:quartz:3.0.0'
    implementation ".quartz-scheduler:quartz:2.5.0"
    implementation 'com.mysql:mysql-connector-j:9.2.0'
    
    profile ".grails.profiles:web"
    runtimeOnly ".glassfish.web:el-impl:2.2.1-b05"
    runtimeOnly "com.h2database:h2"
    runtimeOnly ".apache.tomcat:tomcat-jdbc"
    runtimeOnly "javax.xml.bind:jaxb-api:2.3.1"
    runtimeOnly "com.bertramlabs.plugins:asset-pipeline-grails:3.4.7"
    testImplementation "io.micronaut:micronaut-inject-groovy"
    testImplementation ".grails:grails-gorm-testing-support"
    testImplementation ".mockito:mockito-core"
    testImplementation ".grails:grails-web-testing-support"
    testImplementation ".grails.plugins:geb"
    testImplementation ".seleniumhq.selenium:selenium-remote-driver:4.0.0"
    testImplementation ".seleniumhq.selenium:selenium-api:4.0.0"
    testImplementation ".seleniumhq.selenium:selenium-support:4.0.0"
    testRuntimeOnly ".seleniumhq.selenium:selenium-chrome-driver:4.0.0"
    testRuntimeOnly ".seleniumhq.selenium:selenium-firefox-driver:4.0.0"
}

bootRun {
    ignoreExitValue true
    jvmArgs(
        '-Dspring.output.ansi.enabled=always', 
        '-noverify', 
        '-XX:TieredStopAtLevel=1',
        '-Xmx1024m')
    sourceResources sourceSets.main
    String springProfilesActive = 'spring.profiles.active'
    systemProperty springProfilesActive, System.getProperty(springProfilesActive)
}

tasks.withType(GroovyCompile) {
    configure(groovyOptions) {
        forkOptions.jvmArgs = ['-Xmx1024m']
    }
}

tasks.withType(Test) {
    useJUnitPlatform()
}

webdriverBinaries {
    if (!System.getenv().containsKey('GITHUB_ACTIONS')) {
        chromedriver {
            version = '2.45.0'
            fallbackTo32Bit = true
        }
        geckodriver '0.30.0'
    }
}

tasks.withType(Test) {
    systemProperty "geb.env", System.getProperty('geb.env')
    systemProperty "geb.build.reportsDir", reporting.file("geb/integrationTest")
    if (!System.getenv().containsKey('GITHUB_ACTIONS')) {
        systemProperty 'webdriver.chrome.driver', System.getProperty('webdriver.chrome.driver')
        systemProperty 'webdriver.gecko.driver', System.getProperty('webdriver.gecko.driver')
    } else {
        systemProperty 'webdriver.chrome.driver', "${System.getenv('CHROMEWEBDRIVER')}/chromedriver"
        systemProperty 'webdriver.gecko.driver', "${System.getenv('GECKOWEBDRIVER')}/geckodriver"
    }
}


assets {
    minifyJs = true
    minifyCss = true
}

gradle.properties

grailsVersion=6.2.3
grailsGradlePluginVersion=6.2.4
groovyVersion=3.0.23
gorm.version=8.1.2
.gradle.daemon=true
.gradle.parallel=true
.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx1024M

To fix the issue, I changed the dependencies of javax to jakarta, updated all other dependency to latest including spring, i expect it to work but not worked, when deployed, job is not getting started.

Second, I tried tomcat 10. inside to it create a webapps-javaee folder and paste the war file there to upgrade the dependency, in this job is not getting register and giving exception.

Caused by: java.lang.IllegalArgumentException: GrailsVersion snapshot is not in the expected format
            at .grails.datastore.mapping.core.grailsversion.Snapshot.<init>(Snapshot.groovy:49)
Share Improve this question edited yesterday Komal Prasad asked yesterday Komal PrasadKomal Prasad 1252 silver badges9 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

Grails 6.2.3 is on Spring Boot 2.7.18 which supports a max tomcat version of 9.0.x.

https://mvnrepository/artifact/.springframework.boot/spring-boot-dependencies/2.7.18

Grails 7 will be on Spring Boot 3.4.x which supports Tomcat 10.1.x. https://grails./blog/2024-12-23-grails-7-m1.html

https://mvnrepository/artifact/.springframework.boot/spring-boot-dependencies/3.4.0

Grails 8 will likely be the first version to support Tomcat 11.

发布评论

评论列表(0)

  1. 暂无评论