Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: problem with "xmlns must be declared for element type beans" exception

  1. #1
    Join Date
    Oct 2006
    Posts
    7

    Default problem with "xmlns must be declared for element type beans" exception

    Hi all,

    i'm a newbie here so pls. forgive my missteps. i tried to test a JMS POJO example but got this parse exception instead:

    Attribute "xmlns" must be declared for element type "beans".

    i am not sure what i'm missing here, but here is the file:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    <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="requestQueue" class="org.apache.activemq.command.ActiveMQQueue">
    <constructor-arg value="PREADMIT.TO400.QUEUE"/>
    </bean>

    <bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFacto ry">
    <property name="brokerURL" value="tcp://localhost:61616"/>
    </bean>

    <!-- this is the Message Driven POJO (MDP) -->
    <bean id="messageListener" class="com.hmacorpmis.msglistener.ActiveMQJMSListe ner"/>

    <!-- and this is the attendant message listener container -->
    <bean id="listenerContainer" class="org.springframework.jms.listener.DefaultMes sageListenerContainer">
    <property name="concurrentConsumers" value="5"/>
    <property name="connectionFactory" ref="connectionFactory"/>
    <property name="destination" ref="requestQueue"/>
    <property name="messageListener" ref="messageListener"/>
    </bean>
    </beans>



    any help is greatly appreciated. thanks.

  2. #2
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,844

    Default

    You are mixing the DTD and XSD declarations. Simply remove the line:
    Code:
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    ...and that should do the trick.

  3. #3
    Join Date
    Oct 2006
    Posts
    7

    Default

    Hi Mark,

    appreciate the response. when i took out the DTD, it then came up with another msg:

    org.xml.sax.SAXParseException: Document root element "beans", must match DOCTYPE root "null".



    Erwin Pader
    Health Management Associates, Inc.
    Naples, FL

  4. #4
    Join Date
    Oct 2006
    Posts
    7

    Default

    btw, i am using jdk 1.5, and these are the following jars in cp:

    activemq-core-4.0.1.jar
    geronimo-jms_1.1_spec-1.0.jar
    geronimo-j2ee-management_1.0_spec-1.0.jar

    thanks.

  5. #5
    Join Date
    Oct 2006
    Posts
    7

    Default

    finally worked! but i found it weird that i had to delete xmlns and schemalocation and replaced both with:

    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">

    there must be something in the schema that's causing the parser to go whacko.

    any explanations on this?

  6. #6
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,844

    Default

    What version of Spring are you using - is it 2.0 final?

  7. #7

    Default

    It sounds like the JAXP parser might be something like Crimson instead of Xerces. I'd check the specific release # of the JDK 1.5 installed, might need to be bumped up to one of the more recent update releases.

  8. #8
    Join Date
    Oct 2006
    Posts
    7

    Default

    i am using spring 2.0 final

    regarding jdk 1.5, it looks like it's using xerces. i'll have to check again though if it's an old version.

  9. #9
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,844

    Default

    For Spring 2.0 final, you need to change the schema reference from "spring-beans.xsd" to "spring-beans-2.0.xsd".

  10. #10
    Join Date
    Sep 2006
    Posts
    1

    Red face Attribute "xmlns" must be declared for element type "beans"

    I met with the same problem.I use spring1.2.8,the xml file is:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
    <beans xmlns="http://xfire.codehaus.org/config/1.0">
    <xfire>
    <transports>
    <bean id="jmsTransport"
    class="org.codehaus.xfire.transport.jms.JMSTranspo rt"
    xmlns="http://xbean.org/schemas/spring/1.0">
    <constructor-arg ref="xfire"/>
    <constructor-arg ref="connectionFactory"/>
    </bean>
    </transports>
    </xfire>

    <service xmlns:e="urn:Echo">
    <name>Echo</name>
    <serviceClass>org.codehaus.xfire.test.Echo</serviceClass>
    <implementationClass>org.codehaus.xfire.test.EchoI mpl</implementationClass>
    <bindings>
    <soap11Binding name="e:EchoJMSBinding" transport="urn:xfire:transport:jms">
    <endpoints>
    <endpoint name="e:EchoJMSEndpoint" url="jms://Echo" />
    </endpoints>
    </soap11Binding>
    </bindings>
    </service>

    <bean id="connectionFactory"
    class="org.apache.activemq.ActiveMQConnectionFacto ry"
    singleton="true"
    xmlns="http://xbean.org/schemas/spring/1.0/">
    <constructor-arg value="vm://localhost?broker.persistent=false" type="java.lang.String"/>
    </bean>
    </beans>

    The error information:
    [thira-admin] ERROR [main] ContextLoader.initWebApplicationContext(211) | Context initialization failed
    org.springframework.beans.factory.BeanDefinitionSt oreException: Line 3 in XML document from ServletContext resource [/WEB-INF/xFire-JmsService.xml] is
    invalid; nested exception is org.xml.sax.SAXParseException: Attribute "xmlns" must be declared for element type "beans".
    org.xml.sax.SAXParseException: Attribute "xmlns" must be declared for element type "beans".

Posting Permissions

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