Frustrated with GWT

88 views
Skip to first unread message

edprog

unread,
Jul 23, 2011, 8:16:30 PM7/23/11
to Google Web Toolkit
Hello,

I like the look and feel of GWT but I can find out why i am getting
a

Error when invoking the pageable data service :404 <html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1"/>
<title>Error 404 NOT_FOUND</title>
</head>
<body><h2>HTTP ERROR 404</h2>
<p>Problem accessing /timesheettracking/timesheetlogin. Reason:
<pre> NOT_FOUND</pre></p><hr /><i><small>Powered by Jetty://</small>


I have spent 2 days already trying to figure it out and about to give
up. Here is my code


WEB.XML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<!-- Servlets -->
<servlet>
<servlet-name>timesheetLoginServlet</servlet-name>
<servlet-
class>com.timesheet.tmproject.server.TimeSheetLoginServiceImpl</
servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>timesheetLoginServlet</servlet-name>
<url-pattern>/TimeSheetTracking/timesheetlogin</url-pattern>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>TimeSheetTracking.html</welcome-file>
</welcome-file-list>
</web-app>


//TIMESHEET LOGIN SERVICE

package com.timesheet.tmproject.client;

import java.util.List;

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

public interface TimeSheetLoginService extends RemoteService {

public boolean isAuthenticated(String empID, String password );
}

//TIMESHEET LOGIN SERVICE ASYNC

package com.timesheet.tmproject.client;

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

public interface TimeSheetLoginServiceAsync {
public void isAuthenticated(String empID, String
password ,AsyncCallback callback);
}





//TIMESHEETTRACK.JAVA





package com.timesheet.tmproject.client;

import java.util.ArrayList;
import java.util.Iterator;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.PasswordTextBox;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.SourcesTabEvents;
import com.google.gwt.user.client.ui.TabPanel;
import com.google.gwt.user.client.ui.TabListener;
import com.google.gwt.user.client.ui.TabPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class TimeSheetTracking implements EntryPoint {

VerticalPanel vpLogin = new VerticalPanel();
private Label lblLoginEmpID = new Label("Employee ID");
private TextBox txtEmpID = new TextBox();
private Label lblLoginPassword = new Label("**Password ");
private PasswordTextBox txtPassword = new PasswordTextBox();
private Button btnLogin = new Button("Login");
private String _empID;
private String _password;

final TimeSheetLoginServiceAsync timesheetLoginServlet =
(TimeSheetLoginServiceAsync) GWT
.create(TimeSheetLoginService.class);



@SuppressWarnings("deprecation")
public void onModuleLoad() {


ServiceDefTarget endpoint = (ServiceDefTarget)
timesheetLoginServlet;
endpoint.setServiceEntryPoint(GWT.getModuleBaseURL() +
"timesheetlogin");

txtEmpID.setStyleName("txtTextbox");
txtPassword.setStyleName("txtTextbox");

lblLoginEmpID.setStyleName("lblLabels");
lblLoginPassword.setStyleName("lblLabels");

btnLogin.setStyleName("btnButtons");


// Create a tab panel with three items.
TabPanel panel = new TabPanel();
HorizontalPanel hpLogin = new HorizontalPanel();
hpLogin.add(lblLoginEmpID);
hpLogin.add(txtEmpID);
vpLogin.add(hpLogin);

HorizontalPanel hpLogin2 = new HorizontalPanel();
hpLogin2.add(lblLoginPassword);
hpLogin2.add(txtPassword);
hpLogin2.add(btnLogin);
vpLogin.add(hpLogin2);

panel.add(vpLogin, "Login");



panel.setWidth("100%");
panel.selectTab(0);


// Hook up a tab listener to do something when the user selects a
tab.
panel.addTabListener(new TabListener() {
public void onTabSelected(SourcesTabEvents sender, int
tabIndex) {
// Let the user know what they just did.
}

public boolean onBeforeTabSelected(SourcesTabEvents sender,
int tabIndex) {

// Just for fun, let's disallow selection of 'panel'.
// if (tabIndex == 1)
// return false;
return true;
}
});

// Add it to the root panel.
panel.setSize("500px", "250px");
panel.addStyleName("table-center");

RootPanel.get().add(panel);



btnLogin.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
getLoginResult();
}

});
}

