Pregunta

At some point in making a Web Application using MyFaces, my faces-config.xml and web.xml started fighting but seemingly long after I'd made any changes. I have been experimenting with different jars and different configurations for both but can't get anything to install correctly. Although I feel like I've tried everything (except the solution), here's one instance of the code:

web.xml:

    <?xml version="1.0" encoding="UTF-8"> 
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<session-config>
    <session-timeout>
        30
    </session-timeout>
</session-config>
<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

intro of faces-config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">

and I am receiving this error:

SEVERE [org.apache.commons.digester.Digester] (MSC service thread 1-2) Parse Error at line 2 column 14: 
Document is invalid: no grammar found.: org.xml.sax.SAXParseException: Document is invalid: no grammar found.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:196)
at org.apache.xerces.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:132)
at org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:390)
at org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:322)
at org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:281)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:136)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(XMLNSDocumentScannerImpl.java:733)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1754)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:324)
at org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:845)
at org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:768)
at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:108)
at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1196)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:555)
at org.apache.commons.digester.Digester.parse(Digester.java:1745) [commons-digester-1.8.jar:]
at org.apache.myfaces.config.impl.digester.DigesterFacesConfigUnmarshallerImpl.getFacesConfig(DigesterFacesConfigUnmarshallerImpl.java:197) [myfaces-impl-1.1.8.jar:]

and also:

    SEVERE [org.apache.commons.digester.Digester] (MSC service thread 1-2) Parse Error at line 2 column 14: 
Document root element "faces-config", must match DOCTYPE root "null".: org.xml.sax.SAXParseException: Document root element "faces-config", must match DOCTYPE root "null".
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:196)

I am going crazy over why this isn't working. Is it obvious why and I'm missing it? Or is the problem not with these files so I should try to change my jars? I am deploying with JBOSS 7. Thank you! Thank you!

¿Fue útil?

Solución

I'm not experience in MyFaces at all, but from looking over some of the other posts I've seen online (and because you have some whitespace at the beginning of your initial XML), I would make sure there aren't any hidden characters or extra whitespace in your XML document that could cause issues.

Additionally, I would perhaps see if the values in the root element of your faces-config.xml are correct. Specifically, I would check out the values for your xsi:schemaLocation attribute. I'm not terribly familiar with how that particular XML parser works, but judging from your exceptions it may be trying to validate schema with those provided URLs and failing. It looks like you have two URLs specified, which may not be valid markup. The second URL does in fact resolve to a valid XSD definition file. Try limiting it to that one URL and see if that changes anything.

Hope that helps!

EDIT: Turns out I may have been misinformed. The xsi:schemaLocation element can have two values separated by a space. The second needs to be a valid schema file. I would check that they are in fact properly spaced. It looks like from your answer they may be, but it's worth a check.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top