将Grails连接到Nexmo插件时出错

时间:2015-10-10 01:40:06

标签: grails plugins nexmo

将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

1 个答案:

答案 0 :(得分:1)

错误文字表示您的webapp/WEB-INF/applicationContext.xml已被删除。要恢复它,请使用相同版本的Grails创建一个新的空应用程序,然后从那里复制文件。如果还缺少sitemesh.xml,也请复制web-app/WEB-INF/tld中的.tld文件。