Ошибка конфигурации Spring - PullRequest
       14

Ошибка конфигурации Spring

3 голосов
/ 05 ноября 2008

Мой файл контекста весны показан ниже.

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:jee="http://www.springframework.org/schema/jee"
    xmlns:jms="http://www.springframework.org/schema/jms"
    xmlns:lang="http://www.springframework.org/schema/lang"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
        http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms.xsd
        http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">

    <bean id="cfaBeanFactory" class="org.springframework.context.support.ClassPathXmlApplicationContext">
        <constructor-arg value="classpath:cfa-spring-core.xml" />
    </bean>
</beans>

Когда я пытаюсь запустить свое приложение, я получаю следующую ошибку:

Caused by: org.springframework.beans.factory.access.BootstrapException: Unable to initialize group definition. Group resource name [classpath*:cfa-spring-context.xml], factory key [cfaBeanFactory]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Line 16 in XML document from URL [file:/C:/.../cfa-spring-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException: Document root element "beans", must match DOCTYPE root "null".
    at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.useBeanFactory(SingletonBeanFactoryLocator.java:389)
    ... 56 more
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Line 16 in XML document from URL [file:/C:/.../cfa-spring-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException: Document root element "beans", must match DOCTYPE root "null".
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:169)
    ... 59 more
Caused by: org.xml.sax.SAXParseException: Document root element "beans", must match DOCTYPE root "null".
    at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)

Может кто-нибудь сказать мне, что я делаю не так?

Ответы [ 5 ]

5 голосов
/ 06 ноября 2008

Оказывается, это потому, что я использую Hibernate 3 с Spring 1.x, что означает, что DTD неверны. Обновлен файл Spring JAR в проекте, и это решило проблему.

1 голос
/ 03 июля 2010

Обновите ваш spring.jar последней версией

1 голос
/ 30 декабря 2009

Возможно, вы используете старую версию spring.jar. Я получил это, и это было решено, когда я использовал последнюю версию spring.jar

0 голосов
/ 05 ноября 2008

Глядя на вашу трассировку стека:

    Line 16 in XML document from URL <b>[file:/C:/.../cfa-spring-context.xml]</b> is invalid;
    nested exception is org.xml.sax.SAXParseException: Document root element "beans", 
    must match DOCTYPE root "null".

Похоже, у вас ошибка в файле cfa-spring-core.xml , а не в файле Spring, который вы включили в свое сообщение.

0 голосов
/ 05 ноября 2008

вы не закрываете тег <beans>. Добавьте </beans> в конец вашего конфигурационного файла.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...