Hello,


I am new to the working of GWT.I have created a simple RPC Application
some thing like this

My user defined Class
================
public class StudentDetails implements IsSerializable
{
private static final long serialVersionUID = -5615180217808518977L;
public String name="" ;
public int class1=0;
public int marks1=0;
public int marks2=0;
public String Address="";
public String city="";
public int total=0;

public StudentDetails()
{}

}

My syncronous interface
===============
@RemoteServiceRelativePath("greet")
public interface GreetingService extends RemoteService {
        //ArrayList<StudentDetails> getResult();
        StudentDetails[] getResult();
        String Connect();
}

Asynchronous interface
==============
public interface GreetingServiceAsync {
        //void getResult(AsyncCallback<ArrayList<StudentDetails>> callback3);
        void getResult(AsyncCallback callback3);
        void Connect(AsyncCallback<String> callback4);
}

Server side implementation
===================
@SuppressWarnings("serial")
public class GreetingServiceImpl extends RemoteServiceServlet
implements
                GreetingService {

        String tempStr="";
        Connection con=null;
        String str="";

/**
         *  @gwt.typeArgs StudentDetails[]
         */
        public StudentDetails[] getResult()
        {

                ArrayList<StudentDetails> tempList=new 
ArrayList<StudentDetails>();
                try
                {
                        //Connect();
                        if(con!=null)
                        {
                                boolean test=con.isClosed();
                        if(!test)
                        {
                                Statement stmt=con.createStatement();

                                str="Select 
student.name,class,city,address,marks1,marks2 from
student,details where student.name=details.name";
                                stmt=con.prepareStatement(str);
                                ResultSet rs=stmt.executeQuery(str);


                                while(rs.next())
                                {

                                        StudentDetails st=new StudentDetails();
                                        st.name=rs.getString(1);
                                        st.class1=rs.getInt(2);
                                        st.city=rs.getString(3);
                                        st.Address=rs.getString(4);
                                        st.marks1=rs.getInt(5);
                                        st.marks2=rs.getInt(6);
                                        st.total=st.marks1+st.marks2;
                                        tempList.add(st);

                                }
                                rs.close();

                                con.close();
                        }
                        }

                }
                catch(Exception ex)
                {
                System.out.println(ex.getMessage());

                }
                System.out.println(tempList.size());

                return tempList.toArray(new StudentDetails[0]);

        }

        public String Connect()
        {
                String str="";
                try
        {

                Class.forName("com.mysql.jdbc.Driver");
                String URL="jdbc:mysql://localhost:3306/project";
                 con=DriverManager.getConnection(URL,"root","Password");
                str="connection success";

        }
        catch(Exception ex)
        {
                str="Connection Failure";

        }
        return str;

        }
}

Client Side calling Part
===================
        private void checkDatabase()
                        {
                        greetingService.Connect(new AsyncCallback<String>() {
                                public void onFailure(Throwable th)
                                {}
                                public void onSuccess(String st)
                                {
                                        Window.alert(st);
                                }
                        })      ;

                                greetingService.getResult(new 
AsyncCallback<StudentDetails[]>()
                            {
                                        public void onFailure(Throwable cought)
                                        {
                                                
System.out.println(cought.getMessage());
                                        }
                                        public void onSuccess(StudentDetails[] 
st1)
                                        {
                                                try
                                                {
                                                        StudentDetails[] st=st1;
                                                
Window.alert(Integer.toString(st.length));
                                                ftable.setText(0, 0, "Name");
                                                ftable.setText(0,1,"Class");
                                                ftable.setText(0,2,"Address");
                                                ftable.setText(0,3,"City");
                                                ftable.setText(0,4,"Marks1");
                                                ftable.setText(0,5,"Marks2");
                                                ftable.setText(0,6, "Total");

                                                for(int i=0;i<st.size();i++)
                                                {
                                                        StudentDetails 
temp=st.get(i);

                                                        ftable.setText(i+1, 0, 
temp.name);
                                                        
ftable.setText(i+1,1,Integer.toString(temp.class1));
                                                        
ftable.setText(i+1,2,temp.Address);
                                                        
ftable.setText(i+1,3,temp.city);
                                                        
ftable.setText(i+1,4,Integer.toString(temp.marks1));
                                                        
ftable.setText(i+1,5,Integer.toString(temp.marks2));
                                                        ftable.setText(i+1,6, 
Integer.toString(temp.total));

                                                }
                                                if(st.length>0)
                                                
RootPanel.get("PanelContainer").add(ftable);
                                                }
                                                catch(Exception ex)
                                                {
                                                        
System.out.println(ex.getMessage());

                                                }
                                        }
                                })      ;
                        }







