Where to see all possible error code of AwsServiceException? - amazon-web-services

I want to handle AwsServiceException based on the error code returned.
Where web page lists out all those possible error code? I cannot find it in the java doc.
https://sdk.amazonaws.com/java/api/2.0.0/software/amazon/awssdk/awscore/exception/AwsServiceException.html
private RuntimeException handleS3Exception(final AwsServiceException exception) {
if (exception.awsErrorDetails().errorCode().equals("NoSuchKey")) {
return new ObjectNotFoundException();
} else {
return exception;
}
}
Thank you!

Related

Error 'unknown MongoDB operation 'aggregate'' when using aggregate in WSo2 Integration Studio?

I am working Wso2 Integration Studio 8.1 version. I want to using aggregate query. But Wso2 Integration Studip giving error as DS Fault Message: Error in MongoQuery.runQuery: DS Fault Message: Unknown MongoDB operation 'aggregate'
I'm afraid it seems the Micro Integrator doesn't support it at the moment. This is from the code which supports the following operations.
private DBConstants.MongoDB.MongoOperation convertToMongoOp(String operation) throws DataServiceFault {
if (DBConstants.MongoDB.MongoOperationLabels.COUNT.equals(operation)) {
return DBConstants.MongoDB.MongoOperation.COUNT;
} else if (DBConstants.MongoDB.MongoOperationLabels.DROP.equals(operation)) {
return DBConstants.MongoDB.MongoOperation.DROP;
} else if (DBConstants.MongoDB.MongoOperationLabels.FIND.equals(operation)) {
return DBConstants.MongoDB.MongoOperation.FIND;
} else if (DBConstants.MongoDB.MongoOperationLabels.FIND_ONE.equals(operation)) {
return DBConstants.MongoDB.MongoOperation.FIND_ONE;
} else if (DBConstants.MongoDB.MongoOperationLabels.INSERT.equals(operation)) {
return DBConstants.MongoDB.MongoOperation.INSERT;
} else if (DBConstants.MongoDB.MongoOperationLabels.REMOVE.equals(operation)) {
return DBConstants.MongoDB.MongoOperation.REMOVE;
} else if (DBConstants.MongoDB.MongoOperationLabels.UPDATE.equals(operation)) {
return DBConstants.MongoDB.MongoOperation.UPDATE;
} else if (DBConstants.MongoDB.MongoOperationLabels.EXISTS.equals(operation)) {
return DBConstants.MongoDB.MongoOperation.EXISTS;
} else if (DBConstants.MongoDB.MongoOperationLabels.CREATE.equals(operation)) {
return DBConstants.MongoDB.MongoOperation.CREATE;
} else {
throw new DataServiceFault("Unknown MongoDB operation '" + operation + "'");
}
}
Even the MongoDB connector doesn't support Aggregate operation, hence your best option is to write a Custom mediator to get this done or try to improve the existing connector.

how to apply in DebuggerHiddenAttribute dependent/cascade methods

