Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 添加拦截器时发生异常_Java_Spring_Spring Mvc_Interceptor - Fatal编程技术网

Java 添加拦截器时发生异常

Java 添加拦截器时发生异常,java,spring,spring-mvc,interceptor,Java,Spring,Spring Mvc,Interceptor,您好,我有以下异常: ERROR 13 May 2013 15:20:17,471 http-9090-1 org.springframework.web.servlet.DispatcherServlet - Context initialization failed org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframewo

您好,我有以下异常:

ERROR 13 May 2013 15:20:17,471 http-9090-1 org.springframework.web.servlet.DispatcherServlet - Context initialization failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.ws.soap.server.endpoint.interceptor.DelegatingSmartSoapEndpointInterceptor#0': Unsatisfied dependency expressed through constructor argument with index 0 of type [org.springframework.ws.server.EndpointInterceptor]: Could not convert constructor argument value of type [com.syngenta.panda.web.mvc.interceptor.ExternalLinkInterceptor] to required type [org.springframework.ws.server.EndpointInterceptor]: Failed to convert value of type 'com.syngenta.panda.web.mvc.interceptor.ExternalLinkInterceptor' to required type 'org.springframework.ws.server.EndpointInterceptor'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [com.syngenta.panda.web.mvc.interceptor.ExternalLinkInterceptor] to required type [org.springframework.ws.server.EndpointInterceptor]: no matching editors or conversion strategy found
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:702)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:196)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1003)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:907)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:442)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:458)
    at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:339)
    at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306)
    at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
    at javax.servlet.GenericServlet.init(GenericServlet.java:212)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)
    at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:806)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:722)
只有当我添加了拦截器时,才会发生这种情况:

@Component
public class ExternalLinkInterceptor extends HandlerInterceptorAdapter {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
            throws Exception {
//code
}
编辑更新: applicationContext.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:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

    <import resource="properties-beans.xml"/>

    <context:component-scan base-package="com.syngenta.panda.security"/>

    <import resource="security-beans.xml"/>

    <context:component-scan base-package="com.syngenta.panda.shared.service"/>

    <import resource="classpath:/com/syngenta/panda/shared/service/config/shared-service-beans.xml"/>

    <context:component-scan base-package="com.syngenta.panda.discovery.service"/>

    <import resource="classpath:/com/syngenta/panda/discovery/service/config/discovery-service-beans.xml"/>

    <context:component-scan base-package="com.syngenta.panda.analysis.service"/>

    <import resource="classpath:/com/syngenta/panda/analysis/service/config/analysis-service-beans.xml"/>

    <context:component-scan base-package="com.syngenta.panda.assay.service"/>

    <import resource="classpath:/com/syngenta/panda/assay/service/config/assay-service-beans.xml"/>

    <import resource="classpath:/com/syngenta/panda/dao/config/dao-beans.xml"/>

    <import resource="classpath:/com/syngenta/panda/integration/refdata/config/xrd-integration-beans.xml"/>

    <import resource="classpath:/com/syngenta/panda/integration/smartchoice/config/smartchoice-integration-beans.xml"/>
    <import resource="classpath:/com/syngenta/panda/integration/vast/config/vast-integration-beans.xml"/>
    <import resource="classpath:/com/syngenta/panda/integration/bfx/config/bfx-integration-beans.xml"/>
    <import resource="classpath:/com/syngenta/panda/integration/magenta/config/magenta-integration-beans.xml"/>


</beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:beans="http://www.springframework.org/schema/beans"
             xmlns:mvc="http://www.springframework.org/schema/web-services"
             xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services.xsd"
             xmlns:security="http://www.springframework.org/schema/security"
             xmlns:tx="http://www.springframework.org/schema/tx">

    <!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->

    <!-- Enables the Spring MVC @Controller programming model -->
    <annotation-driven/>
    <tx:annotation-driven proxy-target-class="true"/>
    <!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
    <!--beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <beans:property name="prefix" value="/WEB-INF/views/" />
        <beans:property name="suffix" value=".jsp" />
    </beans:bean-->

