Spring 3.2.6使用JDK Dynamic Proxy和DWR 2.0.2抛出异常 [英] Spring 3.2.6 with JDK Dynamic Proxy and DWR 2.0.2 throwing exception

查看:47
本文介绍了Spring 3.2.6使用JDK Dynamic Proxy和DWR 2.0.2抛出异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



我在这里使用Maven,DWR 2.0.2和Spring AOP网络应用程序。



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



这是代码: -



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



I have just upgraded my web application from spring version 3.0 to spring 3.2.6.

I am using Maven, DWR 2.0.2 and Spring AOP in this web application.

All my configuration is XML based, I am not using annotations.

Here is the code:-

Bean configuration in sample-servlet.xml file

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







使用的界面: -






Interface used:-

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





实现上述界面的类: -





Class that implements the above interface:-

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()方法,我遇到以下异常: -








When I upgraded my configuration files to spring version 3.2.6 and tried calling the loadSampledata() method through a DWR call, I faced the following exception:-


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 =falseto aop:scoped-proxy proxy-target-class =true



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



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



注意 - 我已经在使用接口了,所以这里似乎不是问题。



先谢谢。




This exception was getting resolved when I changed AOP configuration from aop:scoped-proxy proxy-target-class="false" to aop:scoped-proxy proxy-target-class="true"

Now as per my knowledge, it got resolved because now the application was using CGLIB proxy instead of JDK Dynamic proxy.

Now the problem is that I don't want to use CGLIB. Is there any constraint in using JDK dynamic proxy with Spring 3.2.6?? Is there any solution to this problem?

Note - I am already using Interfaces, so that doesn't seems to be the issue here.

Thanks in advance.

推荐答案

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)org.springframework.web.servlet.DispatcherServle上的
吨。 doDispatch(DispatcherServlet.java:925)
at org.springframework.web.servlet.DispatcherServlet。 doService(DispatcherServlet.java:856)
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 =falseto aop:scoped-proxy proxy-target-class =true



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



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



注意 - 我已经在使用接口了,所以这里似乎不是问题。



提前致谢。




This exception was getting resolved when I changed AOP configuration from aop:scoped-proxy proxy-target-class="false" to aop:scoped-proxy proxy-target-class="true"

Now as per my knowledge, it got resolved because now the application was using CGLIB proxy instead of JDK Dynamic proxy.

Now the problem is that I don't want to use CGLIB. Is there any constraint in using JDK dynamic proxy with Spring 3.2.6?? Is there any solution to this problem?

Note - I am already using Interfaces, so that doesn't seems to be the issue here.

Thanks in advance.


这篇关于Spring 3.2.6使用JDK Dynamic Proxy和DWR 2.0.2抛出异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