- This topic has 4 replies, 2 voices, and was last updated 18 years, 1 month ago by support-snjeza.
-
AuthorPosts
-
Unnsse KhanMemberHello there,
I am experiencing a BeanDefinitionStoreException when I try to invoke a web app that I built using Spring.
My environment:
-JDK 1.5
-Tomcat 5.5.9
-MyEclipse IDE plug-in
-Spring 1.2 Core Libraries (which comes bundled with MyEclipse)
-Spring 1.2 Web Libraries (which comes bundled in with MyEclipse; includes the spring-mvc.jar)
-OS X TigerHere’s some of my code details:
My applicationContext.xml file (located under the src dir):
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="store" class="com.webshop.util.LineItems"> <property name="storeName"> <value>"Sunrise Schwinn"</value> </property> </bean> <bean id="commandLineView" class="com.webshop.view.CommandLineView"> <property name="store"> <ref bean="store"/> </property> </bean> </beans>
My webShop-Servlet.xml file (located under WEB-INF ):
<beans> <bean id="store" class="com.webshop.util.LineItems"> <property name="storeName"> <value>Sunrise Schwinn</value> </property> </bean> <bean id="productsController" class="com.webshop.controller.ProductsController"> <property name="facade"> <ref bean="store"/> </property> </bean> <bean id="editProductController" class="com.webshop.controller.EditProductController"> <property name="facade"> <ref bean="store"/> </property> </bean> <bean id="submitProductController" class="com.webshop.controller.SubmitProductController"> <property name="facade"> <ref bean="store"/> </property> </bean> <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="mappings"> <props> <prop key="/products.products">productsController</prop> <prop key="/editProduct.products">editProductController</prop> <prop key="/newProduct.products">editProductController</prop> <prop key="/submitProduct.products">submitProductController</prop> </props> </property> </bean> </beans>
My web.xml file:
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <servlet> <servlet-name>webShopApp</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>webShopApp</servlet-name> <url-pattern>*.products</url-pattern> </servlet-mapping> </web-app>
I use the exploded package option (hot deploy) when deploying the app. The MyEclipse plug-in gracefully places all the right jar files under /WEB-INF/lib.
Now, when I launch Firefox or Safari and point the browser to: http://localhost:8080/webshop
I receive this error message:
javax.servlet.ServletException: Servlet.init() for servlet webShopApp threw exception org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744) org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) java.lang.Thread.run(Thread.java:613) root cause org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/webShopApp-servlet.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/webShopApp-servlet.xml] org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:180) org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:148) org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:129) org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:145) org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:126) org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94) org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:89) org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:262) org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:139) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:306) org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:251) org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:220) org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:112) javax.servlet.GenericServlet.init(GenericServlet.java:211) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744) org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) java.lang.Thread.run(Thread.java:613) note
This error report is really annoying! :banghead:
Any suggestions, help, and tips are greatly appreciated!
Many, many thanks!
Unnsse KhanMemberI made a mistake in the original posting:
It happens when I point it to http://localhost:8080/webshop/products.products
not
when I point it to http://localhost:8080/webshop (which I posted in the first message).
How can I edit mistakes that I made after post?
support-snjezaMemberuntz ,
You have chosen the name webShopApp for your servlet and webShop-Servlet.xml for your context file.
Rename webShop-Servlet.xml to webShopApp-servlet.xml.Regards,
Snjeza
Unnsse KhanMemberSnjeza:
Thank you for the response…
I tried your suggestion and it still doesn’t work…
Received a new error message:
javax.servlet.ServletException: Servlet.init() for servlet webShopApp threw exception org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744) org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) java.lang.Thread.run(Thread.java:613) root cause org.springframework.beans.factory.BeanDefinitionStoreException: Line 1 in XML document from ServletContext resource [/WEB-INF/webShopApp-servlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException: Document root element "beans", must match DOCTYPE root "null". org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:229) org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:173) org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:148) org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:129) org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:145) org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:126) org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94) org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:89) org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:262) org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:139) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:306) org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:251) org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:220) org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:112) javax.servlet.GenericServlet.init(GenericServlet.java:211) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744) org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) java.lang.Thread.run(Thread.java:613)
I renamed webshop-Servlet.xml to webshopApp-servlet.xml and as you can see it threw this new error message of:
"org.springframework.beans.factory.BeanDefinitionStoreException: Line 1 in XML document from ServletContext resource [/WEB-INF/webShopApp-servlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException: Document root element "beans", must match DOCTYPE root "null"."
Inside the webShopApp-servlet.xml:
<beans> <bean id="store" class="com.webshop.util.LineItems"> <property name="storeName"> <value>Sunrise Schwinn</value> </property> </bean> <bean id="productsController" class="com.webshop.controller.ProductsController"> <property name="facade"> <ref bean="store"/> </property> </bean> <bean id="editProductController" class="com.webshop.controller.EditProductController"> <property name="facade"> <ref bean="store"/> </property> </bean> <bean id="submitProductController" class="com.webshop.controller.SubmitProductController"> <property name="facade"> <ref bean="store"/> </property> </bean> <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="mappings"> <props> <prop key="/products.products">productsController</prop> <prop key="/editProduct.products">editProductController</prop> <prop key="/newProduct.products">editProductController</prop> <prop key="/submitProduct.products">submitProductController</prop> </props> </property> </bean> </beans>
Does anyone know what’s wrong?
support-snjezaMemberuntz,
Sorry, somebody made the mistake to close your post.
Please, add DOCTYPE declaration to xml file :<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
Spring can’t validate xml file without this declaration.
Regards,
Snjeza -
AuthorPosts