2013-05-13 108 views
1

你好,我有这样的以下情况例外:异常增加拦截器

@Component 
public class ExternalLinkInterceptor extends HandlerInterceptorAdapter { 

    @Override 
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) 
      throws Exception { 
//code 
} 

编辑更新: 的applicationContext.xml

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) 

当我加入拦截这只happended:

<?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> 

在servlet-context.xml中:

<?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> 

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

+0

你使用的是MessageDispatcherServlet吗? – 2013-05-13 13:48:55

+0

@SotiriosDelimanolis我不知道,所以我会回答,不。 – 2013-05-13 13:59:18

+0

你可以检查你的'web.xml'。你正在使用哪个servlet?我认为对于Spring WS,你需要使用'EndpointInterceptor'而不是'HandlerInterceptorAdapter'。 – 2013-05-13 14:17:12

回答

2

由于某些其他原因,您可能有此xmlns:mvc="http://www.springframework.org/schema/web-services"。你会想将它更改为:

xmlns:mvc="http://www.springframework.org/schema/mvc" 

用的schemaLocation(对于以上)

http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd" 

与Web服务的命名空间,你使用Spring WS <interceptors>标签,它预计org.springframework.ws.server.EndpointInterceptor实例,而org.springframework.web.servlet.HandlerInterceptor

+0

我认为你是对的我换了两个,unfortunatley我得到了另一个异常,但它远离这个问题:-)谢谢 – 2013-05-13 15:22:47

+0

@MuhammadRamahy不客气。 – 2013-05-13 15:23:58