Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: [FIXED] Loading a store from an xml string.

  1. #1

    Default [FIXED] Loading a store from an xml string.

    I am currently using the following code to load a store from an xml string. This method works perfectly in the hosted browser but fails to work when the site is hosted on a Tomcat server and accessed through either IE or FF. If there is a better way to load a store from an XML string please feel free to point me in the right direction.

    Code:
    final MemoryProxy<String> proxy = new MemoryProxy<String>(xml);; final BaseListLoader loader = new BaseListLoader(proxy, _xmlReader); final ListStore<ModelData> store = new ListStore<ModelData>(loader); loader.addLoadListener(new LoadListener() { public void loaderLoad(LoadEvent le) { loadNewData(append, store); } }); try { loader.load(); } catch (Throwable error) { CommandManager.instance().executeCommand(CommandFactory.logError("Failed.", error));
    }
    2009-01-22 16:28:08,272 ERROR http-8080-5 admin - Failed.
    java.lang.RuntimeException: com.google.gwt.core.client.JavaScriptException: (TypeError): Object expected
    number: -2146823281
    description: Object expected
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.instantiate(ServerSerializationStreamReader.java:721)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.deserialize(ServerSerializationStreamReader.java:498)
    at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:61)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader$ValueReader$8.readValue(ServerSerializationStreamReader.java:131)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamReader.deserializeValue(ServerSerializationStreamReader.java:372)
    at com.google.gwt.user.server.rpc.RPC.decodeRequest(RPC.java:287)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:163)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:86)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:619)

  2. #2
    Ext GWT Premium Member gslender's Avatar
    Join Date
    Mar 2008
    Location
    Brisbane, Australia
    Posts
    1,572

    Default

    It would help if you defined the context of where this code snippet is running - is this on the server or client?

    ...it looks like you are runing GWT code on the server? - if so, then no it won't work.

    GWT code MUST run on the client - a browser, and hosted mode is the only time ever it will work in a Java environment (like the hosted shell) with Tomcat.

  3. #3

    Default

    Thanks for the quick reply.

    The code is on the client. The exception was sent to the server through an RPC so I could get an idea of where it was having problems. The variable _xmlReader is an XmlReader<ModelType>.

  4. #4
    Ext GWT Premium Member gslender's Avatar
    Join Date
    Mar 2008
    Location
    Brisbane, Australia
    Posts
    1,572

    Default

    Arthur,

    Provide more details. Where does the error/stack trace come from? (looks server side) and the code looks client side.

    I honestly don't understand what you mean by "The exception was sent to the server through an RPC" - huh?

    Can't you just add some Window.alert() calls at various stages to confirm the output of data at the client side (ie when you are processing the XML etc).

  5. #5

    Default

    Where does the error/stack trace come from?

    The exception is thrown in client side code. It's a method that is called from a class that implements AsyncCallback. The particular method that loads the data does not implement the AsyncCallback interface.

    I honestly don't understand what you mean by "The exception was sent to the server through an RPC" - huh?

    The exception was thrown and caught on the client. The caught exception was then sent to the server through a RPC so that it could be logged.

    Can't you just add some Window.alert() calls at various stages to confirm the output of data at the client side (ie when you are processing the XML etc).

    Done. . . a Windows Internet Explorer alert window pops up stating "Failed to load data. com.google.gwt.core.client.JavaScriptException: (TypeError): Object expected number: -2146823281 description: Object expected".

    Code:
    MemoryProxy<String> proxy = null; ListLoader loader = null; try { proxy = new MemoryProxy<String>(xml); if (proxy == null) Window.alert("Proxy is null."); } catch (Throwable e) { Window.alert("Failed to create proxy.\n" + e.getMessage()); } try { loader = new BaseListLoader(proxy, _xmlReader); if (loader == null) Window.alert("Reader is null."); } catch (Throwable e) { Window.alert("Failed to create loader.\n" + e.getMessage()); } try { final ListStore<ModelData> store = new ListStore<ModelData>(loader); if (store == null) Window.alert("Store is null."); loader.addLoadListener(new LoadListener() { public void loaderLoad(LoadEvent le) { loadNewData(append, store); } }); } catch (Throwable e) { Window.alert("Failed to create store.\n" + e.getMessage()); } try { loader.load(); // throws exception here } catch (Throwable e) { Window.alert("Failed to load data.\n" + e.getMessage());
    }

  6. #6
    Ext GWT Premium Member gslender's Avatar
    Join Date
    Mar 2008
    Location
    Brisbane, Australia
    Posts
    1,572

    Default

    ok, at this point I'd debug, step by step through the loader.load code to figure out what is going wrong... I can't see it, but something is...

  7. #7

    Default

    I got the following error in FireFox:

    Code:
    Failed to load the store.
    com.google.gwt.core.client.JavaScriptException: (ReferenceError): attrValue is not defined
    This seems to be a little more complete as it actually states which variable was never defined. I don't have an attrValue anywhere in my code. I am currently trying to debug more thoroughly but I am not a web developer so this may take some time for me to get it figured out.

  8. #8

    Default

    I've narrowed the bug down to parsing xml attributes. I'm not sure if this applies to parsing xml that is using a remote proxy as well as the memory proxy that I am using. Removing attributes from the XmlReader field list will allow the program to run normally in a web browser. Of course this also breaks some very important functionality of my program.

    I'm assuming this is a bug in Ext library since this works correctly in hosted mode. I am also able to parse and use XML attributes by using the core GWT library in other parts of my program with no issues.

  9. #9
    Ext User
    Join Date
    Apr 2008
    Location
    Lincoln, NE
    Posts
    235

    Default

    It would be helpful to see an example XML string as well.

    -JP

  10. #10

    Default

    Here is a sample of the xml I am using. Note that some of the names have been changed to protect the innocent. Or at the very least my job. . .

    Code:
    <?xml version="1.0" encoding="UTF-8"?><list><data id="06b43db7-21a8-4f35-b316-65755fbce35c"> <createdBy>user</createdBy> <modifiedBy>user</modifiedBy> <createdDate>2009-01-27 09:20:57.216 PST</createdDate> <modifiedDate>2009-01-27 09:20:57.216 PST</modifiedDate> <effectiveDate></effectiveDate> <effectiveTime></effectiveTime> <expireDate></expireDate> <expireTime></expireTime> <status>Active</status> <name></name> </data></list>

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •