1
前兩個文件是我認爲會導致錯誤的'SmsController.groovy'和'applicationContext.xml'。連接到短信插件的Grails錯誤
'SmsController.groovy':
package nexmo
import grails.plugin.nexmo.NexmoException
class SmsControllerController {
// Inject the service
def nexmoService
def smsResult
def index() {
try {
// Send the message "What's up?" to 1-500-123-4567
smsResult = nexmoService.sendSms("61451062006", "What's up?")
}
catch (NexmoException e) {
// Handle error if failure
}
}
}
'的applicationContext.xml':
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="grailsApplication" class="org.codehaus.groovy.grails.commons.GrailsApplicationFactoryBean">
<description>Grails application factory bean</description>
<property name="grailsDescriptor" value="/WEB-INF/grails.xml" />
</bean>
<bean id="pluginManager" class="org.codehaus.groovy.grails.plugins.GrailsPluginManagerFactoryBean">
<description>A bean that manages Grails plugins</description>
<property name="grailsDescriptor" value="/WEB-INF/grails.xml" />
<property name="application" ref="grailsApplication" />
</bean>
<bean id="grailsConfigurator" class="org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator">
<constructor-arg>
<ref bean="grailsApplication" />
</constructor-arg>
<property name="pluginManager" ref="pluginManager" />
</bean>
<bean id="characterEncodingFilter" class="org.springframework.web.filter.CharacterEncodingFilter">
<property name="encoding">
<value>utf-8</value>
</property>
</bean>
<bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean" />
下面是複製後,我發現了錯誤來自新應用的文件。 (applicationContext.xml中,sitemesh.xml &一些.TLD文件):
context.ContextLoader Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsApplication' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; ne
sted exception is org.codehaus.groovy.grails.exceptions.GrailsConfigurationException: Class not found loading Grails application: nexmo.SmsController
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: org.codehaus.groovy.grails.exceptions.GrailsConfigurationException: Class not found loading Grails application: nexmo.SmsController
... 4 more
Caused by: java.lang.ClassNotFoundException: nexmo.SmsController
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
... 4 more
context.GrailsContextLoaderListener Error initializing the application: Error creating bean with name 'grailsApplication' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init me
thod failed; nested exception is org.codehaus.groovy.grails.exceptions.GrailsConfigurationException: Class not found loading Grails application: nexmo.SmsController
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsApplication' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; ne
sted exception is org.codehaus.groovy.grails.exceptions.GrailsConfigurationException: Class not found loading Grails application: nexmo.SmsController
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: org.codehaus.groovy.grails.exceptions.GrailsConfigurationException: Class not found loading Grails application: nexmo.SmsController
... 4 more
Caused by: java.lang.ClassNotFoundException: nexmo.SmsController
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
... 4 more
| Error Forked Grails VM exited with error
謝謝。我解決了這個問題。 –
我能夠去'http:// localhost:8080/nexmo'。但是,它顯示如下:HTTP狀態404 - 「/WEB-INF/grails-app/views/index.gsp」未找到。 –
這就像一個洋蔥,你剝離的每一層揭示更多的底下。是否存在'grails-app/views/index.gsp'?如果沒有,創建它。和以前一樣,您可以通過使用相同版本的Grails創建一個新應用程序並從該應用程序複製該應用程序,從而獲得爲新應用程序創建的默認文件。我想你會繼續有這樣的問題,因爲它看起來像很多重要的文件已被刪除。您可能應該創建一個新應用程序,並將與Nexmo相關的代碼和文件複製到該應用程序中,而不是一次一個地修復所有這些人爲問題。 –