Announcement Announcement Module
Collapse
No announcement yet.
Cannot resolve the name 'beans:identifiedType' Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cannot resolve the name 'beans:identifiedType'

    What I am trying to do should be very simple as I am copying it straight from Appendix B. Extensible XML authoring. I am receiving the following error:

    src-resolve: Cannot resolve the name 'beans:identifiedType' to a(n) 'type definition' component.

    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema xmlns="http://www.mycompany.com/schema/myns"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:beans="http://www.springframework.org/schema/beans"
    targetNamespace="http://www.mycompany.com/schema/myns"
    elementFormDefault="qualified"
    attributeFormDefault="unqualified">

    <xsd:import namespace="http://www.springframework.org/schema/beans"/>

    <xsd:element name="dateformat">
    <xsd:complexType>
    <xsd:complexContent>
    <xsd:extension base="beans:identifiedType">
    <xsd:attribute name="lenient" type="xsd:boolean"/>
    <xsd:attribute name="pattern" type="xsd:string" use="required"/>
    </xsd:extension>
    </xsd:complexContent>
    </xsd:complexType>
    </xsd:element>

    </xsd:schema>



    I would think this is a classpath issue, but wondering if anyone knows what I might be missing.

    Thanks,

    Keith

  • #2
    I had to specify the schema location for the xsd:import.

    schemaLocation="http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"

    Now, I have to figure out the error in my applicationContext.xml. Any help would be greatly appreciated...

    Error
    org.springframework.beans.factory.xml.XmlBeanDefin itionStoreException: Line 20 in XML document from ServletContext resource [/WEB-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'documentDefinition:dateformat'.
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.doLoadBeanDefinitions(XmlBeanDefinitio nReader.java:404)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:342)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:310)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:143)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:178)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:149)
    at org.springframework.web.context.support.XmlWebAppl icationContext.loadBeanDefinitions(XmlWebApplicati onContext.java:124)
    at org.springframework.web.context.support.XmlWebAppl icationContext.loadBeanDefinitions(XmlWebApplicati onContext.java:92)
    at org.springframework.context.support.AbstractRefres hableApplicationContext.refreshBeanFactory(Abstrac tRefreshableApplicationContext.java:123)
    at org.springframework.context.support.AbstractApplic ationContext.obtainFreshBeanFactory(AbstractApplic ationContext.java:422)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:352)
    at org.springframework.web.context.ContextLoader.crea teWebApplicationContext(ContextLoader.java:255)
    at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:199)
    at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 45)
    at org.apache.catalina.core.StandardContext.listenerS tart(StandardContext.java:3843)
    at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4342)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1045)
    at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:719)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(Sta ndardService.java:516)
    at org.apache.catalina.core.StandardServer.start(Stan dardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalin a.java:578)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.apache.catalina.startup.Bootstrap.start(Bootst rap.java:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:413)

    documentDefinition.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema xmlns="http://www.cvs.com/schema/documentDefinition"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:beans="http://www.springframework.org/schema/beans"
    targetNamespace="http://www.cvs.com/schema/documentDefinition"
    elementFormDefault="qualified"
    attributeFormDefault="unqualified">

    <xsd:import namespace="http://www.springframework.org/schema/beans" schemaLocation="http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"/>
    <xsd:element name="dateformat">
    <xsd:complexType>
    <xsd:complexContent>
    <xsd:extension base="beans:identifiedType">
    <xsd:attribute name="lenient" type="xsd:boolean"/>
    <xsd:attribute name="pattern" type="xsd:string" use="required"/>
    </xsd:extension>
    </xsd:complexContent>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>


    spring-handlers under META-INF
    http\://www.cvs.com/schema/documentDefinition=com.cvs.xml.DocumentNamespaceHa ndler

    spring-schemas under META-INF
    http\://www.cvs.com/schema/documentDefinition/documentDefinition.xsd=com/cvs/xml/documentDefinition.xsd

    applicationContext.xml under WEB-INF
    <?xml version="1.0" encoding="UTF-8"?>
    <!--
    - Application context definition for Promo Order Guide business layer.
    - Contains bean references to the transaction manager and to the DAOs.
    -->
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:documentDefinition="http://www.cvs.com/schema/documentDefinition"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schem...-beans-2.5.xsd
    http://www.cvs.com/schema/documentDefinition http://www.cvs.com/schema/documentDefinition/documentDefinition.xsd">

    <documentDefinition:dateformat id="dateFormat" pattern="yyyy-MM-dd HH:mm"
    lenient="true" />
    </beans>

    DocumentDefinitionBeanDefinitionParser.java
    package com.cvs.xml;

    import java.text.SimpleDateFormat;

    import org.springframework.beans.factory.support.BeanDefi nitionBuilder;
    import org.springframework.beans.factory.xml.AbstractSing leBeanDefinitionParser;
    import org.springframework.util.StringUtils;
    import org.w3c.dom.Element;

    public class DocumentDefinitionBeanDefinitionParser extends
    AbstractSingleBeanDefinitionParser {
    protected Class getBeanClass(Element element) {
    return SimpleDateFormat.class;
    }

    protected void doParse(Element element, BeanDefinitionBuilder bean) {
    // this will never be null since the schema explicitly requires that a
    // value be supplied
    String pattern = element.getAttribute("pattern");
    bean.addConstructorArgValue(pattern);

    // this however is an optional property
    String lenient = element.getAttribute("lenient");
    if (StringUtils.hasText(lenient)) {
    bean.addPropertyValue("lenient", Boolean.valueOf(lenient));
    }
    }
    }

    DocumentNamespaceHandler.java
    package com.cvs.xml;

    import org.springframework.beans.factory.xml.NamespaceHan dlerSupport;

    public class DocumentNamespaceHandler extends NamespaceHandlerSupport {

    public void init() {
    registerBeanDefinitionParser("dateformat",
    new DocumentDefinitionBeanDefinitionParser());
    }

    }


    The .javas and the documentDefinition.xsd are all under package com.cvs.xml.

    Thanks,

    Keith
    Last edited by thecaptain1977; Mar 24th, 2009, 10:24 AM.

    Comment


    • #3
      Realized spring-handlers should be spring.handlers and spring-schemas should be spring.schemas, but it is still not working for me.

      Comment


      • #4
        Having the same issue.

        Comment


        • #5
          This part of the forum is for the Spring Integration project. You will probably have more replies to this if you post it in the "core" forum section.

          Comment

          Working...
          X