java.lang.ClassCastException: $Proxy9 cannot be cast to org.springframework.remoting.
Hi thanks for any help being banging my head over this for the whole weekend. I need to acces a remote service using HttpInvokerProxyFactoryBean but not using autowired which does work and looks after the casting for me.
I am trying to access a simple remote service.
In my remoting-servlet.xml
<bean name="/MyService" class="org.springframework.remoting.httpinvoker.Ht tpInvokerServiceExporter">
<property name="service" ref="myService"/>
<property name="serviceInterface" value="uk.co.mo.app.moses.domain.myservice.service .MyService"/>
</bean>
In my applicationContext.xml
<bean id="agreementServiceProxy" class="org.springframework.remoting.httpinvoker.Ht tpInvokerProxyFactoryBean">
<property name="serviceUrl" value="http://localhost:8080/RemoteApp/remoting/AgreementService"/>
<property name="serviceInterface" value="uk.co.mo.app.moses.domain.myservice.service .MyService"/>
</bean>
I deploy the war file to tomcat.
In my junit
public class RemoteCustomerServiceTest extends AbstractJunit4Test {
private HttpInvokerProxyFactoryBean customerServiceProxy;
@Test
public void testCustomerSelectHttpInvoker() {
ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath*:META-INF/spring/applicationContext*.xml");
customerServiceProxy = (HttpInvokerProxyFactoryBean)ctx.getBean("customer ServiceProxy");
}
When I run the test I get the error:
java.lang.ClassCastException: $Proxy10 cannot be cast to org.springframework.remoting.httpinvoker.HttpInvok erProxyFactoryBean
at uk.co.mo.app.moses.domain.customer.RemoteCustomerS erviceTest.testCustomerSelectHttpInvoker(RemoteCus tomerServiceTest.java:35)
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.junit.runners.model.FrameworkMethod$1.runRefle ctiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallabl e.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExpl osively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod .evaluate(InvokeMethod.java:20)
at org.springframework.test.context.junit4.statements .RunBeforeTestMethodCallbacks.evaluate(RunBeforeTe stMethodCallbacks.java:74)
at org.springframework.test.context.junit4.statements .RunAfterTestMethodCallbacks.evaluate(RunAfterTest MethodCallbacks.java:82)
at org.springframework.test.context.junit4.statements .SpringRepeat.evaluate(SpringRepeat.java:72)
at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.runChild(SpringJUnit4ClassRunner.jav a:240)
at org.junit.runners.BlockJUnit4ClassRunner.runChild( BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner. java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRu nner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentR unner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRu nner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRu nner.java:184)
at org.springframework.test.context.junit4.statements .RunBeforeTestClassCallbacks.evaluate(RunBeforeTes tClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements .RunAfterTestClassCallbacks.evaluate(RunAfterTestC lassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.ja va:236)
at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.run(SpringJUnit4ClassRunner.java:180 )
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestR eference.run(JUnit4TestReference.java:46)
at org.eclipse.jdt.internal.junit.runner.TestExecutio n.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:197)
Thanks for any help.
Is there any decent step by step guides.