Spring 3.2.6使用JDK Dynamic Proxy和DWR 2.0.2抛出异常

时间:2014-01-22 05:59:12

标签: java spring java-ee spring-aop dwr

我刚刚将我的Web应用程序从spring 3.0升级到spring 3.2.6。

我在这个Web应用程序中使用Maven,DWR 2.0.2和Spring AOP。

我的所有配置都是基于XML的,我没有使用注释。

以下是代码: -

sample-servlet.xml文件中的Bean配置

<bean id="sampleAjaxLogic" class="com.sid.web.ajax.SampleAjaxLogicImpl">

 <property name="bimSampleLogic">
     <ref bean="bimBusinessLogic"/>
 </property>

 <aop:scoped-proxy proxy-target-class="false" />
 <!--  <aop:scoped-proxy/> -->

 <dwr:remote javascript="SampleDWRCaller">
 <dwr:include method="loadSampleData"/>

</bean>

使用的界面: -

public interface SampleAjaxLogic 
{
 public List loadSampleData(int type);
}

实现上述界面的类: -

public class SampleAjaxLogicImpl implements SampleAjaxLogic {

  private SampleBusinessLogic bimSampleLogic;

public SampleBusinessLogic getBimSampleLogic() {
    return bimSampleLogic;
}

public void setBimSampleLogic(SampleBusinessLogic bimSampleLogic) {
    this.bimSampleLogic = bimSampleLogic;
}

public List loadSampleData(int type) {
   List sampleList = bimSampleLogic.loadSampleData(type);
   return sampleList;
 }

}

当我将配置文件升级到spring版本3.2.6并尝试通过DWR调用调用loadSampledata()方法时,我遇到以下异常: -

2014-01-21 15:20:29,534 [TP-Processor3] WARN org.directwebremoting.impl.DefaultRemoter::warn - Method execution failed:
**java.lang.IllegalArgumentException: object is not an instance of declaring class**
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.directwebremoting.impl.ExecuteAjaxFilter.doFil ter(ExecuteAjaxFilter.java:34)
at org.directwebremoting.impl.DefaultRemoter$1.doFilt er(DefaultRemoter.java:428)
at org.directwebremoting.impl.DefaultRemoter.execute( DefaultRemoter.java:431)
at org.directwebremoting.impl.DefaultRemoter.execute( DefaultRemoter.java:283)
at org.directwebremoting.servlet.PlainCallHandler.han dle(PlainCallHandler.java:52)
at org.directwebremoting.servlet.UrlProcessor.handle( UrlProcessor.java:101)
at org.directwebremoting.spring.DwrController.handleR equestInternal(DwrController.java:234)
at org.springframework.web.servlet.mvc.AbstractContro ller.handleRequest(AbstractController.java:153)
at org.springframework.web.servlet.mvc.SimpleControll erHandlerAdapter.handle(SimpleControllerHandlerAda pter.java:48)
at org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:925)
at org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:856)

当我更改AOP配置时,此异常得到解决 aop:scoped-proxy proxy-target-class =“false” aop:scoped-proxy proxy-target-class =“true”

现在据我所知,它已得到解决,因为现在应用程序使用 CGLIB代理而不是 JDK动态代理

现在的问题是我不想使用CGLIB。在Spring 3.2.6中使用JDK动态代理有什么限制吗?有没有解决这个问题的方法?

注意 - 我已经在使用接口,因此这似乎不是问题

提前致谢。

0 个答案:

没有答案