The stack trace says it all...

com.example.foobar.client.RPCInterface.testRPC (java.lang.String)'
Threw an unexpected exception: java. lang.NoClassDefFoundError:
java.io.FileWriter is a restricted class. Please see the Google App
Engine developer's guide for more details.


You appear to have your test module in the com.example.foobar.client package.
                                                                                
                                 ^^^^^

This means that the GWT compiler will compile that module and it looks to me like that contains a reference to java.io.FileWriter - as the stack trace message says, the developer's guide will explain to you exactly what the problem is but the 'executive summary' is that java.io.FileWriter can't be used in GWT 'client' code because it can't be compiled to Javascript.

The rule in GWT is:

1. things that will only be run as javascript on the client should be in the your.module.client.* packages
2. things that will only be run on the server should be in the  
your.module.server.* packages
3. things that will be shared by the client code should be in the your.module.shared.* packages - IMHO these should be kept to a minimum.

You must make sure that you have both client and shared in the 
your.module.Module.gwt.xml file

Java classes used in 1. and 3. above must be restricted to those classes supported by the GWT compiler - see

http://code.google.com/webtoolkit/doc/latest/RefJreEmulation.html

for more details. Its all in the docs or has already been covered on this list

HTH

Alan




On 1/3/2011 6:19 AM, Sebe wrote:
Hello to all ...
I have to write an XML doc with GWT. I discovered that you can not do
client-side but it can be done with server-side.

So I setup the synchronous and asynchronous client-side:

package  com.example.foobar.client ;

import com.google.gwt.user.client.rpc.RemoteService;

public interface extends RPCInterface RemoteService {

     testRPC public String (String message);
}
--------------------------------------------------
-------------------------------------------------

  package com.example.foobar.client ;

import com.google.gwt.user.client.rpc.AsyncCallback;

public interface RPCInterfaceAsync {

testRPC void (String message, AsyncCallback callback<String>);

}
--------------------------------------------------
-----------------------------------------------

while on the server-side I did:

import java.io.BufferedWriter;
import java.io.DataOutputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.text.DateFormat;
import java.util.Date;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.example.foobar.client.RPCInterface;


public class extends RPCImpl RemoteServiceServlet implements
RPCInterface {
private static final long serialVersionUID = 1L;

testRPC public String (String message)
{

Date now = new Date ();
Dtm DateFormat.getTimeInstance String = (DateFormat.MEDIUM.) Format
(now);


try {
BufferedWriter out = new BufferedWriter (new FileWriter ("test.txt"));
out.write (message);
out.close ();
} Catch (IOException e) {
}

return "This is my message" + message;

}

}
--------------------------------------------------
-------------------------------------------------- ---------
I have not forgotten anything in the matter, because before you use
the class FileWriter and BufferedWriter the program run smoothly.
I have these errors:

ERROR] javax.servlet.ServletContext log: Exception while dispatching
incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method
'public abstract java.lang.String
com.example.foobar.client.RPCInterface.testRPC (java.lang.String)'
Threw an unexpected exception: java. lang.NoClassDefFoundError:
java.io.FileWriter is a restricted class. Please see the Google App
Engine developer's guide for more details.
at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure
(RPC.java: 378)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse
(RPC.java: 581)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall
(RemoteServiceServlet.java: 207)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost
(RemoteServiceServlet.java: 243)
at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost
(AbstractRemoteServiceServlet.java: 62)
at javax.servlet.http.HttpServlet.service (HttpServlet.java: 713)
at javax.servlet.http.HttpServlet.service (HttpServlet.java: 806)
at org.mortbay.jetty.servlet.ServletHolder.handle (ServletHolder.java:
511)
at org.mortbay.jetty.servlet.ServletHandler $ CachedChain.doFilter
(ServletHandler.java: 1166)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter
(ServeBlobFilter.java: 58)
at org.mortbay.jetty.servlet.ServletHandler $ CachedChain.doFilter
(ServletHandler.java: 1157)
at
com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter
(TransactionCleanupFilter.java: 43)
at org.mortbay.jetty.servlet.ServletHandler $ CachedChain.doFilter
(ServletHandler.java: 1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter
(StaticFileFilter.java: 122)
at org.mortbay.jetty.servlet.ServletHandler $ CachedChain.doFilter
(ServletHandler.java: 1157)
at org.mortbay.jetty.servlet.ServletHandler.handle
(ServletHandler.java: 388)
at org.mortbay.jetty.security.SecurityHandler.handle
(SecurityHandler.java: 216)
at org.mortbay.jetty.servlet.SessionHandler.handle
(SessionHandler.java: 182)
at org.mortbay.jetty.handler.ContextHandler.handle
(ContextHandler.java: 765)
at org.mortbay.jetty.webapp.WebAppContext.handle (WebAppContext.java:
418)
at com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle
(DevAppEngineWebAppContext.java: 70)
at org.mortbay.jetty.handler.HandlerWrapper.handle
(HandlerWrapper.java: 152)
com.google.appengine.tools.development.JettyContainerService at $
ApiProxyHandler.handle (JettyContainerService.java: 349)
at org.mortbay.jetty.handler.HandlerWrapper.handle
(HandlerWrapper.java: 152)
at org.mortbay.jetty.Server.handle (server.jar: 326)
at org.mortbay.jetty.HttpConnection.handleRequest
(HttpConnection.java: 542)
org.mortbay.jetty.HttpConnection at $ RequestHandler.content
(HttpConnection.java: 938)
at org.mortbay.jetty.HttpParser.parseNext (HttpParser.java: 755)
at org.mortbay.jetty.HttpParser.parseAvailable (HttpParser.java: 218)
at org.mortbay.jetty.HttpConnection.handle (HttpConnection.java: 404)
at org.mortbay.io.nio.SelectChannelEndPoint.run
(SelectChannelEndPoint.java: 409)
org.mortbay.thread.QueuedThreadPool at $ PoolThread.run
(QueuedThreadPool.java: 582)
Caused by: java.lang.NoClassDefFoundError: java.io.FileWriter is a
restricted class. Please see the Google App Engine developer's guide
for more details.
at com.google.appengine.tools.development.agent.runtime.Runtime.reject
(Runtime.java: 51)
at com.example.foobar.server.RPCImpl.testRPC (RPCImpl.java: 41)
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: 597)
at com.google.appengine.tools.development.agent.runtime.Runtime.invoke
(Runtime.java: 100)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse
(RPC.java: 562)
... 30 more


Someone can give me a hand? Please, do not know how to do ...:(

Thanks to all



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

Reply via email to