0

将 Grails 连接到 Nexmo 插件时出现一些错误。为什么会出现如下错误?任何人都可以解决这些问题吗?

'BuildConfig.groovy' 下面:

grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"

grails.project.fork = [
// configure settings for compilation JVM, note that if you alter the Groovy version forked compilation is required
//  compile: [maxMemory: 256, minMemory: 64, debug: false, maxPerm: 256, daemon:true],

// configure settings for the test-app JVM, uses the daemon by default
test   : [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon: true],
// configure settings for the run-app JVM
run    : [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve: false],
// configure settings for the run-war JVM
war    : [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve: false],
// configure settings for the Console UI JVM
console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256]
]

grails.project.dependency.resolver = "maven" // or ivy
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// uncomment to disable ehcache
// excludes 'ehcache'
}
log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
repositories {
grailsCentral()
mavenLocal()
mavenCentral()
// uncomment the below to enable remote dependency resolution
// from public Maven repositories
//mavenRepo "http://repository.codehaus.org"
//mavenRepo "http://download.java.net/maven/2/"
//mavenRepo "http://repository.jboss.com/maven2/"
}
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
// runtime 'mysql:mysql-connector-java:5.1.27'
}

plugins {
  build ':tomcat:7.0.52.1'
  runtime ':hibernate:3.6.10.10' // ':hibernate4:4.3.4.1' for Hibernate 4
  compile ":rest:0.8"

}
}

'SmsController.groovy' 下面:

package nexmo

class SmsControllerController {

// Inject the service
def nexmoService

def index() {
    def smsResult
    def callResult

    try {
        // Send the message "What's up?" to 1-500-123-4567
        smsResult = nexmoService.sendSms("61451062006", "What's up?")

        System.out.println("Try block message");

    }

        catch (Exception e) {
            // Handle error if failure
            System.out.println("Error: Don't divide a number by zero");
        }
    }
}

以下错误:

context.ContextLoader Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: C
ould not open ServletContext resource [/WEB-INF/applicationContext.xml]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
    ... 4 more
context.GrailsContextLoaderListener Error initializing the application: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundExce
ption: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: C
ould not open ServletContext resource [/WEB-INF/applicationContext.xml]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
    ... 4 more
| Error Forked Grails VM exited with error
4

1 回答 1

1

错误文本表明您webapp/WEB-INF/applicationContext.xml已被删除。要恢复它,使用相同版本的 Grails 创建一个新的空应用程序并从那里复制文件。如果它也丢失了,也复制sitemesh.xml它,以及来自 .tld 的 .tld 文件web-app/WEB-INF/tld

于 2015-10-10T03:52:40.793 回答