Syntax error, insert "}" to complete MethodBody - Syntax error, insert "}" to complete ClassBody - jframe

jb1.addActionListener(new ActionListener(){
#Override
public void actionPerformed(ActionEvent e) {
SwingUtilities.invokeLater(new Runnable(){
#Override
public void run() {
.access$0(()1.this).CSV_File1 = 1.this.AutoCSV.this.showSaveFileDialog();
.access$0(()1.this).jtf1.setText(.access$0(()1.this).CSV_File1);
}
});
}
});
The error i'm getting are as follows.
Multiple markers at this line
- Syntax error, insert "}" to complete
MethodBody
- Syntax error, insert "}" to complete
ClassBody
- implements java.lang.Runnable.run
please somebody help me

Related

How can I test #onFailure method?

How could I go to "#Override public void onFailure(Throwable ex) { ... }"?
It always go "#Override public void onSuccess(SendResult<String, KafkaPresponseDto> result) {...}.
I want to print
log.error("Unable to send message=["+kafkaPgResponseDto.toString()+"] due to : " + ex.getMessage());
Please help...
ListenableFuture<SendResult<String, KafkaPgResponseDto>> future = pgResponseKafkaTemplate.send(kurlyTopicNamePgResponse, kafkaPgResponseDto);
future.addCallback(new ListenableFutureCallback<SendResult<String, KafkaPgResponseDto>>(){
#Override
public void onSuccess(SendResult<String, KafkaPgResponseDto> result) {
KafkaPgResponseDto kafkaPgResponseDto = result.getProducerRecord().value();
log.debug("Send message=["+kafkaPgResponseDto.toString()+"] with offset=["+result.getRecordMetadata().offset()+"]");
}
#Override
public void onFailure(Throwable ex) {
log.error("Unable to send message=["+kafkaPgResponseDto.toString()+"] due to : "+ex.getMessage());
kafkaTransactionService.failedProcessingKafkaHistorySave(orderNo, kurlyTopicNamePgResponse, gson.toJson(payload), ex.toString());
}
});
I believe there is no need in the real Kafka to test your functionality. Consider to use a MockProducer for injection into that KafkaTemplate and emulate an error for that onFailure() case: https://www.baeldung.com/kafka-mockproducer

Cannot perform mapquest.com searchQuery

I cannot perform search query.
https://developer.mapquest.com/documentation/searchahead-sdk/android/v1.3/
Tells me that this is correct but it wont work. It throws me an error
private void searchQuery(String queryString){
SearchAheadService mSearchAheadServiceV3;
mSearchAheadServiceV3 = new SearchAheadService(mContext, "uZW4cZzRkNqXaK9oHOrgJVEb6rk3oVM0");
List searchCollections = Arrays.asList(SearchCollection.AIRPORT, SearchCollection.ADMINAREA,
SearchCollection.ADDRESS);
try {
SearchAheadQuery query = new SearchAheadQuery.Builder(queryString, searchCollections).location(new LatLng((float)MapsActivity.mLastLocation.getLatitude(), (float)MapsActivity.mLastLocation.getLongitude())).build();
mSearchAheadServiceV3.predictResultsFromQuery(query,
new SearchAheadService.SearchAheadResponseCallback() {
#Override
public void onSuccess(#NonNull SearchAheadResponse searchAheadResponse) {
Log.i(TAG, "Search Ahead V3 Success - Response: " + searchAheadResponse);
}
#Override
public void onError(Exception e) {
Log.e(TAG, "Search Ahead V3 Failure", e);
}
});
} catch (IllegalQueryParameterException e) {
L.e("Error performing search", e);
}
}
But i got this error:
java.lang.LinkageError: Method org.apache.http.HttpResponse com.mapquest.android.commoncore.network.volley.NetworkHelper$InitialRequestQueueSupplier$1.performRequest(com.android.volley.Request, java.util.Map) overrides final method in class Lcom/android/volley/toolbox/BaseHttpStack; (declaration of 'com.mapquest.android.commoncore.network.volley.NetworkHelper$InitialRequestQueueSupplier$1' appears in /data/app/com.example.locolusmap-S4zcpMbjISCjpC9YmZe9SQ==/base.apk:classes3.dex)
This is an issue that the development team is aware of and we hope to have a fix for this soon. It will be part of the next version of the SDK. I don't have an ETA.

