Hive Server 2 thrift Client error: Required field 'operationHandle' is unset - hadoop

I am trying to run the below hive thrift code on hive server2 on CDH 4.3 and getting below error. Here is my code: I can run hive jdbc connection to same server successfully, it is just thrift which is not working.
public static void main(String[] args) throws Exception
{
TSocket transport = new TSocket("my.org.hiveserver2.com",10000);
transport.setTimeout(999999999);
TBinaryProtocol protocol = new TBinaryProtocol(transport);
TCLIService.Client client = new TCLIService.Client(protocol);
transport.open();
TOpenSessionReq openReq = new TOpenSessionReq();
TOpenSessionResp openResp = client.OpenSession(openReq);
TSessionHandle sessHandle = openResp.getSessionHandle();
TExecuteStatementReq execReq = new TExecuteStatementReq(sessHandle, "SELECT * FROM testhivedrivertable");
TExecuteStatementResp execResp = client.ExecuteStatement(execReq);
TOperationHandle stmtHandle = execResp.getOperationHandle();
TFetchResultsReq fetchReq = new TFetchResultsReq(stmtHandle, TFetchOrientation.FETCH_FIRST, 1);
TFetchResultsResp resultsResp = client.FetchResults(fetchReq);
TRowSet resultsSet = resultsResp.getResults();
List<TRow> resultRows = resultsSet.getRows();
for(TRow resultRow : resultRows){
resultRow.toString();
}
TCloseOperationReq closeReq = new TCloseOperationReq();
closeReq.setOperationHandle(stmtHandle);
client.CloseOperation(closeReq);
TCloseSessionReq closeConnectionReq = new TCloseSessionReq(sessHandle);
client.CloseSession(closeConnectionReq);
transport.close();
}
Here is the error log:
Exception in thread "main" org.apache.thrift.protocol.TProtocolException: Required field 'operationHandle' is unset! Struct:TFetchResultsReq(operationHandle:null, orientation:FETCH_FIRST, maxRows:1)
at org.apache.hive.service.cli.thrift.TFetchResultsReq.validate(TFetchResultsReq.java:465)
at org.apache.hive.service.cli.thrift.TCLIService$FetchResults_args.validate(TCLIService.java:12607)
at org.apache.hive.service.cli.thrift.TCLIService$FetchResults_args$FetchResults_argsStandardScheme.write(TCLIService.java:12664)
at org.apache.hive.service.cli.thrift.TCLIService$FetchResults_args$FetchResults_argsStandardScheme.write(TCLIService.java:12633)
at org.apache.hive.service.cli.thrift.TCLIService$FetchResults_args.write(TCLIService.java:12584)
at org.apache.thrift.TServiceClient.sendBase(TServiceClient.java:63)
at org.apache.hive.service.cli.thrift.TCLIService$Client.send_FetchResults(TCLIService.java:487)
at org.apache.hive.service.cli.thrift.TCLIService$Client.FetchResults(TCLIService.java:479)
at HiveJDBCServer1.main(HiveJDBCServer1.java:26)

Are you really sure you set the operationsHandle field to a valid value? The Thrift eror indicates what it says: The API expects a certain field (operationHandle in your case) to be set, which has not been assigned a value. And you stack trace confirms this:
Struct:TFetchResultsReq(operationHandle:null, orientation:FETCH_FIRST,
maxRows:1)

In case anyone finds this, like I did, by googling that error message: I had a similar problem with a PHP Thrift library for hiverserver2. At least in my case, execResp.getOperationHandle() returned NULL because there was an error in the executed request that generated execResp. This didn't throw an exception for some reason, and I had to examine execResp in detail, and specifically check the status, before attempting to get an operation handle.

Related

error setting linkConfig.connectionString on sqoop 1.99.4