I'm trying to ignore a exception that happen when run my test Methods.
I`m using a unitTest proyect.
The problem apears when
TestCleanup Method runs. It's a recursive method. This method clean all entities created in DB during the test. This is a recursive method because of dependences.
Anyway this method call to delete generic method in my ORM(Petapoco). It throws an exception if it can't delete the entity. Any problem, it run again with recursive way until delete it.
Now the problem, if i'm debugging VS stop a lot of times in Execute method because of failed deletes. But I can't modify this method to ignore it. I need a way to ignore this stops when i'm debugging tests. A way like DebuggerHiddenAttribute or similar.
Thanks!
I tried to use DebuggerHiddenAttribute, but cannot works in methods called by main method.
[TestCleanup(), DebuggerHidden]
public void CleanData()
{
ErrorDlt = new Dictionary<Guid, object>();
foreach (var entity in TestEntity.CreatedEnt)
{
try
{
CallingTest(entity);
}
catch (Exception e)
{
if (!ErrorDlt.ContainsKey(entity.Key))
ErrorDlt.Add(entity.Key, entity.Value);
}
}
if (ErrorDlt.Count > 0)
{
TestEntity.CreatedEnt = new Dictionary<Guid, object>();
ErrorDlt.ForEach(x => TestEntity.CreatedEnt.Add(x.Key, x.Value));
CleanData();
}
}
public int Execute(string sql, params object[] args)
{
try
{
OpenSharedConnection();
try
{
using (var cmd = CreateCommand(_sharedConnection, sql, args))
{
var retv = cmd.ExecuteNonQuery();
OnExecutedCommand(cmd);
return retv;
}
}
finally
{
CloseSharedConnection();
}
}
catch (Exception x)
{
OnException(x);
throw new DatabaseException(x.Message, LastSQL, LastArgs);
}
}
Error messages are not required.

SolrJ - NPE when accessing to SolrCloud

I'm running the following test code on SolrCloud using Solrj library:
public static void main(String[] args) {
String zkHostString = "192.168.56.99:2181";
SolrClient solr = new CloudSolrClient.Builder().withZkHost(zkHostString).build();
List<MyBean> beans = new ArrayList<>();
for(int i = 0; i < 10000 ; i++) {
// creating a bunch of MyBean to be indexed
// and temporarily storing them in a List
// no Solr operations performed here
}
System.out.println("Adding...");
try {
solr.addBeans("myCollection", beans);
} catch (IOException | SolrServerException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
System.out.println("Committing...");
try {
solr.commit("myCollection");
} catch (SolrServerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
This code fails due to the following exception
Exception in thread "main" java.lang.NullPointerException
at org.apache.solr.client.solrj.impl.CloudSolrClient.requestWithRetryOnStaleState(CloudSolrClient.java:1175)
at org.apache.solr.client.solrj.impl.CloudSolrClient.request(CloudSolrClient.java:1057)
at org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:160)
at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:106)
at org.apache.solr.client.solrj.SolrClient.addBeans(SolrClient.java:357)
at org.apache.solr.client.solrj.SolrClient.addBeans(SolrClient.java:312)
at com.togather.solr.testing.SolrIndexingTest.main(SolrIndexingTest.java:83)
This is the full stacktrace of the exception. I just "upgraded" from a Solr standalone installation to a SolrCloud (with an external Zookeeper single instance, not the embedded one). With standalone Solr the same code (with just some minor differences, like the host URL) used to work perfectly.
The NPE sends me inside the SolrJ library, which I don't know.
Anyone can help me understand where the problem originates from and how I can overcome it? Due to my unexperience and the brevity of the error message, I can't figure out where to start inquiring from.
Looking at your code, I would suggest to specify the default collection as first thing.
CloudSolrClient solr = new CloudSolrClient.Builder().withZkHost(zkHostString).build();
solr.setDefaultCollection("myCollection");
Regarding the NPE you're experiencing, very likely is due to a network error.
In these lines your exception is raised by for loop: for (DocCollection ext : requestedCollections)
if (wasCommError) {
// it was a communication error. it is likely that
// the node to which the request to be sent is down . So , expire the state
// so that the next attempt would fetch the fresh state
// just re-read state for all of them, if it has not been retired
// in retryExpiryTime time
for (DocCollection ext : requestedCollections) {
ExpiringCachedDocCollection cacheEntry = collectionStateCache.get(ext.getName());
if (cacheEntry == null) continue;
cacheEntry.maybeStale = true;
}
if (retryCount < MAX_STALE_RETRIES) {//if it is a communication error , we must try again
//may be, we have a stale version of the collection state
// and we could not get any information from the server
//it is probably not worth trying again and again because
// the state would not have been updated
return requestWithRetryOnStaleState(request, retryCount + 1, collection);
}
}

MySql - QSqlError is not caught

Here's my code snippet:
try
{
if ( query.exec(query_str) == false ) {
err_desc = query.lastError().text().toStdString();
return RET_FAIL;
}
}
catch(QSqlError &e)
{
handleError(e);
}
I set a breakpoint inside handleError, but it seems this breakpoint was never reached when there is an error, with err_desc the following value:
MySQL server has gone away QMYSQL: unable to execute query
Why does it fail to catch the error ?
Because there's no error to catch.
If the query fails it return false and set a QSqlError, accessible via QSqlQuery::lastError(), but it doesn't raise an exception.
if ( query.exec(query_str) == false ) {
err_desc = query.lastError().text().toStdString();
handleError(query.lastError());
return RET_FAIL;
}
I suspect you are not getting an exception when the server has gone away.
There are other posts on handling this

J2ME Stub generates an unknown exception with JPA Entity types

I created a web service stub using NetBeans 7.0 and when I try using it, it throws an unknown Exception. I don't even know what part of my code to show here, all I know is that bolded line generates an unknown Exception:
public Businesses[] findBusiness(String query) throws java.rmi.RemoteException {
Object inputObject[] = new Object[]{
query
};
Operation op = Operation.newInstance(_qname_operation_findBusiness, _type_findBusiness, _type_findBusinessResponse);
_prepOperation(op);
op.setProperty(Operation.SOAPACTION_URI_PROPERTY, "");
Object resultObj;
try {
resultObj = op.invoke(inputObject);
} catch (JAXRPCException e) {
Throwable cause = e.getLinkedCause();
if (cause instanceof java.rmi.RemoteException) {
throw (java.rmi.RemoteException) cause;
}
throw e;
}
return businesses_ArrayfromObject((Object[]) resultObj);
}
private static Businesses[] businesses_ArrayfromObject(Object obj[]) {
if (obj == null) {
return null;
}
Businesses result[] = new Businesses[obj.length];
for (int i = 0; i < obj.length; i++) {
result[i] = new Businesses();
Object[] oo = (Object[]) obj[i];
result[i].setAddress((String) oo[0]); // **exception here**
result[i].setEmail((String) oo[1]);
result[i].setId((Integer) oo[2]);
result[i].setName((String) oo[3]);
result[i].setPhoneno((String) oo[4]);
result[i].setProducts((String) oo[5]);
}
return result;
}`
I tried to consume the same webservice using a web application and it works quite well. I don't have a single clue to what is causing this exception. Any comment would be appreciated.
Update
I tried other services that return a String data type and it works fine. So I thought maybe J2ME has issues with JPA Entity types.
So my question is how do I return the data properly so that the J2ME client can read it well?