spring-projects / spring-framework

Spring Framework
https://spring.io/projects/spring-framework
Apache License 2.0
56.62k stars 38.13k forks source link

Error using JaxRpcPortProxyFactoryBean with an interceptor [SPR-158] #4890

Closed spring-projects-issues closed 20 years ago

spring-projects-issues commented 20 years ago

Nils-Helge Garli opened SPR-158 and commented

When using an interceptor with the JaxRpcPortProxyFactoryBean, an exception is thrown during initialization of the Spring Context. It appears that somewhere in the initialization, the toString method of the interceptor is invoked, which in turn will invoke toString on the JaxRpcPortProxy, which in turn attempts to invoke a toString operation on the web service that it proxies.

The stack trace (plus some debug info) is:

4632 [main] INFO org.springframework.beans.factory.support.DefaultListableBeanFactory - Destroying singletons in factory {org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [debugInterceptor,amazon,debugAdvisor,amazonTarget]; Root of BeanFactory hierarchy} 4633 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Retrieving depending beans for bean 'debugAdvisor' 4633 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Applying DestructionAwareBeanPostProcessors to bean with name 'debugAdvisor' 4634 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Retrieving depending beans for bean 'debugInterceptor' 4635 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Applying DestructionAwareBeanPostProcessors to bean with name 'debugInterceptor' 4635 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Retrieving depending beans for bean 'amazonTarget' 4635 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Applying DestructionAwareBeanPostProcessors to bean with name 'amazonTarget' org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'amazon' defined in class path resource [applicationContext-spring-test.xml]: Initialization of bean failed; nested exception is javax.xml.rpc.JAXRPCException: Cannot find operation: toString - none defined javax.xml.rpc.JAXRPCException: Cannot find operation: toString - none defined at org.apache.axis.client.Call.setOperation(Call.java:1309) at org.apache.axis.client.AxisClientProxy.invoke(AxisClientProxy.java:154) at $Proxy0.toString(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.springframework.remoting.jaxrpc.JaxRpcPortClientInterceptor.invoke(JaxRpcPortClientInterceptor.java:294) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:138) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:148) at $Proxy1.toString(Unknown Source) at java.lang.String.valueOf(String.java:2131) at java.lang.StringBuffer.append(StringBuffer.java:370) at org.springframework.aop.target.SingletonTargetSource.toString(SingletonTargetSource.java:50) at java.lang.String.valueOf(String.java:2131) at java.lang.StringBuffer.append(StringBuffer.java:370) at org.springframework.aop.framework.AdvisedSupport.toString(AdvisedSupport.java:478) at java.lang.String.valueOf(String.java:2131) at java.lang.StringBuffer.append(StringBuffer.java:370) at org.springframework.aop.framework.ProxyFactoryBean.setBeanFactory(ProxyFactoryBean.java:174) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:245) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:177) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:159) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:177) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:268) at org.springframework.context.support.ClassPathXmlApplicationContext.\(ClassPathXmlApplicationContext.java:58) at spring.bug.SpringBugTest.testAmazonService(SpringBugTest.java:23) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203)


Affects: 1.0.1, 1.0.2

Attachments:

spring-projects-issues commented 20 years ago

Nils-Helge Garli commented

Test case and supporting classes to recreate the issue. Note that the invocation of the web service itself will fail since the example is not complete. But it is enough to illustrate the problem

spring-projects-issues commented 20 years ago

Nils-Helge Garli commented

application context file used to re-create the issue

spring-projects-issues commented 20 years ago

Nils-Helge Garli commented

...apologies for the corrupt test case in the previous test.tar. This one should fail correctly.

spring-projects-issues commented 20 years ago

Juergen Hoeller commented

Thanks for the report - SingletonTargetSource shouldn't try to invoke toString on the target, as some targets like an Axis proxy might not support toString.

As a side note, you might want to use a JaxRpcPortClientInterceptor instead of a JaxRpcPortProxyFactoryBean when you combine a JAX-RPC proxy with an interceptor. Simply turn "amazonTarget" into a JaxRpcPortClientInterceptor, and specify "amazonTarget" as further interceptor name on the "amazon" ProxyFactoryBean rather than as target. This will be more efficient as it doesn't unnecessarily create another proxy behind the scenes but instead delegates the call directly to the Axis proxy.

Juergen