This is because you are using XMLParser in server side. Otherwise you should 
put that code under the client package.

(p.s. Why returning ArrayList instead of List?  Separate interface from 
implementation...)

--------------------------------------------------
From: "Dave" <[email protected]>
Sent: Saturday, November 28, 2009 8:59 AM
To: "Google Web Toolkit" <[email protected]>
Subject: ERROR: GWT.create() is only usable in client code!  It cannot be 
called, for example, from server code.

> I have the following code on my server
>
> public ArrayList<AMI> getAMIs()
> {
> ArrayList<AMI> amis = new ArrayList<AMI>();
> int n;
>
> AMI ami = new AMI();
> GetResources amiResourceXML = new GetResources();
>
> try
> {
> Document amiDom = XMLParser.parse(amiResourceXML.getAmi());
> Element root = amiDom.getDocumentElement();
> XMLParser.removeWhitespace(root);
>
> ...........
>
>                }
>                catch
>                { ......}
>                return "some value to client"
>        }
>
>        Why do I receive this error below?
>
> SEVERE: [1259395014149000] javax.servlet.ServletContext log: Exception
> while dispatching incoming RPC call
> com.google.gwt.user.server.rpc.UnexpectedException: Service method
> 'public abstract java.util.ArrayList
> com.clemson.client.AmazonService.getAMIs()' threw an unexpected
> exception: java.lang.ExceptionInInitializerError
> at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure
> (RPC.java:360)
> at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse
> (RPC.java:546)
> at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall
> (RemoteServiceServlet.java:166)
> at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost
> (RemoteServiceServlet.java:86)
> 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:
> 487)
> at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter
> (ServletHandler.java:1093)
> at
> com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter
> (TransactionCleanupFilter.java:43)
> at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter
> (ServletHandler.java:1084)
> at com.google.appengine.tools.development.StaticFileFilter.doFilter
> (StaticFileFilter.java:121)
> at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter
> (ServletHandler.java:1084)
> at org.mortbay.jetty.servlet.ServletHandler.handle
> (ServletHandler.java:360)
> at org.mortbay.jetty.security.SecurityHandler.handle
> (SecurityHandler.java:216)
> at org.mortbay.jetty.servlet.SessionHandler.handle
> (SessionHandler.java:181)
> at org.mortbay.jetty.handler.ContextHandler.handle
> (ContextHandler.java:712)
> at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:
> 405)
> at com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle
> (DevAppEngineWebAppContext.java:54)
> at org.mortbay.jetty.handler.HandlerWrapper.handle
> (HandlerWrapper.java:139)
> at com.google.appengine.tools.development.JettyContainerService
> $ApiProxyHandler.handle(JettyContainerService.java:342)
> at org.mortbay.jetty.handler.HandlerWrapper.handle
> (HandlerWrapper.java:139)
> at org.mortbay.jetty.Server.handle(Server.java:313)
> at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:
> 506)
> at org.mortbay.jetty.HttpConnection$RequestHandler.content
> (HttpConnection.java:844)
> at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:644)
> at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
> at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
> at org.mortbay.io.nio.SelectChannelEndPoint.run
> (SelectChannelEndPoint.java:396)
> at org.mortbay.thread.BoundedThreadPool$PoolThread.run
> (BoundedThreadPool.java:442)
> Caused by: java.lang.ExceptionInInitializerError
> at com.google.gwt.xml.client.XMLParser.<clinit>(XMLParser.java:28)
> at com.clemson.server.AmazonServiceImpl.getAMIs
> (AmazonServiceImpl.java:45)
> 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:527)
> ... 27 more
> Caused by: java.lang.UnsupportedOperationException: ERROR: GWT.create
> () is only usable in client code!  It cannot be called, for example,
> from server code.  If you are running a unit test, check that your
> test case extends GWTTestCase and that GWT.create() is not called from
> within an initializer or constructor.
> at com.google.gwt.core.client.GWT.create(GWT.java:85)
> at com.google.gwt.xml.client.impl.XMLParserImpl.<clinit>
> (XMLParserImpl.java:29)
> ... 35 more
> Thanks
>
> --
>
> 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.
>
> 

--

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