Using this code I am trying to call server side procedure getResult()
which should Return an Array containing student details .The code upto
filling of data in the ArrayList works fine and I am able to get
values in the arrayList but when I try to return this value to the
client .I get the folloeing error  :"NativeMethodAccessorImpl.Invoke()
Line not found" .I have tried to implement the same thing by returning
an ArrayList also but I get the same exception there.Please help as
this code has already taken my 3 days.

Following is the stacktrace from debug window
testClientServerJDBC [Web Application]
        com.google.gwt.dev.HostedMode at localhost:2335
                Thread [main] (Running)
                Thread [btpool0-1 - Acceptor0 
selectchannelconnec...@0.0.0.0:8080]
(Running)
                Thread [btpool0-0] (Running)
                Daemon Thread [Timer-0] (Running)
                Thread [btpool0-2] (Suspended)
                        NativeMethodAccessorImpl.invoke(Object, Object[]) line: 
not
available
                        DelegatingMethodAccessorImpl.invoke(Object, Object[]) 
line: not
available
                        Method.invoke(Object, Object...) line: not available
                        RPC.invokeAndEncodeResponse(Object, Method, Object[],
SerializationPolicy) line: 527
                        
GreetingServiceImpl(RemoteServiceServlet).processCall(String) line:
166
                        GreetingServiceImpl(RemoteServiceServlet).doPost
(HttpServletRequest, HttpServletResponse) line: 86
                        
GreetingServiceImpl(HttpServlet).service(HttpServletRequest,
HttpServletResponse) line: 637
                        GreetingServiceImpl(HttpServlet).service(ServletRequest,
ServletResponse) line: 717
                        ServletHolder.handle(ServletRequest, ServletResponse) 
line: 487
                        ServletHandler.handle(String, HttpServletRequest,
HttpServletResponse, int) line: 362
                        SecurityHandler.handle(String, HttpServletRequest,
HttpServletResponse, int) line: 216
                        SessionHandler.handle(String, HttpServletRequest,
HttpServletResponse, int) line: 181
                        
JettyLauncher$WebAppContextWithReload(ContextHandler).handle
(String, HttpServletRequest, HttpServletResponse, int) line: 729
                        
JettyLauncher$WebAppContextWithReload(WebAppContext).handle(String,
HttpServletRequest, HttpServletResponse, int) line: 405
                        RequestLogHandler(HandlerWrapper).handle(String,
HttpServletRequest, HttpServletResponse, int) line: 152
                        RequestLogHandler.handle(String, HttpServletRequest,
HttpServletResponse, int) line: 49
                        Server(HandlerWrapper).handle(String, 
HttpServletRequest,
HttpServletResponse, int) line: 152
                        Server.handle(HttpConnection) line: 324
                        HttpConnection.handleRequest() line: 505
                        HttpConnection$RequestHandler.content(Buffer) line: 843
                        HttpParser.parseNext() line: 647
                        HttpParser.parseAvailable() line: 211
                        HttpConnection.handle() line: 380
                        
SelectChannelConnector$ConnectorEndPoint(SelectChannelEndPoint).run
() line: 395
                        QueuedThreadPool$PoolThread.run() line: 488
                Daemon Thread [MySQL Statement Cancellation Timer] (Running)
        C:\Program Files\Java\jre6\bin\javaw.exe (Aug 17, 2009 12:49:43 PM)



Thanks in Advance


--~--~---------~--~----~------------~-------~--~----~
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-Toolkit@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