找不到类org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer

萨蒂亚·卡维蒂(Satya Kaveti):

我们已将Project Spring版本从3.1.2.RELEASE升级4.3.25.RELEASE

我没有发现任何与代码相关的错误。但是Junit测试用例由于抛出错误以下而失败

找不到类[org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer

错误记录

Tests run: 10, Failures: 0, Errors: 10, Skipped: 0, Time elapsed: 3.979 sec <<< FAILURE!
testMergeInProgressStatus(com.perceptive.portal.idm.domain.AccountTest)  Time elapsed: 0.021 sec  <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
    at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83)
    ....
    ....
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException:
 Error creating bean with name 'userAdminViewController': 
Unsatisfied dependency expressed through field 'userProfileService'; nested exception is 
org.springframework.beans.factory.CannotLoadBeanClassException: 
**Cannot find class [org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer]** 
for bean with name 'org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer#0' defined in class path resource [UserAdminTest-portlet.xml]; 
nested exception is java.lang.ClassNotFoundException: org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:586)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)

UserAdminTest-portlet.xml的内容是

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                           http://www.springframework.org/schema/context
                           http://www.springframework.org/schema/context/spring-context-3.0.xsd
                           http://www.springframework.org/schema/util
                           http://www.springframework.org/schema/util/spring-util-3.0.xsd">


    <bean class="org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer" />

    <bean id="velocityEngineFactoryBean" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
     <property name="resourceLoaderPath" value="/WEB-INF/classes/mailTemplates/"/>
   </bean>

    <bean
        class="org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter">
        <property name="webBindingInitializer">
            <bean
                class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer">
                <property name="validator" ref="hibernateValidator" />
            </bean>
        </property>

    </bean>
    <bean id="hibernateValidator"
        class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
        <property name="validationMessageSource">
            <ref bean="messageSource" />
        </property>
    </bean>

    <bean id="messageSource"
        class="org.springframework.context.support.ResourceBundleMessageSource">
        <property name="basenames">
            <list>
                <value>content.messages</value>
            </list>
        </property>
    </bean> 
</beans>

相同的代码可以正常工作,并且具有以下依赖性

<spring.version>3.0.5.RELEASE</spring.version>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.8</version>
      <scope>test</scope>
    </dependency>

作为升级的一部分,我们已将上面的依赖关系更改为下面的依赖关系

<spring.version>4.3.25.RELEASE</spring.version>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>

具有以上依赖性的对象,它将在执行测试用例时抛出此异常。找不到类org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer

无论如何,我已经将spring-xx-xsd模式更改为4.0,但是没有运气

萨蒂亚·卡维蒂(Satya Kaveti):

感谢M.deinum

我已按照您的建议进行操作,并通过做其他一些事情解决了此问题

将此代码放在UserAdminTest-portlet.xml中

    <bean
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="ignoreUnresolvablePlaceholders" value="true"/>
        <property name="ignoreResourceNotFound" value="false"/>
        <property name="order" value="1" />

    </bean>

之后,它抛出了

java.lang.NoClassDefFoundError: org/hibernate/validator/spi/resourceloading/ResourceBundleLocator

为此,我已将pom.xml中的休眠验证器版本升级为

<hibernate.validator.version>6.1.0.Final</hibernate.validator.version>

然后我又遇到了一个问题

javax.validation.ValidationException: HV000183: 
Unable to initialize 'javax.el.ExpressionFactory'. Check that you have the EL dependencies on the classpath, 
or use ParameterMessageInterpolator instead

我已经放置了javax-el依赖项

<dependency>
    <groupId>org.glassfish</groupId>
    <artifactId>javax.el</artifactId>
    <version>3.0.1-b08</version>
</dependency>

然后,建立成功。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

找不到org.springframework.web.context.support.XmlWebApplicationContext类在EAP上的Fuse 7.1.0中部署WAR

找不到org.springframework.web.context.ContextLoaderListener类

Tomcat和Spring Web-找不到类异常org.springframework.web.context.ContextLoaderListener

log4j:WARN找不到记录器的附加程序(org.springframework.web.context.support.StandardServletEnvironment)

找不到类org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration]

java.lang.NoSuchMethodError:org.springframework.web.context.support.ServletContextAwareProcessor:方法<init>()V未找到

Spring MVC Webapp-java.lang.ClassNotFoundException:org.springframework.web.context.support.ServletRequestHandledEvent

ClassNotFoundException :: org.springframework.web.context.ContextLoaderListener

找不到 org.springframework.web.WebApplicationInitializer

无法解析org.springframework.context.support.GenericApplicationContext类型

在 Spring Web 应用程序中找不到类 [org.springframework.scheduling.quartz.SchedulerFactoryBean]

java.lang.NoClassDefFoundError:org / springframework / web / context / ContextCleanupListener问题

java.lang.ClassNotFoundException:org.springframework.web.context.ContextLoaderListener

org.springframework.boot.web.support不存在

org.springframework.boot.web.support.does 不存在

org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver handleHttpRequestMethodNotSupported

找不到 org.springframework.web.servlet.mvc.SimpleFormController

无法初始化类org.springframework.web.context.request.ServletRequestAttributes

严重:错误配置类 [org.springframework.web.context.ContextLoaderListener] NoClassDefFoundError: javax/servlet/ServletContextListener

线程“主”中的异常java.lang.NoClassDefFoundError:org / springframework / context / support / ClassPathXmlApplicationContext

ClassNotFoundException: org/springframework/context/support/LiveBeansView 异常在 STS 中重复抛出

引起原因:java.lang.ClassNotFoundException:org.springframework.web.context.request.RequestAttributes

java.lang.NoSuchMethodError:org.springframework.web.context.request.ServletRequestAttributes。<init>

java.lang.ClassNotFoundException:org.springframework.web.servlet.support.DefaultFlashMapManager Weblogic 12c

[org.springframework.web.multipart.support.MissingServletRequestPartException:所需的请求部分“文件”不存在

错误:org.springframework.web.context.ContextLoader - 上下文初始化失败 [context-security.xml]

org.springframework.beans.factory.CannotLoadBeanClassException:找不到类

org.springframework.web.client.RestClientException:无法编写请求:找不到适合请求类型的HttpMessageConverter

Spring cloud Feign:找不到适合响应类型的HttpMessageConverter [class org.springframework.web.servlet.ModelAndView]