I am new to this and having a hard time understanding this error.
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 1 in XML document from class path resource  is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
People at stackoverflow and other forums have already posted this error and the answers are along the lines: BAD XML, look for white space, etc.
I believe it is not so or I at least do not have a clear understanding of the error message.
To find an answer to this problem I have created another project and purposely inserted a few characters before my prolog (first line of xml if I understood that right.)
The error I get in that case is:
Line 1 in XML document from ServletContext resource [/WEB-INF/classicmodels-servlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
The [/WEB-INF/classicmodels-servlet.xml] tells me exactly where it is and what to look from I know fromContent is not allowed in prolog
XML document from class path resource  is invalid. I have no idea what is going on.
Any help or advice would be appreciated. Thanks in advance!
XML document from class path resource  is invalid.
Note carefully the name of the resource which is invalid. It's empty, right? Notice that when you experimented with invalid XML resources and caused a similar error message, that message told you the name of the XML resource which you modified. So maybe something is getting a resource (from the class path, not from the ServletContext) but not providing a name for that resource.
It's hard for me to point specifically at anything in your configuration, but the web.xml does seem to have something near the end which looks like it's trying to point at XML documents in the class path. Maybe there's some kind of problem there?
Also I suppose you got this message out of a log file? Perhaps other log file entries just before it might provide some context as to what was happening just then?
posted 1 year ago
Here my web.xml. I think you are missing the <init-params> that point to the .xml file, hence, the null resource error.
posted 1 year ago
Here is how I configured my ContextLoadListener:
Whereas, your files are on your classpath. Might want to reconsider that.
might be looking in the classpath relative to the (Spring) class which is trying to read the XML. And since that class is in a package, that wouldn't work. But (still with my speculative assumptions) using an absolute path might fix the problem:
Here's how I think this story begins: Philip started learning Spring by creating a Spring Java app, and configured his Application Context like this:
with the .xml file residing on the classpath (because there is nowhere else to put it).
Then he tried to cross-pollenate a Spring WebMVC app using the same logic, without fully understanding how to configure a "web Application Context".
According to Spring documentation Spring 4.3.7 , on page 156:
You can create ApplicationContext instances declaratively by using, for example, a
ContextLoader. Of course you can also create ApplicationContext instances programmatically
by using one of the ApplicationContext implementations.
You can register an ApplicationContext using the ContextLoaderListener as follows:
The listener inspects the contextConfigLocation parameter. If the parameter does not exist, the
listener uses /WEB-INF/applicationContext.xml as a default. When the parameter does exist,
the listener separates the String by using predefined delimiters (comma, semicolon and whitespace)
and uses the values as locations where application contexts will be searched. Ant-style path patterns
are supported as well. Examples are /WEB-INF/*Context.xml for all files with names ending with
"Context.xml", residing in the "WEB-INF" directory, and /WEB-INF/**/*Context.xml, for all such
files in any subdirectory of "WEB-INF".
The ContextLoaderListener class in web.xml will bootstrap the "web Application Context" via the .xml file(s) in the WEB-INF folder.
So, Paul is correct saying the .xml path is relative to "which Application Context interface is being implemented", and Philip COULD use the classpath, but Spring documentation implies you SHOULD use the WEB-INF folder.
We should throw him a surprise party. It will cheer him up. We can use this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database