I followed https://sqoop.apache.org/docs/1.99.4/RESTAPI.html for trying out sqoop2. But Iam getting error "Exception in thread "main" org.apache.sqoop.common.SqoopException: MODEL_011:Input do not exist - Input name: linkConfig.connectionString" on the line linkConfig.getStringInput("linkConfig.connectionString").setValue("jdbc:mysql://localhost/my");
i tested sqoop2, mysql, database etc from terminal and working fine. please help. thanks in advance.
here is the code i am trying
import org.apache.sqoop.client.SqoopClient;
import org.apache.sqoop.model.MLink;
import org.apache.sqoop.model.MLinkConfig;
import org.apache.sqoop.validation.Status;
public class Sqoop2 {
public static void main(String[] args) {
//Initialization SqoopClient
String url = "http://<myip>:12000/sqoop/";
SqoopClient client = new SqoopClient(url);
// create a placeholder for link
long connectorId = 1;
MLink link = client.createLink(connectorId);
link.setName("Vampire");
link.setCreationUser("Buffy");
MLinkConfig linkConfig = link.getConnectorLinkConfig();
// fill in the link config values
linkConfig.getStringInput("linkConfig.connectionString").setValue("jdbc:mysql://<myip>/<dbname>");
linkConfig.getStringInput("linkConfig.jdbcDriver").setValue("com.mysql.jdbc.Driver");
linkConfig.getStringInput("linkConfig.username").setValue("root");
linkConfig.getStringInput("linkConfig.password").setValue("root");
// save the link object that was filled
Status status = client.saveLink(link);
if(status.canProceed()) {
System.out.println("Created Link with Link Id : " + link.getPersistenceId());
} else {
System.out.println("Something went wrong creating the link");
}
}
}
I faced the same issue. As per the documentation generic-jdbc connector id =1 and hdfs-connector id =2. But after we upgraded to 5.3.2 the id's were swapped.
Don't hard code the connector Id's(as said in the documentation). Use client.getConnectors(); or show connector --all method to look for existing connectors and get the connector Id you need. There is currently an issue logged for this https://issues.apache.org/jira/browse/SQOOP-1965.
Looks like connector 1 is already exists. Can you try with another id ?

Exchange EWS SearchMailboxes invalid child element error

I have a strange error. When i try to do a SearchMailboxes, I get this error:
Unhandled Exception: Microsoft.Exchange.WebServices.Data.ServiceResponseException: The request "://schemas.microsoft.com/exchange/services/2006/types" has invalid child element 'ExtendedAttributes'
The problem is that i get this error in some pc's. With fiddler I could see that my pc sends a request without the node ExtendedAttributes and it works.
This is the ExtendedAttributes node that produces the error.
The code:
List<MailboxSearchScope> scopeList = new List<MailboxSearchScope>();
foreach (SearchableMailbox mb in searchableMailboxes)
{
MailboxSearchScope scope = new MailboxSearchScope(mb.ReferenceId, MailboxSearchLocation.All);
scopeList.Add(scope);
}
MailboxQuery query = new MailboxQuery(searchQuery, scopeList.ToArray());
MailboxQuery[] mbQueryList = new MailboxQuery[] { query };
SearchMailboxesParameters p = new SearchMailboxesParameters
{
SearchQueries = mbQueryList,
ResultType = SearchResultType.PreviewOnly
};
ServiceResponseCollection<SearchMailboxesResponse> res = _service.SearchMailboxes(p);
ExtendedAttributes is a new element that was introduced in Exchange 2013 SP1 and is intended for internal use only.
http://msdn.microsoft.com/en-us/library/office/dn627392(v=exchg.150).aspx
I don't see in your code where you are trying to use this element so I would suggest that you specify ExchangeVersion.Exchange2013 when you are instantiating your ExchangeService object.

AWS: Getting 400 Bad Request error from AmazonCloudWatch.GetMetricStatistics()

