Spring XML Configuration Error:The processing instruction target matching '[xX][mM][lL]' not allowed
I'm working on a Spring application and encountering an error when trying to load my application context from an XML configuration file. The error message is as follows:
Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 3 in XML document from class path resource [in/sp/resources/applicationContext.xml] is invalid
Caused by: org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 6; The processing instruction target matching "[xX][mM][lL]" is not allowed.
Here is the relevant part of my applicationContext.xml file:
<?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 class="in.sp.beans.Student" id="stdId">
<property name="rollno" value="101" />
<property name="name" value="Karan" />
<property name="email" value="[email protected]" />
</bean>
</beans>
I've ensured that there are no spaces or characters before the XML declaration, and the file is saved with UTF-8 encoding. The file is located in src/main/resources, and I'm loading it using:
ApplicationContext context = new ClassPathXmlApplicationContext("in/sp/resources/applicationContext.xml");
I've double-checked the file path and classpath configuration, but the error persists. Could anyone help me identify what might be causing this issue or suggest further troubleshooting steps?
1 Reply
⌛
This post has been reserved for your question.
Hey @CodeForgeNet! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.