Unable to catch STException in StringTemplate 4

I am unable to catch the STException thrown by the STGroupFile. This is a problem. I need to abort if the template is bad. To reproduce this problem, I have this incorrect template file called tmp.stg:
temp1(param1)::=<<
%if(param1)%
%param1:{%temp2(p)%}; separator"\n"%
%endif%
>>
And this groovy code to process it:
#!/usr/bin/env groovy
#Grab(group="org.antlr", module="ST4", version="4.0.8")
import org.stringtemplate.v4.STGroupFile;
import org.stringtemplate.v4.NumberRenderer;
public class Gex {
public static void main(String [] args) {
System.out.println("Processing...")
File fn = new File("tmp.stg")
STGroupFile group;
try {
group = new STGroupFile(fn.toString());
} catch (Throwable e) {
throw new Exception("Caught first exception");
}
try {
group.registerRenderer(Integer.class, new NumberRenderer());
} catch (Throwable e) {
throw new Exception("Caught second exception");
}
throw new Exception("You should not see this");
}
}
Gex.main()
When I run that script, I get an error message but I cannot catch the exception:
can't load group file file:tmp.stg
The error message comes from STGroupFile.java:
throw new STException("can't load group file "+fileName, e);
But I am unable to catch this exception. How can I catch this exception and abort?
Following the advice of The ANTLR Guy, I extended the STErrorListener to throw an exception instead of printing a message to stderr. It looks like this:
File: lib/GexListener.groovy
import org.stringtemplate.v4.STErrorListener;
import org.stringtemplate.v4.misc.STMessage;
import org.stringtemplate.v4.misc.ErrorType;
class GexListener implements STErrorListener {
#Override
public void compileTimeError(STMessage msg) {
throw new Exception(msg.toString());
}
#Override
public void runTimeError(STMessage msg) {
if ( msg.error != ErrorType.NO_SUCH_PROPERTY ) { // ignore these
throw new Exception(msg.toString());
}
}
#Override
public void IOError(STMessage msg) {
throw new Exception(msg.toString());
}
#Override
public void internalError(STMessage msg) {
throw new Exception(msg.toString());
}
public void error(String s) { error(s, null); }
public void error(String s, Throwable e) {
System.err.println(s);
if ( e!=null ) {
throw new Exception(msg.toString());
}
}
}
Then the master script bin/gex.groovy looks like this:
#!/bin/bash
//usr/bin/env groovy -cp ${0%/*}/../lib "$0" "$#"; exit $?
#Grab(group="org.antlr", module="ST4", version="4.0.8")
import org.stringtemplate.v4.STGroupFile;
import org.stringtemplate.v4.NumberRenderer;
import GexListener
public class Gex {
public static void main(String [] args) {
System.out.println("Processing...")
File fn = new File("tmp.stg")
STGroupFile group;
GexListener listener = new GexListener();
group = new STGroupFile(fn.toString());
group.setListener(listener);
group.registerRenderer(Integer.class, new NumberRenderer());
System.out.println("You should not see this line")
}
}
Gex.main()
When it executes, there is a nasty side effect where the stacktrace is printed twice, but the program aborts before printing the last sentence "You should not see this line", which is the desired behaviour.
As you pointed out in a separate email: "I discovered that the exception is actually caught and not re-thrown. This happens inside STGroup.java:"
catch (Exception e) {
errMgr.IOError(null, ErrorType.CANT_LOAD_GROUP_FILE, e, fileName);
}
Why not override the IOError function (or a function in the listener that it calls?) to just re-throw e?

Issue with Google Contacts API

