I'm trying to use the built-in functions of GWT to serialize something
that's not going through regular RPC.  I've manually created a
ClientOracle and gotten the InputStream for the <strongName>.gwt.rpc
where I got the <strongName> portion from the client.  I'm using
RPC.streamResponseForSuccess to write it to a ByteArrayOutputStream.
However, I get an exception part way through serialization:

java.lang.NullPointerException
        at
com.google.gwt.rpc.server.WebModePayloadSink.getBytes(WebModePayloadSink.java:
860)
        at com.google.gwt.rpc.server.WebModePayloadSink
$PayloadVisitor.constructorFunction(WebModePayloadSink.java:607)
        at com.google.gwt.rpc.server.WebModePayloadSink
$PayloadVisitor.visit(WebModePayloadSink.java:260)
        at
com.google.gwt.rpc.client.ast.InstantiateCommand.traverse(InstantiateCommand.java:
54)
        at
com.google.gwt.rpc.client.ast.RpcCommandVisitor.doAccept(RpcCommandVisitor.java:
320)
        at
com.google.gwt.rpc.client.ast.RpcCommandVisitor.accept(RpcCommandVisitor.java:
42)
        at com.google.gwt.rpc.server.WebModePayloadSink
$PayloadVisitor.visit(WebModePayloadSink.java:237)
        at
com.google.gwt.rpc.client.ast.ArrayValueCommand.traverse(ArrayValueCommand.java:
53)
        at
com.google.gwt.rpc.client.ast.RpcCommandVisitor.doAccept(RpcCommandVisitor.java:
320)
        at
com.google.gwt.rpc.client.ast.RpcCommandVisitor.accept(RpcCommandVisitor.java:
42)
        at com.google.gwt.rpc.server.WebModePayloadSink
$PayloadVisitor.visit(WebModePayloadSink.java:285)
        at
com.google.gwt.rpc.client.ast.InstantiateCommand.traverse(InstantiateCommand.java:
54)
        at
com.google.gwt.rpc.client.ast.RpcCommandVisitor.doAccept(RpcCommandVisitor.java:
320)
        at
com.google.gwt.rpc.client.ast.RpcCommandVisitor.accept(RpcCommandVisitor.java:
42)
        at com.google.gwt.rpc.server.WebModePayloadSink
$PayloadVisitor.visit(WebModePayloadSink.java:376)
        at
com.google.gwt.rpc.client.ast.InvokeCustomFieldSerializerCommand.traverse(InvokeCustomFieldSerializerCommand.java:
76)
        at
com.google.gwt.rpc.client.ast.RpcCommandVisitor.doAccept(RpcCommandVisitor.java:
320)
        at
com.google.gwt.rpc.client.ast.RpcCommandVisitor.accept(RpcCommandVisitor.java:
42)
        at com.google.gwt.rpc.server.WebModePayloadSink
$PayloadVisitor.visit(WebModePayloadSink.java:407)
        at
com.google.gwt.rpc.client.ast.ReturnCommand.traverse(ReturnCommand.java:
44)
        at
com.google.gwt.rpc.client.ast.RpcCommandVisitor.doAccept(RpcCommandVisitor.java:
320)
        at
com.google.gwt.rpc.client.ast.RpcCommandVisitor.accept(RpcCommandVisitor.java:
42)
        at
com.google.gwt.rpc.server.WebModePayloadSink.accept(WebModePayloadSink.java:
890)
        at com.google.gwt.rpc.server.RPC.streamResponse(RPC.java:472)
        at
com.google.gwt.rpc.server.RPC.streamResponseForSuccess(RPC.java:249)


Relevant code:

ClientOracle oracle = getClientOracle();
ByteArrayOutputStream out = new ByteArrayOutputStream();
RPC.streamResponseForSuccess(oracle, out, messagesToSend);

protected InputStream findClientOracleData(String
requestModuleBasePath, String permutationStrongName) throws
IOException {
                        String resourcePath = requestModuleBasePath + 
permutationStrongName
+ ".gwt.rpc";
                        InputStream in =
getServletContext().getResourceAsStream(resourcePath);
                        if (in == null) {
                                throw new IOException("Could not find 
ClientOracle data for
permutation " + permutationStrongName);
                        }
                        return in;
                }

                public ClientOracle getClientOracle() throws IOException {
                        String strongName = request.getParameter("StrongName");
                        strongName = strongName != null ? strongName.trim() : 
null;
                        strongName = strongName != null && strongName.isEmpty() 
? null :
strongName;
                        if (strongName == null) {
                                return null;
                        }
                        if ("HostedMode".equals(strongName)) {
                                return new HostedModeClientOracle();
                        } else {
                                String moduleBase = 
request.getParameter("ModuleBase");
                                if (moduleBase == null) {
                                        return null;
                                }

                                String basePath = new URL(moduleBase).getPath();
                                if (basePath == null) {
                                        throw new 
MalformedURLException("Blocked request without GWT base
path parameter (XSRF attack?)");
                                }

                                String contextPath = 
getServletContext().getContextPath();
                                if (!basePath.startsWith(contextPath)) {
                                        throw new 
MalformedURLException("Blocked request with invalid GWT
base path parameter (XSRF attack?)");
                                }
                                basePath = 
basePath.substring(contextPath.length());

                                InputStream in = findClientOracleData(basePath, 
strongName);

                                return WebModeClientOracle.load(in);
                        }
                }

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to