Announcement Announcement Module
Collapse
No announcement yet.
cvc-elt.1: Cannot find the declaration of element 'beans' Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • cvc-elt.1: Cannot find the declaration of element 'beans'

    Problem revisited: I found a member with the exact same problem. I tried what Bram explained at http://bram.jteam.nl/index.php/2007/...jax-made-easy/ but I get (I'm really annoyed after HOURS of wasted time) this

    Code:
    org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 10 in XML document from ServletContext resource [/WEB-INF/spring-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.
    Caused by: 
    org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.
    My spring-context.xml is this

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    
    <beans 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    		xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
    		xsi:schemaLocation="
    		http://www.directwebremoting.org/schema/spring-dwr
    		http://www.directwebremoting.org/sch...ng-dwr-2.0.xsd
    		">
    
    	<bean id="myService" class="example.MyServiceImpl">
    		<dwr:remote javascript="MyAjaxService" />
    		<property name="dao" ref="myDao" />
    
    	</bean>
    
    </beans>
    It just doesn't seem to find what "beans" are. If I use the DTD instead (oldschool) it works, but then DWR isn't working ofcourse...

    PLEASE if anyone knows what I'm doing wrong...?

  • #2
    You have to add the follow line

    I saw your application context config file, you have missed the follow line at beans tag

    Code:
    xmlns="http://www.springframework.org/schema/beans"
    Put it into your file, and re-try it.

    Comment


    • #3
      any updates on this item - beans not found

      I am getting similar issue. Any ideas on what this could be?


      2007-04-03 13:39:11.481::WARN: Nested in org.springframework.beans.factory.xml.
      XmlBeanDefinitionStoreException: Line 4 in XML document from ServletContext reso
      urce [/WEB-INF/rentaBikeApp-servlet.xml] is invalid; nested exception is org.xml
      .sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans
      '.:

      Comment


      • #4
        The solution in the previous post should solve your problem. If you are still having problems posting the applicationContext is always a good idea, in [ code] [ /code] tags.

        Comment


        • #5
          could it be because you have doctype AND xmlns?
          i'd remove the doctype..

          Comment


          • #6
            You should basically have something similar to this.
            Code:
            <?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-2.0.xsd">
                   
                ...
                   
            </beans>

            Comment


            • #7
              I'm migrating from Spring 1.2 to Spring 2.0 and i had to deal with this issue too.
              This thread has helped me but the trick is that at the page 30 of the Spring Framework 2.0.4 Reference Manual (PDF format), the given example of the beans configuration file header is

              Code:
              <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/spring-beans-2.0.xsd">
              And that doesn't work.

              So I just point out this manual issue and hope it will help people if it's corrected.

              Comment


              • #8
                Have you raised a JIRA issue for this?

                Comment


                • #9
                  I didn't find an existing issue about this so I created one :

                  http://opensource.atlassian.com/proj...rowse/SPR-3372

                  Comment


                  • #10
                    That was quick, it's fixed already! Those guys do work quick .

                    Comment


                    • #11
                      cvc-elt.1: Cannot find the declaration of element 'beans'

                      Hi all,

                      Please help me to solve this issue.

                      My beans.xml is ,

                      Code:
                      <?xml version="1.0" encoding="windows-1252" ?>
                      <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-2.5.xsd">
                          <!-- injecting built-in vals sample -->
                          <bean id="injectSimple" class="SpringInjectSimpleValue">
                              <property name="name">
                                  <value>John Smith</value>
                              </property>
                              <property name="age">
                                  <value>35</value>
                              </property>
                              <property name="height">
                                  <value>1.78</value>
                              </property>
                              <property name="isProgrammer">
                                  <value>true</value>
                              </property>
                              <property name="ageInSeconds">
                                  <value>1103760000</value>
                              </property>
                          </bean>
                      </beans>
                      My Issue is,


                      Apr 7, 2008 4:16:25 PM org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions
                      INFO: Loading XML bean definitions from file [C:\DevTools\jdevstudio10133\jdev\mywork\TestApp\Te stProject\beans1.xml]
                      Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefin itionStoreException: Line 7 in XML document from file [C:\DevTools\jdevstudio10133\jdev\mywork\TestApp\Te stProject\beans1.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.
                      at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.doLoadBeanDefinitions(XmlBeanDefinitio nReader.java:389)
                      at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:327)
                      at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:295)
                      at org.springframework.beans.factory.xml.XmlBeanFacto ry.<init>(XmlBeanFactory.java:73)
                      at org.springframework.beans.factory.xml.XmlBeanFacto ry.<init>(XmlBeanFactory.java:61)
                      at SpringInjectSimpleValue.main(SpringInjectSimpleVal ue.java:14)
                      Caused by: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.
                      at com.sun.org.apache.xerces.internal.util.ErrorHandl erWrapper.createSAXParseException(ErrorHandlerWrap per.java:236)
                      at com.sun.org.apache.xerces.internal.util.ErrorHandl erWrapper.error(ErrorHandlerWrapper.java:172)
                      at com.sun.org.apache.xerces.internal.impl.XMLErrorRe porter.reportError(XMLErrorReporter.java:382)
                      at com.sun.org.apache.xerces.internal.impl.XMLErrorRe porter.reportError(XMLErrorReporter.java:316)
                      at com.sun.org.apache.xerces.internal.impl.xs.XMLSche maValidator.handleStartElement(XMLSchemaValidator. java:1944)
                      at com.sun.org.apache.xerces.internal.impl.xs.XMLSche maValidator.startElement(XMLSchemaValidator.java:7 05)
                      at com.sun.org.apache.xerces.internal.impl.XMLNSDocum entScannerImpl.scanStartElement(XMLNSDocumentScann erImpl.java:330)
                      at com.sun.org.apache.xerces.internal.impl.XMLNSDocum entScannerImpl$NSContentDispatcher.scanRootElement Hook(XMLNSDocumentScannerImpl.java:779)
                      at com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImpl$FragmentContentDispatcher.dis patch(XMLDocumentFragmentScannerImpl.java:1794)
                      at com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImpl.scanDocument(XMLDocumentFragm entScannerImpl.java:368)
                      at com.sun.org.apache.xerces.internal.parsers.XML11Co nfiguration.parse(XML11Configuration.java:834)
                      at com.sun.org.apache.xerces.internal.parsers.XML11Co nfiguration.parse(XML11Configuration.java:764)
                      at com.sun.org.apache.xerces.internal.parsers.XMLPars er.parse(XMLParser.java:148)
                      at com.sun.org.apache.xerces.internal.parsers.DOMPars er.parse(DOMParser.java:250)
                      at com.sun.org.apache.xerces.internal.jaxp.DocumentBu ilderImpl.parse(DocumentBuilderImpl.java:292)
                      at org.springframework.beans.factory.xml.DefaultDocum entLoader.loadDocument(DefaultDocumentLoader.java: 75)
                      at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.doLoadBeanDefinitions(XmlBeanDefinitio nReader.java:381)
                      ... 5 more
                      Process exited with exit code 1.
                      Thanks in advance.

                      Vaswin

                      Comment


                      • #12
                        Solved : cvc-elt.1: Cannot find the declaration of element 'beans'.

                        Sorry friends,

                        Code:
                             public static void main(String[] args) {
                                BeanFactory factory = new XmlBeanFactory(new FileSystemResource(
                                        "beans1.xml"));
                                SpringInjectSimpleValue simple = (SpringInjectSimpleValue)factory.getBean("injectSimple");
                                System.out.println(simple);
                            }
                        I have given wrong xml to XmlBeanFactory. Now its working fine. Jdeveloper missed the line to include

                        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-2.5.xsd"

                        Thanks

                        Vaswin

                        Comment


                        • #13
                          Also encountered this

                          Turns out from multiple netbeans upgrades and spring versions some of the spring xml files had 2.0 and others had 2.5. I was running with spring-2.0.8 for this version of the product. On production server where we saw this issue I was getting :

                          Code:
                          org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.
                          	at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
                          	at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
                          	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
                          	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
                          	at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
                          	at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
                          	at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
                          	at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
                          	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
                          	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
                          	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
                          	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
                          	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
                          	at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
                          	at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
                          	at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:76)
                          	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:361)
                          	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:313)
                          	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:290)
                          	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:131)
                          	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:147)
                          	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:171)
                          	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:145)
                          	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:130)
                          	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:90)
                          	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:468)
                          	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:363)
                          	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:313)
                          	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:290)
                          	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:131)
                          	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:147)
                          	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:171)
                          	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:145)
                          	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:130)
                          	at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:90)
                          	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:468)
                          	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:363)
                          	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:313)
                          	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:290)
                          	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:131)
                          	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:147)
                          	at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
                          	at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92)
                          	at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:101)
                          	at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:389)
                          	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:324)
                          	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:245)
                          	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:188)
                          	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
                          	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3827)
                          	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4343)
                          	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)
                          	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
                          	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
                          	at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:277)
                          	at org.apache.catalina.core.StandardHost.install(StandardHost.java:832)
                          	at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:625)
                          	at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:431)
                          	at org.apache.catalina.startup.HostConfig.start(HostConfig.java:983)
                          	at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:349)
                          	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
                          	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1091)
                          	at org.apache.catalina.core.StandardHost.start(StandardHost.java:789)
                          	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)
                          	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478)
                          	at org.apache.catalina.core.StandardService.start(StandardService.java:480)
                          	at org.apache.catalina.core.StandardServer.start(StandardServer.java:2313)
                          	at org.apache.catalina.startup.Catalina.start(Catalina.java:556)
                          	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                          	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                          	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                          	at java.lang.reflect.Method.invoke(Method.java:597)
                          	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:287)
                          	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:425)
                          The prod environment had very strict firewall rules, so I suspect jaxp could not callout to springframework.org and validate 2.5 xsd references. Dev, integration and workstation would have been able to since they are not as secure. Changed the all to 2.0 and worked off pat.

                          Comment


                          • #14
                            Throughout the whole discussion above there was no indication of what the correct xmlns uri should be:

                            This works
                            Code:
                            <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-2.0.xsd">

                            Comment


                            • #15
                              the URI was always correct. It was just an issue of using the spring 2.5 jar with references to 2.0 in the URI

                              Comment

                              Working...
                              X