在使用myfaces-jsf的时候,如果配置的faces-config.xml在服务器启动时报错,需要修改faces-config.xml的头部内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE faces-config
PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
                            "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
<faces-config>

问题如下:

严重: Parse Error at line 2 column 14: Document is invalid: no grammar found.
org.xml.sax.SAXParseException: Document is invalid: no grammar found.
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSA
ParseException(ErrorHandlerWrapper.java:236)
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Er
orHandlerWrapper.java:172)
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError
XMLErrorReporter.java:382)
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError
XMLErrorReporter.java:316)
        at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.sca
StartElement(XMLNSDocumentScannerImpl.java:177)
        at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSC
ntentDispatcher.scanRootElementHook(XMLNSDocumentScannerImpl.java:779)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerIm
l$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1794)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerIm
l.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(
ML11Configuration.java:834)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(
ML11Configuration.java:764)
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser
java:148)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(A
stractSAXParser.java:1242)
        at org.apache.commons.digester.Digester.parse(Digester.java:1572)
        at org.apache.myfaces.config.impl.digester.DigesterFacesConfigUnmarshal
erImpl.getFacesConfig(DigesterFacesConfigUnmarshallerImpl.java:183)
        at org.apache.myfaces.config.FacesConfigurator.feedClassloaderConfigura
ions(FacesConfigurator.java:251)
        at org.apache.myfaces.config.FacesConfigurator.configure(FacesConfigura
or.java:129)
        at org.apache.myfaces.webapp.StartupServletContextListener.initFaces(St
rtupServletContextListener.java:69)
        at org.apache.myfaces.webapp.StartupServletContextListener.contextIniti
lized(StartupServletContextListener.java:52)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardConte
t.java:3764)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:
216)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBas
.java:760)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:7
0)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544

        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:825

        at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:71
)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:49
)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.jav
:311)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecyc
eSupport.java:120)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022

        at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014

        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:44
)
        at org.apache.catalina.core.StandardService.start(StandardService.java:
48)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:70
)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcce
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)