当前位置: 首页 > 面试题库 >

来自ServletContext资源[/WEB-INF/applicationContext.xml]的意外异常解析XML文档;

万俟财
2023-03-14
问题内容

在我的pom.xml中,出现以下错误。我<version>2.0.3</version>之所以要使用Spring 2 NTLM身份验证。

org.springframework.beans.factory.BeanDefinitionStoreException: 
Unexpected exception parsing XML document from
 ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception
is java.lang.NoSuchMethodError:org.springframework.aop.config.AopNamespaceUtils.
 registerAutoProxyCreatorIfNecessary(Lorg/springframework/beans
/factory/xml/ParserContext;Lorg/w3c/dom/Element;)V

如果我添加以下内容。

<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-core</artifactId>
    <version>2.0.3</version>
</dependency>
<dependency>
     <groupId>org.springframework.security</groupId>
     <artifactId>spring-security-core-tiger</artifactId>
     <version>2.0.3</version>
</dependency>
<dependency>
     <groupId>org.springframework.security</groupId>
     <artifactId>spring-security-ntlm</artifactId>
     <version>2.0.3</version>
</dependency>
<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-taglibs</artifactId>
    <version>2.0.3</version>
</dependency>

pom.xml没有上面没有错误

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
          http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>test</groupId>
    <artifactId>app</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>app</name>
    <url>http://maven.apache.org</url>
    <repositories>
        <repository>
            <id>prime-repo</id>
            <name>PrimeFaces Maven Repository</name>
            <url>http://repository.primefaces.org</url>
            <layout>default</layout>
        </repository>
    </repositories>
    <properties>
        <spring.version>3.1.1.RELEASE</spring.version>
        <spring.security.version>2.0.2. RELEASE</spring.security.version>
    </properties>
    <dependencies>
        <!-- Spring 3 dependencies -->

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <!-- JSF library -->
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>2.1.6</version>
        </dependency>
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-impl</artifactId>
            <version>2.1.6</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <!-- Primefaces library -->
        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>3.4.2</version>
        </dependency>
        <dependency>
            <groupId>org.primefaces.themes</groupId>
            <artifactId>afterwork</artifactId>
            <version>1.0.8</version>
        </dependency>
        <!-- Hibernate library -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.1.0.Final</version>
        </dependency>
        <dependency>
            <groupId>javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>3.12.1.GA</version>
        </dependency>
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>
        <!-- Oracle Java Connector library -->
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0.3</version>
        </dependency>
        <dependency>
            <groupId>c3p0</groupId>
            <artifactId>c3p0</artifactId>
            <version>0.9.1.2</version>
        </dependency>
        <!-- Log4j library -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.16</version>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.4</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-jpamodelgen</artifactId>
            <version>1.2.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>4.1.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.0-api</artifactId>
            <version>1.0.1.Final</version>
        </dependency>
        <dependency>
            <groupId>org.apache.myfaces.extensions.cdi.core</groupId>
            <artifactId>myfaces-extcdi-core-api</artifactId>
            <version>1.0.5</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-ehcache</artifactId>
            <version>4.0.1.Final</version>
        </dependency>
        <dependency>
            <groupId>p6spy</groupId>
            <artifactId>p6spy</artifactId>
            <version>1.3</version>
        </dependency>
    </dependencies>
    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <compilerArgument>-proc:none</compilerArgument>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.bsc.maven</groupId>
                <artifactId>maven-processor-plugin</artifactId>
                <version>2.0.6</version>
                <executions>
                    <execution>
                        <id>process</id>
                        <goals>
                            <goal>process</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                            <!-- source output directory -->
                            <outputDirectory>target/metamodel</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

编辑1

根据PSR的建议,添加以下依赖项时发生错误

<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-core</artifactId>
    <version>2.0.3</version>
</dependency>

问题答案:

问题会由于一种依赖关系而来,请尝试先删除所有显示的依赖关系,然后尝试逐一添加,然后我们才能找出问题所在



 类似资料:
  • 问题内容: 好的,我是第500位用户问这个问题,我读了很多答案,但仍然没有运气。 父模块pom包含: 子模块有,我使用运行我的webapp模块。 定义标准的调度程序模块: 我在下有文件,但是启动失败: 怎么了?文档和所有人都说Spring MVC将搜索XX-servlet.xml,其中XX是servlet的名称。为什么要搜索? 问题答案: 有自己的上下文,所有servlet和过滤器都共享它。默认情

  • 我在下有文件,但启动失败的原因是: 怎么啦?所有人都说Spring MVC将搜索xx-servlet.xml,其中XX是servlet的名称。它为什么搜索?

  • 我有这个错误,我不知道它可能是什么,我留下了一些项目类 xml: 应用Context.xml: Principal.java 错误: SLF4J:未能加载类“org.SLF4J.impl.StaticLoggerBinder”。SLF4J:默认为无操作(NOP)记录器实现SLF4J:请参阅http://www.slf4j.org/codes.html#StaticLoggerBinder了解更多细

  • 我使用spring boot并编写了以下代码:package com。luv2code。springdemo; 错误消息: 我的应用程序上下文。xml在com之外。luv2code。springdemo。 这里的错误是什么? 如果我必须发布其他信息,请发表评论

  • 我的web.xml 我的调度器-servlet.xml 然后这个 编辑2 我创建了新的clean Spring MVC项目,但问题仍然存在。我想问题可能出在Weblogic上,我会试着重新安装它

  • 问题内容: 我试图通过使用spring hibernatetemplate将我的hibernate示例移植到spring,但出现此错误,原因是:java.io.FileNotFoundException:无法打开ServletContext资源[/applicationContext.xml]。请建议我运行我的项目。我在公司里更新鲜 我的web.xml文件 我的applicationContext