private void getLoginResult() {
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
_empID = txtEmpID.toString();
_password = txtPassword.toString();
}

public void onFailure(Throwable caught) {
Window.alert("Error when invoking the pageable data service :" +
caught.getMessage());
}
};


timesheetLoginServlet.isAuthenticated(txtEmpID.toString(),txtPassword.toString(),
callback);

}
}


//TIMESHEETLOGINSERVICEIMPL



package com.timesheet.tmproject.server;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.timesheet.tmproject.client.TimeSheetLoginService;

public class TimeSheetLoginServiceImpl extends RemoteServiceServlet
implements TimeSheetLoginService {

private boolean isAuthentic = false;
private String _empID;
private String _password;

public TimeSheetLoginServiceImpl() {
super();
Authenticate();
}

public boolean Authenticate()
{
Connection conn = null;
try {
Class.forName("com.mysql.jdbc.Driver")
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/
timex", "root", "");

Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("SELECT employeeid, password FROM
employee WHERE " +
"employeeeID="+_empID+" AND password =
"+_password);
if(rs == null)
{
isAuthentic = false;
}
else
{
isAuthentic = true;
}


} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} finally{
try {
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return isAuthentic;
}
public boolean isAuthenticated(String empID, String password) {
_empID = empID;
_password = password;

return Authenticate();
}

}



Please, if you see anything here that may be causing this error, I
would appreciate to post a note. I am new at GWT and I am very
frustrated as I have spent too much time on this task...

Thank you

Gal Dolber

unread,
Jul 25, 2011, 12:09:14 AM7/25/11
to google-we...@googlegroups.com
Maybe the uppercases? try this:

<url-pattern>/timesheettracking/timesheetlogin</url-pattern>


--
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-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.




--
Guit: Elegant, beautiful, modular and *production ready* gwt applications.

http://code.google.com/p/guit/




Jeff Larsen

unread,
Jul 25, 2011, 6:44:25 AM7/25/11
to google-we...@googlegroups.com
Did you map your servlet in your web.xml file? 

Kevin Jordan

unread,
Jul 25, 2011, 9:45:32 AM7/25/11
to Google Web Toolkit
Yeah, definitely looks like a case-sensitive error. It's got
uppercase letters in the mapping of where it's listening on, but all
lowercase in the request.
> Guit: Elegant, beautiful, modular and...
>
> read more »

Jeff Larsen

unread,
Jul 25, 2011, 10:02:33 AM7/25/11
to google-we...@googlegroups.com
oops, i missed the web.xml at the top of the post. Yea, I agree with everyone else. 

JC

unread,
Jul 25, 2011, 10:24:11 AM7/25/11
to Google Web Toolkit
I spent one week trying to connect my GWT Client application to my
Servlet throug RPC and I got a similar problem.
I gave up testing from Eclipse/GWT plugin against my servlet handling
the JDBC connection. It looks like GWT is forcing you to use Jetty and
GWT database.

I solved the problem with the following solution:
I created a Java package (.jar) to handle all JDBC statements only.
The Servlet invokes the classes in that .jar files.
I deployed the Servlet and the package in Tomcat
I wrote a JSP to test the Servlet. It works great.
I generated a jar file with my GWT Client application which implements
RPC to call the Servlet.
I deployed the GWT Client application in Tomcat.
I tested the whole thing successfully.
You can spent about one hours splitting your application in three
pieces, but it'll work.
After that I'm very happy using GWT just for UI.

I hope this can help you.

Greetings,

JC
Reply all
Reply to author
Forward
0 new messages