I'm having a little trouble using AmazonCloudWatch to fetch CPU Utilization. When I try to use AmazonCloudWatch.GetMetricStatistics(), I get this for an exception message:
Exception of type 'Amazon.CloudWatch.AmazonCloudWatchException' was thrown.
And this for an inner exception:
{"The remote server returned an error: (400) Bad Request."}
Here is the code I'm using to make the call:
public static String getCPUStats(String Endpoint, String InstanceID)
{
try
{
AmazonCloudWatchConfig cloudConfig = new AmazonCloudWatchConfig();
cloudConfig.ServiceURL = Endpoint;
string AWSAccessKey = Sql.ToString(appConfig["AWSAccessKey"]);
string AWSSecretKey = Sql.ToString(appConfig["AWSSecretKey"]);
AmazonCloudWatch client = AWSClientFactory.CreateAmazonCloudWatchClient(AWSAccessKey, AWSSecretKey, cloudConfig);
GetMetricStatisticsRequest request = new GetMetricStatisticsRequest();
request.Dimensions.Add(new Dimension { Name = "InstanceId", Value = InstanceID });
request.StartTime = DateTime.UtcNow.AddMinutes(-5);
request.EndTime = DateTime.UtcNow;
request.Namespace = "AWS/EC2";
request.Statistics.Add("Maximum");
request.Statistics.Add("Average");
request.MetricName = "CPUUtilization";
request.Period = 60;
GetMetricStatisticsResponse r = client.GetMetricStatistics(request);
if (r.GetMetricStatisticsResult.Datapoints.Count > 0)
{
Datapoint dataPoint = r.GetMetricStatisticsResult.Datapoints[0];
return "CPU maximum load: " + dataPoint.Maximum;
}
return "No data available.";
}
catch (Exception ex)
{
return ex.Message;
}
}
Some side notes - the access key, secret access key, and endpoint work fine for creating an AmazonEC2Client, so I'm pretty sure the problem isn't there.
I've done quite a bit of googling and poring over the documentation, but haven't been successful in solving this. Any ideas? Thanks so much!
Unfortunately, we weren't able to figure this one out - we ended up deciding to use Microsoft Azure instead of Amazon Web Services :(
I think you can only request one Statistics at a time. So try removing either request.Statistics.Add("Maximum"); or request.Statistics.Add("Average");

SAP Business One: Connection Error When I try to connect to UI API

I got this error message
"Connection - Could not find SBO that match the connection string [66000-85]"
when I try to connect SAP Business One UI API.
I connect like the following :
private void SetApplication()
{
SAPbouiCOM.SboGuiApi SboGuiApi = null;
string sConnectionString = null;
SboGuiApi = new SAPbouiCOM.SboGuiApi();
// connect to a running SBO Application
sConnectionString = Environment.GetCommandLineArgs().GetValue(1).ToString() ;
SboGuiApi.Connect(sConnectionString);
SBO_Application = SboGuiApi.GetApplication(-1);
}
I got it this problem, my connestring string is wrongly config. WHen I set rigth one it works now. Thanks all.

Windows Azure: Error 300 Ambiguous Redirect when creating a blob container

I followed a tutorial on creating a blob on windows azure. But when I do that, I get an exception error:
Error while creating containerThe server encountered an unknown failure: The remote server returned an error: (300) Ambiguous Redirect.
The code is:
private void SetContainersAndPermission()
{
try
{
// create a container
var CloudAccountStorage = CloudStorageAccount.FromConfigurationSetting("BlobConnectionString");
cloudBlobClient = CloudAccountStorage.CreateCloudBlobClient();
CloudBlobContainer blobContainer = cloudBlobClient.GetContainerReference("documents");
blobContainer.CreateIfNotExist();
// permissions
var containerPermissions = blobContainer.GetPermissions();
containerPermissions.PublicAccess = BlobContainerPublicAccessType.Container;
blobContainer.SetPermissions(containerPermissions);
}
catch(Exception ex)
{
throw new Exception("Error while creating container" + ex.Message);
}
}
Can anyone tell me How to solve this problem....
I would guess the connection string is somehow wrong? Can you share the connection string? (X out your shared key...)
You could also install Fiddler (debugging HTTP proxy) and see what the HTTP request looks like. That may make the issue more obvious.
I also faced the same issue. I am not sure if this is the workaround for it. I modified the container name value in ServiceConfiguration.csfg from "Photograph" to "photograph" and it worked.
I think you can not give upper case letters in queue, table or blob name. The name should have only lower case characters.

Resources