I'm running an issue with gwt-oauth and Google contacts API.
I use gwt-oauth to login and everything works fine.
While running the RPC for retrieving the contacts I get
WARNING: Authentication error: Unable to respond to any of these challenges: {}
java.lang.NullPointerException: No authentication header information
Here is the code in Client
Button button = new Button("Authenticate with Google");
button.addClickHandler(new ClickHandler() {
#Override
public void onClick(ClickEvent event) {
final AuthRequest req = new AuthRequest(K.GOOGLE_AUTH_URL, K.GOOGLE_CLIENT_ID).withScopes(K.CONTACTS_SCOPE, K.AUTH_SCOPE);
AUTH.expiresIn(req);
AUTH.login(req, new Callback<String, Throwable>() {
#Override
public void onSuccess(final String token) {
greetingService.loginDetails(token, new AsyncCallback<LoginInfo>() {
#Override
public void onSuccess(LoginInfo result) {
greetingService.getContactList(token, new AsyncCallback<Boolean>() {
#Override
public void onSuccess(Boolean result) {
Window.alert("oh");
}
#Override
public void onFailure(Throwable caught) {
Window.alert("Error:\n" + caught.getMessage());
}
});
}
#Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}
});
}
#Override
public void onFailure(Throwable caught) {
Window.alert("Error:\n" + caught.getMessage());
}
});
}
});
And here the serverside for contacts:
try {
ContactsService s = new ContactsService(K.APPLICATION_NAME);
s.setProtocolVersion(ContactsService.Versions.V3);
s.setAuthSubToken(token);
s.setHeader("Authorization", "Bearer " + token);
for (ContactEntry entry : s.query(new Query(new URL(K.CONTACTS_SCOPE)), ContactFeed.class).getEntries())
System.out.println(entry.toString());
} catch (Exception e) {
e.printStackTrace();
}
return true;
This was working couple of weeks ago...
I assume is not a scope issue since loginDetails works properly...
Any idea?
Solved.
Scope for contacts in Auth was set to: https://www.google.com/m8/feeds/contacts/default/full/
Apparently this doesn't work anymore and I just set https://www.google.com/m8/feeds/ for auth
and the full url for querying in ContactService

GWT client "throws Exception" cause compling problem

I try to use get result from a api called j-calais, and then out put the result on a web page, i write all the code in client, but it cant compile right, dont know why??? please help. the source code like below:
there is no obvious error arise, but it cant be compile successfully..... thanks a lot:
public void onModuleLoad() {
// Create table for stock data.
stocksFlexTable.setText(0, 0, "Type");
stocksFlexTable.setText(0, 1, "Name");
// Assemble Add Stock panel.
addPanel.add(newSymbolTextBox);
addPanel.add(addStockButton);
// Assemble Main panel.
mainPanel.add(stocksFlexTable);
mainPanel.add(addPanel);
mainPanel.add(lastUpdatedLabel);
// Associate the Main panel with the HTML host page.
RootPanel.get("stockList").add(mainPanel);
// Move cursor focus to the input box.
newSymbolTextBox.setFocus(true);
// Listen for mouse events on the Add button.
addStockButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
try {
addStock();
} catch (Exception e) {
e.printStackTrace();
}
}
});
// Listen for keyboard events in the input box.
newSymbolTextBox.addKeyPressHandler(new KeyPressHandler() {
public void onKeyPress(KeyPressEvent event) {
if (event.getCharCode() == KeyCodes.KEY_ENTER) {
try {
addStock();
} catch (Exception e) {
e.printStackTrace();
}
}
}
});
}
private void addStock() throws Exception {
final String url_s = newSymbolTextBox.getText().toUpperCase().trim();
newSymbolTextBox.setFocus(true);
newSymbolTextBox.setText("");
int row = stocksFlexTable.getRowCount();
CalaisClient client = new CalaisRestClient("ysw5rx69jkvdnzqf6sgjduqj");
System.out.print("read success...\n");
URL url = new URL(url_s);
CalaisResponse response = client.analyze(url);
for (CalaisObject entity : response.getEntities()) {
System.out.println(entity.getField("_type") + ":"
+ entity.getField("name"));
stocks.add(entity.getField("_type"));
stocksFlexTable.setText(row, 0, entity.getField("_type"));
stocksFlexTable.setText(row, 1, entity.getField("name"));
}
for (CalaisObject topic : response.getTopics()) {
System.out.println(topic.getField("categoryName"));
}
}
}
GWT only handles unchecked exceptions so you can throw Runtime Exceptions
or write your own Exception that extends from Runtime Exception then it will not cause any compile time problem
void f() throws NullPointerException // will not cause any problem because it is Runtime exception so unchecked
void f() throws IllegalAccessException // it is checked exception so there will be problem at compile time