Remote Service Question

GWT Designer allows you to quickly create the modules, composites, panels, remote services and other elements that comprise Google Web Tookit applications.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

Remote Service Question

Postby aesrys » Mon Aug 13, 2007 4:34 am


I'm fairly new to both Java and GWT, and need a little help with
creating a remote service. In trying to learn more about GWT, I
created a basic application based on an example at the Instantiations
website. Basically, the app pulls data from a test
table through a JDBC query and tries to put it into a grid. When I
try to run the app, I get the following error when I click the button
that should pull the data:
Code: Select all
java.lang.ClassCastException: java.lang.String cannot be cast to
        at query.client.QueryView$2.onSuccess(
        at query.client.QueryService_Proxy$1.onCompletionImpl(transient
source for query.client.QueryService_Proxy:67)
        at query.client.QueryService_Proxy$1.onCompletionAndCatch(transient
source for query.client.QueryService_Proxy:43)
        at query.client.QueryService_Proxy$1.onCompletion(transient source
for query.client.QueryService_Proxy:37)
        at org.eclipse.swt.internal.win32.OS.DispatchMessage(

Here's the relevant code:
Remote Service contains: List getQueryItems();

Service Async contains: void getQueryItems(AsyncCallback callback);

Service Impl contains:
Code: Select all
        public List getQueryItems() {

                final Connection con;
                final String query;
                final Statement stmt;
                final ResultSet rs;

                List li = new ArrayList();

                try {

                        // Set connection for Oracle
                        con = DriverManager.getConnection(
                                        "jdbc:oracle:thin:@server:1521:DB", "username",

                        // Query string plus conditional variable(s)
                        query = "SELECT * from JH_PROG";

                        // Run query
                        stmt = con.prepareStatement(query,

                        rs = stmt.executeQuery(query);

                        ResultSetMetaData rmd = rs.getMetaData();
                        int colCount = (rmd.getColumnCount() - 1);

                        // Loop through ResultSet and add values to a list
                        while ( {

                                for (int i = 0; i <= colCount; i++) {
                                        li.add(i, rs.getObject(i + 1));
                } catch (Exception e) {
                return li;

The view object, where the error seems to occur, has a button that
runs the following function
Code: Select all
private void getData() {
                QueryService.Util.getInstance().getQueryItems(new AsyncCallback() {
                        public void onSuccess(Object result) {
                                        List items = (List) result;
                                        grid.resize(1 + items.size(), 3);
                                        int row = 1;
                                        for (Iterator I = items.iterator(); I.hasNext(); row++) {
                                                QueryItems qi = (QueryItems);
                                                grid.setWidget(row, 0, new Label(qi.getCol1()));
                                                grid.setWidget(row, 1, new Label(qi.getCol2()));
                                                grid.setWidget(row, 2, new Label(qi.getCol3()));

                        public void onFailure(Throwable caught) {

QueryItems is a simple java class that implements IsSerializable and
contains getters/setters for 3 String fields, which matches the table
(JH_PROG) from the JDBC query. Any help would be appreciated.
Code: Select all
Code: Select all
Posts: 5
Joined: Wed Jul 11, 2007 12:31 pm


Postby aesrys » Mon Aug 13, 2007 7:46 am

I think I found my problem. I'm passing a List of Strings to code expecting QueryItems instead. I tested a way to fix it, but my code is definitely not elegant or probably even efficient, so I'd appreciate any suggestions/examples on how to best go about it. Thanks.
Posts: 5
Joined: Wed Jul 11, 2007 12:31 pm

Re: Problem

Postby Eric Clayberg » Thu Aug 16, 2007 12:22 pm

General GWT questions are better posted to Google's GWT forum.
Eric Clayberg
Software Engineering Manager

Author: "Eclipse Plug-ins"
Eric Clayberg
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Return to GWT Designer

Who is online

Users browsing this forum: No registered users and 3 guests