File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

nested exception is org.xml.sax.SAXParseException: Attribute "value" must be declared

 
Tulip Jain
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys... i m new to this Spring framework....

I m facing this ERROR nested exception is org.xml.sax.SAXParseException: Attribute "value" must be declared for element type "property".

Please help me out ... in my spring-servlet.xml ...

My spring-servlet.xml is :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>


<!-- Maps flow requests from DispatcherServlet to flowController -->

<bean id="simpleUrlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<value>
/index.html=loginController
</value>
</property>
</bean>

<!-- Mappings required for the loginFormController are-->

<bean id="loginConroller" class="loginFormController">
<property name="commandName" value="login"></property>
<property name="commandClass" value="Login"></property>
<property name="formView"><value>index</value></property>
<property name="successView"><value>success</value></property>
</bean>



<!-- Maps a logical view name to a physical resource -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>

</beans>


& my controller class is:

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;

public class loginFormController extends SimpleFormController {

@Override
protected ModelAndView onSubmit(Object command) throws Exception {

Login log=(Login)command;

String uname=log.getUsername();

ModelAndView mav= new ModelAndView(getSuccessView());

mav.addObject("uname",uname);
//Add an object to the model.
//modelName - name of the object to add to the model
//modelObject - object to add to the model. May not be null.

return mav;
}

}

Appreciate your response----
 
Paul Clapham
Sheriff
Pie
Posts: 20171
24
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error message says that your "property" element must have a "value" attribute. But in your example:

it doesn't have a "value" attribute. (Which is of course exactly what the error message says.)

You might want to spend a couple of minutes learning about XML, in particular what does the term "attribute" mean in XML.
 
Tulip Jain
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul for your reply ....

i forgot to mention that the error is in the below "value" tag....

<bean id="loginConroller" class="loginFormController">
line 20 <property name="commandName" value="login"></property>
<property name="commandClass" value="Login"></property>
<property name="formView"><value>index</value></property>
<property name="successView"><value>success</value></property>
</bean>

for ease, here is the actual error .....

org.springframework.beans.factory.BeanDefinitionStoreException: Line 20 in XML document from ServletContext resource [/WEB-INF/polling-servlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException: Attribute "value" must be declared for element type "property".
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:135)
org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:144)
org.springframework.context.support.AbstractXmlApplicationContext.refreshBeanFactory(AbstractXmlApplicationContext.java:79)
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:249)
org.springframework.web.context.support.XmlWebApplicationContext.refresh(XmlWebApplicationContext.java:131)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:281)
org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:228)
org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:199)
org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:103)
javax.servlet.GenericServlet.init(GenericServlet.java:212)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Thread.java:722)


Thanks ....
 
Paul Clapham
Sheriff
Pie
Posts: 20171
24
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would be more likely to believe that the error referred to the lines just below, which in fact do not have "value" attributes. I suggest that if you fix the lines which don't have "value" attributes then you won't get error messages. But pointing at a document which obviously does have errors and saying that the error message doesn't apply because it appears to point at one line which doesn't have an error, that's just wasting time. Fix the errors already.
 
Tulip Jain
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thnaks for the guidance Paul ... I will try to fix this out ....
 
Saifuddin Merchant
Ranch Hand
Posts: 607
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both the nested <value> node or the "value" attribute are valid formats supported by Spring.
http://static.springsource.org/spring/docs/2.0.x/reference/beans.html#beans-value-element


My suspect would be the line breaks between the value attributes in this bean



I also suggest using the XSD schema instead of the doctype.

 
Tulip Jain
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Everyone Guys

error was resolved actually there were 2 problem one was in the jar files.... i was using 2 versions of a same jar files ..... when i replaced it by using common-logging.jar. jstl.jar, spring.jar & standard.jar files in my lib folder it worked...

Also when i replaced the following the code

<bean id="loginConroller" class="loginFormController">
<property name="commandName" value="login"></property>
<property name="commandClass" value="Login"></property>

<property name="formView"><value>index</value></property>
<property name="successView"><value>success</value></property>
</bean>

<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>


by-


<property name="commandName"><value>login</value></property>
<property name="commandClass"><value>Login</value></property>

<property name="prefix"><value>/WEB-INF/jsp/</value></property>
<property name="suffix"><value>.jsp</value></property>


IT WORKED..... dont know wats d problem!!!... in my opinion both are valid formart in spring....!!!
 
Paul Clapham
Sheriff
Pie
Posts: 20171
24
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sam Mercs wrote:Both the nested <value> node or the "value" attribute are valid formats supported by Spring.


In which case the error message (which explicitly says that an attribute is missing) is seriously misleading.
 
Tulip Jain
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya... very true .....its very hard to find....
 
Saifuddin Merchant
Ranch Hand
Posts: 607
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:
Sam Mercs wrote:Both the nested <value> node or the "value" attribute are valid formats supported by Spring.


In which case the error message (which explicitly says that an attribute is missing) is seriously misleading.


I know the format is supported in 2.5 version onwards, not so sure about Spring 2.0. Maybe it's not supported in those jars which is why that particular message shows up. Wrong jar issues (class path issues) are hard to debug but doesn't mean that message is really misleading ...
 
Paul Clapham
Sheriff
Pie
Posts: 20171
24
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to clarify: I meant to say that I would interpret that message about an "attribute" which wasn't declared to mean that an XML attribute was necessary. That would imply to me that a child element -- which is not an attribute in XML -- is unacceptable. It's bad enough that we have people working with XML who haven't even read the one-page summary and who don't know what an attribute is (not you, I hasten to say), we don't need people writing error messages which muddy the waters.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic