Hi, all:
I'm a newbie to jsonrpc4j and i'm currently using the lib to
test a simple communication as follow code:
Client side:
client = new JsonRpcHttpClient(
new URL("
http://localhost:9005"));
UserService userService = ProxyUtil.createProxy(
getClass().getClassLoader(),
UserService.class,
client);
User user = userService.GetUser("bob");
Server side:
this.jsonRpcServer = new
JsonRpcServer(this.userService, UserService.class);
// create the stream server
int maxThreads = 50;
int port = 9005;
InetAddress bindAddress = InetAddress.getByName("localhost");
StreamServer streamServer;
streamServer = new StreamServer(
jsonRpcServer, maxThreads, new ServerSocket(port, 1,
bindAddress) );
// start it, this method doesn't block
streamServer.start();
UserService:
public interface UserService {
public User GetUser(String userName);
}
However, i somehow got exception:
六月 09, 2012 10:44:26 上午 com.googlecode.jsonrpc4j.StreamServer start
信息: StreamServer starting localhost/
127.0.0.1:9005
六月 09, 2012 10:44:35 上午 com.googlecode.jsonrpc4j.StreamServer$Server
run
信息: Connection from /
127.0.0.1:2867
六月 09, 2012 10:44:37 上午 com.googlecode.jsonrpc4j.StreamServer$Server
run
严重: Exception while handling request
org.codehaus.jackson.JsonParseException: Unexpected character
('P' (code 80)): e
xpected a valid value (number, String, array, object, 'true', 'false'
or 'null')
at [Source: com.googlecode.jsonrpc4j.NoCloseInputStream@f4aa7a; line:
1, column
: 2]
at
org.codehaus.jackson.JsonParser._constructError(JsonParser.java:1433)
at
org.codehaus.jackson.impl.JsonParserMinimalBase._reportError(JsonPars
erMinimalBase.java:521)
at
org.codehaus.jackson.impl.JsonParserMinimalBase._reportUnexpectedChar
(JsonParserMinimalBase.java:442)
at
org.codehaus.jackson.impl.Utf8StreamParser._handleUnexpectedValue(Utf
8StreamParser.java:2090)
at
org.codehaus.jackson.impl.Utf8StreamParser._nextTokenNotInObject(Utf8
StreamParser.java:606)
at
org.codehaus.jackson.impl.Utf8StreamParser.nextToken(Utf8StreamParser
.java:492)
at
org.codehaus.jackson.map.ObjectMapper._initForReading(ObjectMapper.ja
va:2770)
at
org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.j
ava:2718)
at
org.codehaus.jackson.map.ObjectMapper.readTree(ObjectMapper.java:1507
)
at
com.googlecode.jsonrpc4j.JsonRpcServer.handle(JsonRpcServer.java:201)
at com.googlecode.jsonrpc4j.StreamServer
$Server.run(StreamServer.java:22
0)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown
Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown
Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown
Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown
Source)
at java.lang.Thread.run(Unknown Source)
Who can help with this exception, or give me a sample guide to use the
lib?
Thank a lot for your kind help!!