Page 3 of 3 FirstFirst 123
Results 21 to 23 of 23

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

  1. #21
    Join Date
    Feb 2011
    Posts
    2

    Default 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 id="CustomerBean" class="com.vaannila.Customer">
    <property name="Person" ref="PersonBean"></property>
    </bean>

    <bean id="PersonBean" class="com.vannila.Person">
    <property name="name" value="rosaline"></property>
    <property name="address" value="Bhubaneswar"></property>
    <property anme="age" value="24"></property>
    </bean>
    </beans>

  2. #22
    Join Date
    Apr 2011
    Posts
    6

    Default

    Hello!
    I have the same problem. My xml is like:
    <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.xsd">
    <bean>
    <property name="mappings">
    <value>
    /**/ZB_app.html=userController
    </value>
    </property>
    </bean>
    <bean name="userController" class="main.java.com.gwt.app.server.GreetingServic eImpl">
    <property name="remoteService">
    <bean class="main.java.com.gwt.app.server.GreetingServic eImpl">
    <constructor-arg index="0" ref="input" />
    <constructor-arg index="1" ref="input2" />
    </bean>
    </property>
    </bean>
    </beans>
    HTML Code:
    [HTML]
    [/HTML]
    </code>
    And I receive the error message;
    <code>
    27-abr-2011 11:44:27 org.springframework.web.context.ContextLoader initWebApplicationContext
    INFO: Root WebApplicationContext: initialization started
    27-abr-2011 11:44:27 org.springframework.context.support.AbstractApplic ationContext prepareRefresh
    INFO: Refreshing Root WebApplicationContext: startup date [Wed Apr 27 11:44:27 CEST 2011]; root of context hierarchy
    27-abr-2011 11:44:27 org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions
    INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/Gwtapp-servlet.xml]
    Starting Jetty on port 8888
    [WARN] Failed startup of context com.google.gwt.dev.shell.jetty.JettyLauncher$WebAp pContextWithReload@3dc5d6{/,E:\eclipse\ZB_app\war}
    org.springframework.beans.factory.xml.XmlBeanDefin itionStoreException: Line 1 in XML document from ServletContext resource [/WEB-INF/Gwtapp-servlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.
    27-abr-2011 11:44:27 org.springframework.web.context.ContextLoader initWebApplicationContext
    GRAVE: Context initialization failed
    org.springframework.beans.factory.xml.XmlBeanDefin itionStoreException: Line 1 in XML document from ServletContext resource [/WEB-INF/Gwtapp-servlet.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:396)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:334)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:302)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:174)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:209)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:180)
    at org.springframework.web.context.support.XmlWebAppl icationContext.loadBeanDefinitions(XmlWebApplicati onContext.java:125)
    at org.springframework.web.context.support.XmlWebAppl icationContext.loadBeanDefinitions(XmlWebApplicati onContext.java:94)
    at org.springframework.context.support.AbstractRefres hableApplicationContext.refreshBeanFactory(Abstrac tRefreshableApplicationContext.java:131)
    at org.springframework.context.support.AbstractApplic ationContext.obtainFreshBeanFactory(AbstractApplic ationContext.java:509)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:427)
    at org.springframework.web.context.ContextLoader.crea teWebApplicationContext(ContextLoader.java:294)
    at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:215)
    at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 47)
    at org.mortbay.jetty.handler.ContextHandler.startCont ext(ContextHandler.java:543)
    at org.mortbay.jetty.servlet.Context.startContext(Con text.java:136)
    at org.mortbay.jetty.webapp.WebAppContext.startContex t(WebAppContext.java:1220)
    at org.mortbay.jetty.handler.ContextHandler.doStart(C ontextHandler.java:513)
    at org.mortbay.jetty.webapp.WebAppContext.doStart(Web AppContext.java:448)
    at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAp pContextWithReload.doStart(JettyLauncher.java:461)
    at org.mortbay.component.AbstractLifeCycle.start(Abst ractLifeCycle.java:39)
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(H andlerWrapper.java:130)
    at org.mortbay.jetty.handler.RequestLogHandler.doStar t(RequestLogHandler.java:115)
    at org.mortbay.component.AbstractLifeCycle.start(Abst ractLifeCycle.java:39)
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(H andlerWrapper.java:130)
    at org.mortbay.jetty.Server.doStart(Server.java:222)
    at org.mortbay.component.AbstractLifeCycle.start(Abst ractLifeCycle.java:39)
    at com.google.gwt.dev.shell.jetty.JettyLauncher.start (JettyLauncher.java:565)
    at com.google.gwt.dev.DevMode.doStartUpServer(DevMode .java:494)
    at com.google.gwt.dev.DevModeBase.startUp(DevModeBase .java:1058)
    at com.google.gwt.dev.DevModeBase.run(DevModeBase.jav a:800)
    at com.google.gwt.dev.DevMode.main(DevMode.java:304)
    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:195)
    at com.sun.org.apache.xerces.internal.util.ErrorHandl erWrapper.error(ErrorHandlerWrapper.java:131)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorRe porter.reportError(XMLErrorReporter.java:384)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorRe porter.reportError(XMLErrorReporter.java:318)
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSche maValidator.handleStartElement(XMLSchemaValidator. java:1916)
    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:400)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocum entScannerImpl$NSContentDriver.scanRootElementHook (XMLNSDocumentScannerImpl.java:626)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImpl$FragmentContentDriver.next(XM LDocumentFragmentScannerImpl.java:3103)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumen tScannerImpl$PrologDriver.next(XMLDocumentScannerI mpl.java:922)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumen tScannerImpl.next(XMLDocumentScannerImpl.java:648)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocum entScannerImpl.next(XMLNSDocumentScannerImpl.java: 140)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImpl.scanDocument(XMLDocumentFragm entScannerImpl.java:511)
    at com.sun.org.apache.xerces.internal.parsers.XML11Co nfiguration.parse(XML11Configuration.java:808)
    at com.sun.org.apache.xerces.internal.parsers.XML11Co nfiguration.parse(XML11Configuration.java:737)
    at com.sun.org.apache.xerces.internal.parsers.XMLPars er.parse(XMLParser.java:119)
    at com.sun.org.apache.xerces.internal.parsers.DOMPars er.parse(DOMParser.java:235)
    at com.sun.org.apache.xerces.internal.jaxp.DocumentBu ilderImpl.parse(DocumentBuilderImpl.java:284)
    at org.springframework.beans.factory.xml.DefaultDocum entLoader.loadDocument(DefaultDocumentLoader.java: 75)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.doLoadBeanDefinitions(XmlBeanDefinitio nReader.java:388)
    ... 31 more
    </code>

  3. #23
    Join Date
    Jul 2011
    Posts
    1

    Default

    you should check your internet connection because of dtd s. if you this exception occurs when connection is not avaible. This exactly because of maven asssembly plugin problem. Since assembly plugin does not append what is inside spring.handlers and spring.schemas files for every spring jar file(spring-beans, spring-context). Only the first encounter files will be included others will be skipped. So you should define two spring.handlers and spring.schemas files under src/main/resources and should append all necessary definitions here like below.You may have to add more depending of your springjar files. And then use add maven assembly plugin as below in your pom.xml file. Assumin you put applicationcontext.xml under src/main/resources.



    maven assembly plugin
    <build>
    <resources>
    <resource>
    <directory>src/main/resources</directory>
    <includes>
    <include>**/*.xml</include>
    <include>**/*.handlers</include>
    <include>**/*.schemas</include>
    </includes>
    </resource>
    </resources>

    <plugins>
    <plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <configuration>
    <descriptors>
    <descriptor>src/main/assembly/assembly.xml</descriptor>
    </descriptors>
    <archive>
    <manifest>
    <mainClass>com.main.YourMainClassWhatever</mainClass>
    </manifest>
    </archive>
    </configuration>
    </plugin>
    </plugins>
    </build>


    assembly.xml file
    <assembly>
    <id>executable</id>
    <formats>
    <format>jar</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <dependencySets>
    <dependencySet>
    <unpack>true</unpack>
    <scope>runtime</scope>
    <unpackOptions>
    <excludes>
    <exclude>**/spring.handlers</exclude>
    <exclude>**/spring.schemas</exclude>
    </excludes>
    </unpackOptions>
    </dependencySet>
    </dependencySets>
    <fileSets>
    <fileSet>
    <directory>${project.build.outputDirectory}</directory>
    </fileSet>
    <fileSet>
    <directory>target/classes</directory>
    <outputDirectory>META-INF</outputDirectory>
    <includes>
    <include>spring.handlers</include>
    <include>spring.schemas</include>
    </includes>
    </fileSet>
    </fileSets>
    </assembly>


    spring.handlers
    http\://www.springframework.org/schema/p=org.springframework.beans.factory.xml.SimpleProp ertyNamespaceHandler
    http\://www.springframework.org/schema/util=org.springframework.beans.factory.xml.UtilNam espaceHandler
    http\://www.springframework.org/schema/context=org.springframework.context.config.Context NamespaceHandler
    http\://www.springframework.org/schema/jee=org.springframework.ejb.config.JeeNamespaceHan dler
    http\://www.springframework.org/schema/lang=org.springframework.scripting.config.LangName spaceHandler
    http\://www.springframework.org/schema/task=org.springframework.scheduling.config.TaskNam espaceHandler
    http\://www.springframework.org/schema/aop=org.springframework.aop.config.AopNamespaceHan dler


    spring.schemas
    http\://www.springframework.org/schema/beans/spring-beans-2.0.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd
    http\://www.springframework.org/schema/beans/spring-beans-2.5.xsd=org/springframework/beans/factory/xml/spring-beans-2.5.xsd
    http\://www.springframework.org/schema/beans/spring-beans-3.0.xsd=org/springframework/beans/factory/xml/spring-beans-3.0.xsd
    http\://www.springframework.org/schema/beans/spring-beans.xsd=org/springframework/beans/factory/xml/spring-beans-3.0.xsd
    http\://www.springframework.org/schema/tool/spring-tool-2.0.xsd=org/springframework/beans/factory/xml/spring-tool-2.0.xsd
    http\://www.springframework.org/schema/tool/spring-tool-2.5.xsd=org/springframework/beans/factory/xml/spring-tool-2.5.xsd
    http\://www.springframework.org/schema/tool/spring-tool-3.0.xsd=org/springframework/beans/factory/xml/spring-tool-3.0.xsd
    http\://www.springframework.org/schema/tool/spring-tool.xsd=org/springframework/beans/factory/xml/spring-tool-3.0.xsd
    http\://www.springframework.org/schema/util/spring-util-2.0.xsd=org/springframework/beans/factory/xml/spring-util-2.0.xsd
    http\://www.springframework.org/schema/util/spring-util-2.5.xsd=org/springframework/beans/factory/xml/spring-util-2.5.xsd
    http\://www.springframework.org/schema/util/spring-util-3.0.xsd=org/springframework/beans/factory/xml/spring-util-3.0.xsd
    http\://www.springframework.org/schema/util/spring-util.xsd=org/springframework/beans/factory/xml/spring-util-3.0.xsd
    http\://www.springframework.org/schema/context/spring-context-2.5.xsd=org/springframework/context/config/spring-context-2.5.xsd
    http\://www.springframework.org/schema/context/spring-context-3.0.xsd=org/springframework/context/config/spring-context-3.0.xsd
    http\://www.springframework.org/schema/context/spring-context.xsd=org/springframework/context/config/spring-context-3.0.xsd
    http\://www.springframework.org/schema/jee/spring-jee-2.0.xsd=org/springframework/ejb/config/spring-jee-2.0.xsd
    http\://www.springframework.org/schema/jee/spring-jee-2.5.xsd=org/springframework/ejb/config/spring-jee-2.5.xsd
    http\://www.springframework.org/schema/jee/spring-jee-3.0.xsd=org/springframework/ejb/config/spring-jee-3.0.xsd
    http\://www.springframework.org/schema/jee/spring-jee.xsd=org/springframework/ejb/config/spring-jee-3.0.xsd
    http\://www.springframework.org/schema/lang/spring-lang-2.0.xsd=org/springframework/scripting/config/spring-lang-2.0.xsd
    http\://www.springframework.org/schema/lang/spring-lang-2.5.xsd=org/springframework/scripting/config/spring-lang-2.5.xsd
    http\://www.springframework.org/schema/lang/spring-lang-3.0.xsd=org/springframework/scripting/config/spring-lang-3.0.xsd
    http\://www.springframework.org/schema/lang/spring-lang.xsd=org/springframework/scripting/config/spring-lang-3.0.xsd
    http\://www.springframework.org/schema/task/spring-task-3.0.xsd=org/springframework/scheduling/config/spring-task-3.0.xsd
    http\://www.springframework.org/schema/task/spring-task.xsd=org/springframework/scheduling/config/spring-task-3.0.xsd
    http\://www.springframework.org/schema/aop/spring-aop-2.0.xsd=org/springframework/aop/config/spring-aop-2.0.xsd
    http\://www.springframework.org/schema/aop/spring-aop-2.5.xsd=org/springframework/aop/config/spring-aop-2.5.xsd
    http\://www.springframework.org/schema/aop/spring-aop-3.0.xsd=org/springframework/aop/config/spring-aop-3.0.xsd
    http\://www.springframework.org/schema/aop/spring-aop.xsd=org/springframework/aop/config/spring-aop-3.0.xsd
    Last edited by fatihtekin; Jul 3rd, 2011 at 03:42 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •