在 tomcat 中部署 Grails 应用程序战争时与 spring/resources.xml 相关的问题
我在 Grails 1.3.7 中开发了一个应用程序(名为 CBR)。当我使用“grails run-app”或“grails run-app prod”运行它时,它工作正常。然而,当我使用“grails war”命令创建一个战争,然后在 Tomcat 6.0.32 中部署这个战争时,我看到以下异常:
Sep 22, 2011 1:55:57 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive CBR.war
context.ContextLoader Context initialization failed
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 1 in
XML document from ServletContext resource [/WEB-INF/spring/resources.xml] is in
valid; nested exception is org.xml.sax.SAXParseException: Premature end of file.
at grails.spring.BeanBuilder.invokeBeanDefiningClosure(BeanBuilder.java:723)
at grails.spring.BeanBuilder.beans(BeanBuilder.java:573)
at grails.spring.BeanBuilder.invokeMethod(BeanBuilder.java:519)
Caused by: org.xml.sax.SAXParseException: Premature end of file.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:174)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:388)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1414)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:1059)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:235)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)
... 3 more
Sep 22, 2011 1:57:48 PM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Sep 22, 2011 1:57:48 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/CBR] startup failed due to previous errors
尽管该项目已完全解压。我检查了conf/spring/resources.xml ...它是空的。
我已经准备好了与Tomcat中的war部署问题类似的所有线程,但无法解决。
以下是我的 config.groovy 文件中的代码:
environments {
production {
grails.serverURL = "http://localhost:8080/${appName}"
}
development {
grails.serverURL = "http://localhost:8080/${appName}/auth"
}
test {
grails.serverURL = "http://localhost:8080/${appName}"
}
}
并且,来自 Datasource.groovy 文件:
environments {
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop','update'
url = "jdbc:mysql://localhost:3306/cbr?autoreconnect=true"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://localhost:3306/cbr?autoreconnect=true"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://localhost:3306/cbr_prod?autoreconnect=true"
}
}
}
以及 application.properties 文件中的一些更多详细信息:
app.grails.version=1.3.7
app.name=CBR
app.servlet.version=2.4
app.version=0.1
plugins.autotranslate=0.3
plugins.hibernate=1.3.7
plugins.message-reports=0.1
plugins.navigation=1.2
plugins.richui=0.8
plugins.shiro=1.1.3
plugins.tomcat=1.3.7
plugins.xfire=0.8.3
我花了过去 2 天来解决这个问题。请帮助我,我花了 1 个月来开发这个应用程序。
I have developed an application (named CBR) in Grails 1.3.7. When i run it with "grails run-app" or "grails run-app prod" it works fine. However when i create a war using "grails war" command and then deploy this war in Tomcat 6.0.32 i see following exception:
Sep 22, 2011 1:55:57 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive CBR.war
context.ContextLoader Context initialization failed
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 1 in
XML document from ServletContext resource [/WEB-INF/spring/resources.xml] is in
valid; nested exception is org.xml.sax.SAXParseException: Premature end of file.
at grails.spring.BeanBuilder.invokeBeanDefiningClosure(BeanBuilder.java:723)
at grails.spring.BeanBuilder.beans(BeanBuilder.java:573)
at grails.spring.BeanBuilder.invokeMethod(BeanBuilder.java:519)
Caused by: org.xml.sax.SAXParseException: Premature end of file.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:174)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:388)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1414)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:1059)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:235)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)
... 3 more
Sep 22, 2011 1:57:48 PM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Sep 22, 2011 1:57:48 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/CBR] startup failed due to previous errors
Although the project was fully unpacked. I have checked conf/spring/resources.xml ... its empty.
I have ready all the threads similar to war deployment problem in Tomcat, but was unable to sort it out.
Following is the code from my config.groovy file:
environments {
production {
grails.serverURL = "http://localhost:8080/${appName}"
}
development {
grails.serverURL = "http://localhost:8080/${appName}/auth"
}
test {
grails.serverURL = "http://localhost:8080/${appName}"
}
}
And, from Datasource.groovy file:
environments {
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop','update'
url = "jdbc:mysql://localhost:3306/cbr?autoreconnect=true"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://localhost:3306/cbr?autoreconnect=true"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://localhost:3306/cbr_prod?autoreconnect=true"
}
}
}
And some more detail from application.properties file:
app.grails.version=1.3.7
app.name=CBR
app.servlet.version=2.4
app.version=0.1
plugins.autotranslate=0.3
plugins.hibernate=1.3.7
plugins.message-reports=0.1
plugins.navigation=1.2
plugins.richui=0.8
plugins.shiro=1.1.3
plugins.tomcat=1.3.7
plugins.xfire=0.8.3
I have spent last 2 days to sort out the issue. Please help me, it took me 1 month to develop this application.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能不是一个很好的答案,但在你把自己绑在一个结之前你绝对应该尝试一下......
当我遇到明显应该起作用的问题时,我首先不信任的是我的构建状态和状态我的机器的配置。
由于您还没有完成完整的构建-部署周期,因此您可以确保它完全适合您的配置。
构建一个简单的 Hello World grails 应用程序,生成 war 文件并部署它。如果可行,我将开始添加插件和配置更改,看看其中是否有任何问题。花费的时间不应超过 20 分钟。
祝你好运
This may not be much of an answer, but something you should definitely try before you tie yourself in a knot...
The first things I mistrust when I run into issues where something should obviously work, are the state of my build and the state of my machine's configuration.
Since you haven't gone through the complete build-deploy cycle yet, you might make sure that it would work at all with your configuration.
Build a simple Hello World grails app, generate the war file and deploy it. If that works, I'd start adding plugins and config changes to see if any of these break anything. Shouldn't take you more than 20 minutes.
Good Luck