    <!-- Imports user-defined @Controller beans that process client requests -->
    <beans:import resource="controllers.xml"/>
    <beans:import resource="freemarker.xml"/>
    <security:global-method-security pre-post-annotations="enabled"/>
    <mvc:interceptors>
        <beans:bean class="com.syngenta.panda.web.mvc.interceptor.ExternalLinkInterceptor"/>
    </mvc:interceptors>

</beans:beans>

servlet-context.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:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

    <import resource="properties-beans.xml"/>

    <context:component-scan base-package="com.syngenta.panda.security"/>

    <import resource="security-beans.xml"/>

    <context:component-scan base-package="com.syngenta.panda.shared.service"/>

    <import resource="classpath:/com/syngenta/panda/shared/service/config/shared-service-beans.xml"/>

    <context:component-scan base-package="com.syngenta.panda.discovery.service"/>

    <import resource="classpath:/com/syngenta/panda/discovery/service/config/discovery-service-beans.xml"/>

    <context:component-scan base-package="com.syngenta.panda.analysis.service"/>

    <import resource="classpath:/com/syngenta/panda/analysis/service/config/analysis-service-beans.xml"/>

    <context:component-scan base-package="com.syngenta.panda.assay.service"/>

    <import resource="classpath:/com/syngenta/panda/assay/service/config/assay-service-beans.xml"/>

    <import resource="classpath:/com/syngenta/panda/dao/config/dao-beans.xml"/>

    <import resource="classpath:/com/syngenta/panda/integration/refdata/config/xrd-integration-beans.xml"/>

    <import resource="classpath:/com/syngenta/panda/integration/smartchoice/config/smartchoice-integration-beans.xml"/>
    <import resource="classpath:/com/syngenta/panda/integration/vast/config/vast-integration-beans.xml"/>
    <import resource="classpath:/com/syngenta/panda/integration/bfx/config/bfx-integration-beans.xml"/>
    <import resource="classpath:/com/syngenta/panda/integration/magenta/config/magenta-integration-beans.xml"/>


</beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:beans="http://www.springframework.org/schema/beans"
             xmlns:mvc="http://www.springframework.org/schema/web-services"
             xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services.xsd"
             xmlns:security="http://www.springframework.org/schema/security"
             xmlns:tx="http://www.springframework.org/schema/tx">

    <!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->

    <!-- Enables the Spring MVC @Controller programming model -->
    <annotation-driven/>
    <tx:annotation-driven proxy-target-class="true"/>
    <!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
    <!--beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <beans:property name="prefix" value="/WEB-INF/views/" />
        <beans:property name="suffix" value=".jsp" />
    </beans:bean-->

    <!-- Imports user-defined @Controller beans that process client requests -->
    <beans:import resource="controllers.xml"/>
    <beans:import resource="freemarker.xml"/>
    <security:global-method-security pre-post-annotations="enabled"/>
    <mvc:interceptors>
        <beans:bean class="com.syngenta.panda.web.mvc.interceptor.ExternalLinkInterceptor"/>
    </mvc:interceptors>

</beans:beans>


我不明白这个异常意味着什么,我需要帮助。

您可能有这个
xmlns:mvc=”http://www.springframework.org/schema/web-services“
出于其他原因。您需要将其更改为:

xmlns:mvc="http://www.springframework.org/schema/mvc"
带schemaLocation(针对上述内容)


使用web服务命名空间,您使用的是Spring WS
标记,该标记期望
org.springframework.WS.server.EndpointInterceptor
实例,而不是
org.springframework.web.servlet.HandlerInterceptor
,您使用的是
MessageDispatcherServlet
?@SotiriosDelimanolis我不知道,所以我会回答,没有。你能检查一下你的
web.xml
吗。您正在使用哪个servlet?我认为对于SpringWS,您需要使用
EndpointInterceptor
而不是
HandlerInterceptorAdapter
。DispatcherServlet是我使用的唯一一个servlet
appServlet org.springframework.web.servlet.DispatcherServlet contextConfigLocation web-INF/Spring/servlet-context.xml1
试试我在下面发布的内容。我认为这是一个xml名称空间问题。我认为你是对的,我交换了这两个名称空间,不幸的是,我遇到了另一个例外,但这远远不是这个问题:-)谢谢