I'm doing some text mining application. It consists of TextRazor API Java Swing. How can I use JButton to run main() class? Once the button is clicked, the code in main() class must be triggered. Below is the code, please help me.
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
//I want the main class to be called here**
}
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
JOptionPane.showMessageDialog(null, "Completed Analysis!","Alert", 1);
jButton5.setEnabled(false);
jTextArea2.setEditable(false);
jTextArea3.setEditable(false);
}
/**
* #param args
* #throws NetworkException
*/
public static void main(String[] args) throws NetworkException, AnalysisException {
// Sample request, showcasing a couple of TextRazor features
String API_KEY = "7d5066bec76cb47f4eb4e557c60e9b979f9a748aacbdc5a44ef9375a";
TextRazor client = new TextRazor(API_KEY);
client.addExtractor("words");
client.addExtractor("entities");
client.addExtractor("entailments");
client.addExtractor("senses");
client.addExtractor("entity_companies");
String rules = "entity_companies(CompanyEntity) :- entity_type(CompanyEntity, 'Company').";
client.setRules(rules);
AnalyzedText response = client.analyze("Barclays misled shareholders and the public RBS about one of the biggest investments in the bank's history, a BBC Panorama investigation has found.");
for (Sentence sentence : response.getResponse().getSentences()) {
for (Word word : sentence.getWords()) {
System.out.println("----------------");
System.out.println("Word: " + word.getLemma());
for (Entity entity : word.getEntities()) {
System.out.println("Matched Entity: " + entity.getEntityId());
}
for (Sense sense: word.getSenses()) {
System.out.println("Word sense: " + sense.getSynset() + " has score: " + sense.getScore());
}
}
}
// Use a custom rule to match 'Company' type entities
for (Custom custom : response.getResponse().getCustomAnnotations()) {
for (Custom.BoundVariable variable : custom.getContents()) {
if (null != variable.getEntityValue()) {
for (Entity entity : variable.getEntityValue()) {
System.out.println("Variable: " + variable.getKey() + " Value:" + entity.getEntityId());
}
}
}
}
}
Main method in Class is also a normal method, which is designed to start the java application by JVM. But, you can also call it in your method
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
JOptionPane.showMessageDialog(null, "Completed Analysis!","Alert", 1);
jButton5.setEnabled(false);
jTextArea2.setEditable(false);
jTextArea3.setEditable(false);
ClassName.main(new String[]{"arg1","arg2"});
}
added dummy arguments to just invoke the main method
Related
Problem summary.
My app triggers audio messages based on BT data that it receives from sensors. It receives the data at 200Hz (once every 5ms). In order to test without having to wait for data from these sensors, I have developed a simulator (part of my program running on android) that reads recorded sensor data from a file and plays them back at the same speed as the sensors would normally send the data to the phone (this code uses a lot of multitasking and scheduling to get the timing right).
The audio messages are played with the java MediaPlayer. Sometimes, the played audio is interrupted based on the incoming data, with a mediaplayer.stop(). I then use prepare() to get it ready to start playing the next time this is required by the data.
The issue is that after the prepare() call, spurious onCompletion calls sometimes occur and I do not understand how they are triggered / how to get rid of them.
Expected and actual results.
I have a CMediaPlayer class as follows:
public class CMediaPlayer extends MediaPlayer {
private String name;
private Activity act;
private Cue cue;
public Long startedAt;
public CMediaPlayer (Activity act, Cue rc,
String audioFileName, String audioSet,
String audioFileExtension, String mpName,
MediaPlayer.OnCompletionListener cListen,
MediaPlayer.OnPreparedListener pListen) {
super();
if (checkAndroidPermission(act, Manifest.permission.READ_EXTERNAL_STORAGE)) {
if (audioFileExists(act, audioFileName + audioSet)) {
init(act, rc, mpName);
String fullFileName = Environment.getExternalStorageDirectory().getPath() + "/" + PHONE_AUDIO_DIR + "/" +
audioFileName + audioSet + audioFileExtension;
makeStartReady(fullFileName, cListen, pListen);
} else {
Log.e(act.getString(R.string.app_name), audioFileName + audioSet + " file not found under /" + PHONE_AUDIO_DIR + " directory!");
}
} else {
Log.e(act.getString(R.string.app_name), " Missing READ_EXTERNAL_STORAGE permission for this app.");
}
}
private void init(Activity act, Cue rc, String name) {
this.name = name;
this.act = act;
this.cue = rc;
this.startedAt = 0L;
}
private void makeStartReady(String fileName, MediaPlayer.OnCompletionListener cListen, MediaPlayer.OnPreparedListener pListen) {
try {
setDataSource(fileName);
prepare();
setOnCompletionListener(cListen);
setOnPreparedListener(pListen);
setVolume(1.0f,1.0f);
} catch (Exception e) {
Log.e(act.getString(R.string.app_name), fileName + " file not found under /" + PHONE_AUDIO_DIR + " directory!");
e.printStackTrace();
}
}
public void prepare(Activity act, String msg) {
try {
this.prepare();
} catch (Exception e) {
Log.e(act.getString(R.string.app_name), msg + " failed!");
e.printStackTrace();
}
}
public void setOnCompletionListener(OnCompletionListener listener) {
super.setOnCompletionListener(listener);
}
public String getName() {
return name;
}
public void startCMP() {
this.startedAt = this.cue.mState.counter.cur;
cue.mState.callBackDebugLine(name + ".startCMP(" + this.startedAt + ")");
try {
super.start();
} catch (Exception e) {
Log.e(act.getString(R.string.app_name), "cannot start " + name + e.toString());
if (cue != null) cue.mState.callBackDebugLine("cannot start " + name);
}
}
public void stopCMP() {
if (isPlaying()) {
stop();
if (cue != null) cue.mState.callBackDebugLine(name + ".stopCMP(" + this.startedAt + ")");
try {
prepare();
} catch (Exception e) {
Log.e(act.getString(R.string.app_name), name + ".prepareAsync() failed!");
e.printStackTrace();
}
}
}
public void closeCMP() {
cue.mState.callBackDebugLine( name + ".closeCMP()");
reset();
release();
}
}
The onPreparedListener looks like this:
(MediaPlayer mp) -> {
if (mState.debugWriter != null)
addDebugLine(mState, ((CMediaPlayer)mp).getName() + ".onPrepared");
((CMediaPlayer)mp).startedAt = -1L;
});
Starting audio with startCMP() and stopping it with stopCMP() works correctly (ie, the onPrepared listener is called and nothing more) when my onCompletionListener looks like this:
(MediaPlayer mp) -> {
addDebugLine(mState, ((CMediaPlayer)mp).getName() + ".onCompletion "); // + ((CMediaPlayer)mp).startedAt);
},
addDebugLine writes debug information to a csv file for analysis after running the program as follows:
public static void addDebugLine(WalkState ws, String label) {
Date now = new Date();
try {
ws.debugWriter.append(Common.formattedNow("HH_mm_ss_SSS") + ","
+ (now.getTime() - ws.startTime) + "," + ws.counter.cur
+ "," + (ws.counter.cur-ws.counter.start) * 5
+ "," + label + "\n");
} catch (IOException e) {
Log.d(mCtx.getString(R.string.app_name), "exception in addDebugLine");
e.printStackTrace();
}
}
When the onCompletion listener is modified as
(MediaPlayer mp) -> {
addDebugLine(mState, ((CMediaPlayer)mp).getName() + ".onCompletion ") + ((CMediaPlayer)mp).startedAt);
},
(the only difference is that a Long is appended to the message that is passed to addDebugLine)
then it is called multiple times after the onPrepared is called. The output in the debug csv file (with the name of the MediaPlayer equal to "dangerStart") looks like this:
09_59_44_176,34515,6866,34330,dangerStart.onCompletion -1
09_59_44_177,34516,6866,34330,dangerStart.onCompletion -1
09_59_44_177,34516,6866,34330,dangerStart.onCompletion -1
The first string on each line is the phone time, the 2nd string (actually a Long) the time since start of the program, the 3rd is the counter of the hardware that transmits data to the phone. Each increase by 1 on this counter represents 5ms.
The failure happens in two different ways: it can happen after a stopCMP() call (and after onPrepared()), or even just after a startCMP() when no stopCMP() has been called and long before normal completion of the audio. This happens shortly (like 15ms) after the call to startCMP() and long before actual completion of the audio (which lasts approx 5.2s).
So, this output means that the mediaPlayer with name dangerStart calls onCompletion 3x in a very short time period (roughly 1 ms). As per the media player state diagram (https://developer.android.com/reference/android/media/MediaPlayer#StateDiagram), this should not happen.
With this one set of data, adding the Long to the addDebugLine message results in the effect described. With other sets of data, this is not the case and the multiple onCompletion calls may happen without having expanded the addDebugLine message. I have quite a few datapoints but cannot find any rhyme or reason behind them.
I would hope to find what goes wrong with this data set and then to test the solution on the other data sets to confirm this really fixes the problem in general.
hoping someone can help with this as it's frying my brain now. I am new to RMI so this could be a basic amateurish mistake .
So I have a layered system where a userinterface creates an interface for an application layer and calls a getRecord function using RMI. This in turn creates an interface to a datalayer which retrieves the information from a database returning it to the appLayer which returns it to the userinterface. This works fine and the JTextFields are updated perfectly.
The problem is when i then try to send this information back through the applayer to another interface. When it gets to the new interface i can output the information to the console but it WILL NOT update the JTextFields on this interface and i cannot for the life of me understand why not.
My Main Interface:
IPatientRecord testRecord;
IAppLayer appLayer;
public class MainOffice extends JFrame {
private JPanel MainPanel;
private JPanel Background;
private JPanel TopPanel;
private JPanel LeftPanel;
private JPanel RightPanel;
private JTextField searchTextBox;
private JButton searchButton;
private JTextField NHSRegistrationNoTextField;
private JTextField patientNameTextField;
private JTextField addressTextField;
private JTextField postCodeTextField;
private JTextField conditionTextField;
private JButton confirmAndSendButton;
public MainOffice() {
add(MainPanel);
setSize(400, 400);
try {
Registry patientRegistry = LocateRegistry.getRegistry(1096);
Registry registry = LocateRegistry.getRegistry(1099);
testRecord = (IPatientRecord) patientRegistry.lookup("patientRecord");
appLayer = (IAppLayer) registry.lookup("appLayer");
System.out.println("Patient Record Interface Ready");
}
catch (Exception ex) {
System.out.println("Exception Creating Patient Record Interface: " + ex.getMessage());
}
searchButton.addActionListener(new ActionListener() {
#Override
public void actionPerformed(ActionEvent e) {
try {
testRecord = appLayer.getPatientRecord(Integer.parseInt(searchTextBox.getText()));
System.out.println("Test Record " + testRecord.getName());
updateForm();
System.out.println("Patient returned to Main Office " + testRecord.getName());
}
catch (Exception ex) {
System.out.println("Exception in Search Button: " + ex.getMessage());
}
}
});
confirmAndSendButton.addActionListener(new ActionListener() {
#Override
public void actionPerformed(ActionEvent e) {
try {
System.out.println("Patient: " + testRecord.getName());
System.out.println("Confirm and send pressed/nDetails sent: " + testRecord.getName());
appLayer.sendToAmbulance(testRecord);
}
catch (Exception ex) {
System.out.println("confirm and Send Exception: " + ex.getMessage());
}
}
});
}
public void updateForm() {
try{
NHSRegistrationNoTextField.setText(String.valueOf(testRecord.getNhsRegistrationNo()));
patientNameTextField.setText(testRecord.getName());
addressTextField.setText(testRecord.getAddress());
postCodeTextField.setText(testRecord.getPostCode());
conditionTextField.setText(testRecord.getCondition());
}
catch (RemoteException rex) {
System.out.println("Update form exception: " + rex.getMessage());
}
}
public static void main (String args[] ) {
MainOffice mainOffice = new MainOffice();
mainOffice.setVisible(true);
}
My App LAyer:
public class AppLayer implements IAppLayer {
List ambulances;
List hospitals;
Dictionary ambulanceDictionary;
IPatientRecord patientRecord;
public AppLayer() throws RemoteException{
ambulances = new ArrayList();
hospitals = new ArrayList();
ambulanceDictionary = new Hashtable();
}
#Override
public IPatientRecord getPatientRecord(int nhsNo) throws RemoteException {
try {
Registry registry = LocateRegistry.getRegistry(null,1098);
IDataLayer dataLayer = (IDataLayer) registry.lookup("dataLayer");
patientRecord = dataLayer.getPatientRecord(nhsNo);
System.out.println("Patient returned: " + patientRecord.getName());
//sendToAmbulance(patientRecord);
return patientRecord;
}
catch (Exception ex) {
System.out.println("Error in AppLayer: " + ex.getMessage() + " /n/nSee getPatientRecord in AppLayer");
return null;
}
}
The Function i Used to send to the other UI: The UI registers with the applayer first using another function. This uses that information to send the record to the right client essentially. The Main office UI calls this on through the applayer interface
public void sendToAmbulance(IPatientRecord patientRecord) {
Enumeration keys = ambulanceDictionary.keys();
Enumeration elements = ambulanceDictionary.elements();
int port = Integer.parseInt(keys.nextElement().toString());
String callSign = ambulanceDictionary.get(port).toString();
try {
System.out.println("Searching on port: " + port);
Registry registry2 = LocateRegistry.getRegistry(port);
System.out.println("Looking up callSign: " + callSign);
System.out.println("made it here");
IAmbulance ambulance = (IAmbulance) registry2.lookup(callSign);
System.out.println("and here");
ambulance.Update(patientRecord);
System.out.println("maybe here");
if (ambulance.Update(patientRecord)){
ambulanceDictionary.remove(port);
System.out.println(callSign + "removed from list");
System.out.println("");
}
else{
System.out.println("Failed to update ambulance " + callSign);
}
}
catch (Exception ex) {
System.out.println("Exception in sendToAmbulance: " + ex.getMessage());
}
}
The above function the calls Update on the Ambulance
public Boolean Update(IPatientRecord patientRecord) {
try {
NHSRegistrationNoTextField.setText(String.valueOf(patientRecord.getNhsRegistrationNo()));
patientNameTextField.setText(patientRecord.getName());
addressTextField.setText(patientRecord.getAddress());
postCodeTextField.setText(patientRecord.getPostCode());
conditionTextField.setText(patientRecord.getCondition());
ReadyStatusTxt.setText("ON CALL");
return true;
}
catch (Exception ex) {
System.out.println("Exception in Update: " + ex.getMessage());
return false;
}
}
It doesn't even update the ReadyStatusTxt.setText("On Call") yet returns true!
I've tried so many things. Originally i wasnt using the Patient record interface between the layers, I was being lazy but I've updated it so each different layer has to go through the Patient Interface and it still works the same way as before.
I added a seperate function to ambulance that would then call the database again pull the details for itself and then update it with this and it still will not update.
Is It as simple as I cant drive the update from an external class
Oh and another thing is if i put System.out.Println(patientRecord.getName()); in the above function it prints out the ******* name that i want to update the above aforementioned JtextField. I've tried saving that into Strings first and then adding it to the JtextField but that doesn't work either
Okay, so I want it so if player typs ::help, the method from RequestHelp.java will run,
Commandif (playerCommand.startsWith("help") && (c.playerRights >= 0)) {
c.sendMessage("A staff member has been contacted, please wait.");
(right here is where I want the method from the other class to run'
}
this is the method from RequestHelp.java
public static void callForHelp(Client c) {
if (System.currentTimeMillis() - c.lastRequest < 30000) {
c.sendMessage("It has only been "+ getTimeLeft(c) +" seconds since your last request for help!");
c.sendMessage("Please only request help from the staff every 30 seconds!");
if (!requestingHelp) {
c.setSidebarInterface(3, 3213);
c.getPA().sendFrame106(3);
}
return;
}
requestingHelp = true;
otherPlayer = c.playerName;
c.lastRequest = System.currentTimeMillis();
setInterface(c);
PlayerHandler.messageAllStaff(Misc.optimizeText(getPlayer().playerName) +" needs help, their cords are: "+ playerCoords() +".", true);
}
RequestHelp helper = new RequestHelp();
if(playerCommand.equals("::help")) {
helper.callForHelp(client);
}
This should work.
I am having trouble with returning string array on a client and server environment. The result I getting is nothing when I compiled the client application.
server application
public String[] getFlight() throws Exception {
AvailableFlights todayFlight = new AvailableFlights();
List<Flight> flights_today = todayFlight.getFlightDetail();
List<String> flights = new ArrayList<String>();
try {
flights_today = this.unmarshal(new File("Flights.xml"));
for (Flight flight : flights_today) {
String flightDetail = flight.getJourney()
+ " " + flight.getAirline()
+ " "+ String.valueOf(flight.getConnections())
+ " "+ String.valueOf(flight.getCost())
+ " "+ flight.getDestination()
+ " "+ flight.getOrigin()
+ " "+ String.valueOf(flight.getSeats());
flights.add(flightDetail);
System.out.println(flightDetail);
}
} catch (Exception e) {
}
return (String[]) flights.toArray();
}
client java application
import org.me.kettravel.*;
public class JavaApplication5 {
public static void main(String[] args) {
try {
System.out.println(getFlight());
} catch (Throwable ex) {
}
}
private static java.util.List<java.lang.String> getFlight() throws Exception_Exception {
org.me.kettravel.ReadFlightService service = new org.me.kettravel.ReadFlightService();
org.me.kettravel.ReadFlight port = service.getReadFlightPort();
return port.getFlight();
}
Additionally I have tried a small experiment with "hello" like below on the server app and it worked fine, so I know that the web service is working fine but I just can't seem to pass/return the flights String array to the client app.
String i = "hello";
return i;
PS: When I try to run the server app with public static void main (String[] args) { constructor and without return, the app printed out the arraylist perfectly from unmarshalling xml convert it to arraylist and do system.out.print.
I would be grateful if anyone could shed some light as I am really stuck on this. Thanks.
04/01/2012 (19:16) - Adjustment has been made suggested by Genzer, the client app still not getting any response from server app.
04/01/2012 (23:24) - Adjustment has been made suggested by Bohemian can be seen below, the client app is now getting an error checking javax.xml.ws.soap.SOAPFaultException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;
public static void main(String[] args) {
try {
Object obj = getFlight();
System.out.println(obj);
} catch (Throwable ex) {
System.out.println(ex);
}
}
06/01/2013 (16:20) - I have just addressed my mistake as the XML file was empty from tests to tests, however it is now have data in the xml file. I have just created a test class to see if readFlight returns anything to a class that it's in a same project/source package. Result is a success... really running out of ideas =/ as I have tested the web service by sending a simple hello string over to client app and worked no problem.
test class
public class test {
public static void main(String[] args) {
readFlight rF = new readFlight();
try {
System.out.println(rF.getFlight());
} catch (Throwable ex) {
System.out.println(ex);
}
}
}
Output from the test class: [London to Amsterdam KLM 1 200.0 Amsterdam London 100, London to Kuala Lumper Malaysia Airline 1 750.0 Kuala Lumper London 100, London to Manchester British Airway 1 50.0 Manchester London 56]
10/01/2013 (18:13) - PROBLEM SOLVED. You have to give full directory to the unmarshall file. Example: C:/Users/User/Documents/NetBeansProjects/WebService/booking.xml
The problem is that you have two different variables named flights. You populate one and return the other.
You could remove public static String[] flights and modify the method like this:
public List<String> getFlight() throws Exception {
Flight nextFlight = new Flight();
AvailableFlights todayFlight = new AvailableFlights();
List<Flight> flights_today = todayFlight.getFlightDetail();
// Since you you List for Flight, why not here
List<String> flights = new ArrayList<String>();
try {
flights_today = readFlight.unmarshal(new File("Flights.xml"));
for (Flight flight : flights_today) {
String flightDetail = flight.getJourney()
+ " " + flight.getAirline()
+ " "+ String.valueOf(flight.getConnections())
+ " "+ String.valueOf(flight.getCost())
+ " "+ flight.getDestination()
+ " "+ flight.getOrigin()
+ " "+ String.valueOf(flight.getSeats());
flights.add(flightDetail);
}
} catch (Exception e) {
}
return flights;
}
You have committed a "no no", which may be hiding the problem:
catch (Exception e) {
}
You should never (well, rarely) catch Exception. Especially when your catch block is empty.
There could be an unchecked exception, like NullPointerException, being thrown within your loop, but you wouldn't know.
Try removing the catch and leaving only soecific Exceptions (if any) that are declared to be thrown.
If one of the method is declared as throwing Exception, then at the very least, you should do this:
catch (Exception e) {
System.out.println(e);
}
Below are my service, serviceImpl and async callback interfaces. Appreciate if someone can help me understand why the submitTeam(...) isn't being called (I howeve see that isValidEmail(...) is being invoked when used). At least provide me the approach for debugging this as currently I am unable to use eclipse debugger (eclipse is not stopping at breakpoints) and the sysout/syserr statements are not being logged to the console either :-(.
#RemoteServiceRelativePath("registrationService")
public interface RegistrationService extends RemoteService
{
Boolean isValidEmail(String email);
String submitTeam(String teamName, List<Player> players);
}
public interface RegistrationServiceAsync
{
void isValidEmail(String email, AsyncCallback<Boolean> callback);
void submitTeam(String teamName, List<Player> players, AsyncCallback<String> callback);
}
public class SubmitTeamCallback implements AsyncCallback<String> {
private final Label status;
public SubmitTeamCallback(Label s) {
status = s;
}
public void onFailure(Throwable caught) {
status.setText(caught.getMessage());
}
public void onSuccess(String result) {
System.out.println("" + getClass().getName() + " : " + result);
status.setText(result);
}
}
public class RegistrationCallback implements AsyncCallback<Boolean>
{
private final Label status;
private final PlayerWidget playerWidget;
private Boolean isValidSharedFlag;
public RegistrationCallback(Label s, PlayerWidget pw, Boolean isValid)
{
status = s;
playerWidget = pw;
setIsValidSharedFlag(isValid);
}
public void onFailure(Throwable caught)
{
status.setText(caught.getMessage());
}
public void onSuccess(Boolean result)
{
if (result.equals(Boolean.FALSE))
{
playerWidget.invalidEmail();
String oldText = status.getText();
status.setText(oldText + "Please specify a valid email address for the captain.");
setIsValidSharedFlag(Boolean.FALSE);
} else
{
playerWidget.validEmail();
String newText = status.getText().replace("Please specify a valid email address for the captain.", "");
status.setText(newText);
setIsValidSharedFlag(Boolean.TRUE);
}
}
public void setIsValidSharedFlag(Boolean isValidSharedFlag)
{
this.isValidSharedFlag = isValidSharedFlag;
}
public Boolean getIsValidSharedFlag()
{
return isValidSharedFlag;
}
}
public class RegistrationServiceImpl extends RemoteServiceServlet implements
RegistrationService {
Logger logger = Logger.getLogger("");
private final Emailer emailer = new Emailer();
private final EmailValidator validator = new EmailValidator();
public Boolean isValidEmail(String email) {
return validator.validate(email);
}
public String submitTeam(String teamName, List<Player> players) {
logger.log(Level.SEVERE, "This is a test log");
System.out.println("This is a test log");
boolean emailSent = false;
for (Player p : players) {
System.out.println("Emailing to captain");
if (p instanceof Captain) {
if (!validator.validate(p.getEmail())) {
return "Please specify a valid email";
}
System.out.println("Emailing to captain");
emailSent = emailer.email(p);
}
}
if (emailSent) {
System.out.println("Email sent successfully");
return teamName
+ " has been successfully registered. Please pay the registration fee to confirm registration. Thank you.";
} else {
return "Unable to send email. Please email the team details [Team name, minimum of 6 players, captain's email address and phone number] to funpluscharity#gmail.com";
}
}
}
Below method is going to invoke the RPC calls
private void registerTeam() {
System.out.println("Received request to dubmit team");
StringBuilder statusText = new StringBuilder();
try {
Boolean isValid = true;
RegistrationServiceAsync service = (RegistrationServiceAsync) GWT
.create(RegistrationService.class);
ServiceDefTarget serviceDef = (ServiceDefTarget) service;
System.err.println(".........." + GWT.getModuleBaseURL());
serviceDef
.setServiceEntryPoint("/services/registrationService");
if (teamName.getText() == null
|| teamName.getText().length() == 0) {
isValid = false;
statusText.append("Please specify team name. ");
}
Player captain = getCaptain();
if (!atleast6PlayersAreSpecified()) {
isValid = false;
statusText.append("Please specify atleast 6 players. ");
}
if (captain == null) {
isValid = false;
statusText.append("Please designate a captain. ");
}
System.out.println("Is request valid? " + isValid);
if (isValid.equals(Boolean.TRUE)) {
System.out.println("RPC - submitTeam start ");
System.out.println("" + getPlayers());
SubmitTeamCallback callback = new SubmitTeamCallback(status);
service.submitTeam(teamName.getText(), getPlayers(),
callback);
System.out.println("RPC - submitTeam end");
} else {
status.setText(statusText.toString());
}
} catch (Exception e) {
e.printStackTrace();
System.err.println(e.getMessage());
}
}
Made some progress after adding Window.alert(...) based on #Pistol suggestion and it is going to onFailure(Throwable t) method of the SubmitTeamCallback class.
unknown.com_google_gwt_user_client_rpc_SerializationException_SerializationException__Ljava_lang_String_2V(Unknown Source)
An alternative method to debug client side code is using Window.alert(...). For example placing it in your callback onFailure() method to see caught messages for a start. Or you can use FireBug or something similar to see if the rpc-call is actually being made?
Edit :
Are you sure your Player class implements IsSerializable and have an empty constructor? Check out Serializable User-Defined Classes.
Figured this out. The POJO's should have a default constructor and the one's I am using didn't have one. GWT compiler didn't complain either. Not sure why.