hacksong / jsonrpc4j

Automatically exported from code.google.com/p/jsonrpc4j
0 stars 0 forks source link

Basic example using spring 3.0.5.RELEASE not working #11

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Declare bean and exporter in context XML:
    <bean id="myBatisService" class="com.jefa.sample.services.MyBatisServiceJSONImpl">
        <property name="userMapper" ref="userMapper" />
    </bean>
.....
    <bean name="/myBatisService.json" class="com.googlecode.jsonrpc4j.spring.JsonServiceExporter">
        <property name="service" ref="myBatisService"/>
        <property name="serviceInterface" value="com.jefa.sample.api.MyBatisService"/>

2. Use RPC client with Proxy invocation:
        JsonRpcHttpClient client = new JsonRpcHttpClient(
                new URL("http://localhost:8180/myBatisService.json"));
        this.myBatisService = ProxyUtil.createProxy(
                getClass().getClassLoader(),
                MyBatisService.class,
                client);

3. Invoke any operation:
System.out.println("MyBatisServiceJSONTest.testGetUserById():: " + 
this.myBatisService.getUserById("1"));

What is the expected output? What do you see instead?
Get an exception instead of getting any result:
java.lang.reflect.UndeclaredThrowableException
    at $Proxy8.getUserById(Unknown Source)
    at com.jefa.sample.services.tests.MyBatisServiceJSONTest.testGetUserById(MyBatisServiceJSONTest.java:45)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.io.FileNotFoundException: 
http://localhost:8180/myBatisService.json
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1401)
    at com.googlecode.jsonrpc4j.JsonRpcHttpClient.invoke(JsonRpcHttpClient.java:162)
    at com.googlecode.jsonrpc4j.ProxyUtil$2.invoke(ProxyUtil.java:72)
    ... 26 more

On server I get the following error:

[                   http-8180-1] PageNotFound                   WARN  No 
mapping found for HTTP request with URI [/SpringServices/myBatisService.json] 
in DispatcherServlet with name 'appServlet'

What version of the product are you using? On what operating system?
Jakarta Tomcat 6, JVM 1.6 and Spring 3.0.5.RELEASE.

Please provide any additional information below.

Original issue reported on code.google.com by fradilet...@gmail.com on 17 Jan 2012 at 6:02

GoogleCodeExporter commented 9 years ago
You need to setup a UrlHandlerMapping in spring.  The examples provided assume 
BeanNameUrlHandlerMapping.  Basically you're spring configuration is not 
complete.

Original comment by brian.di...@gmail.com on 8 Feb 2012 at 7:34

GoogleCodeExporter commented 9 years ago

Original comment by brian.di...@gmail.com on 26 May 2012 at 2:42