Error while trying to connect to jms connection factory - wso2

myQueueSender org.apache.axis2.transport.jms.AxisJMSException: Cannot acquire JNDI context,
JMS Connection factory : QueueConnectionFactory or default destination : null for JMS CF :
myQueueSender using : {transport.jms.UserName=wso2user,
transport.jms.ConnectionFactoryType=queue, transport.jms.Password=***,
transport.jms.CacheLevel=producer, java.naming.provider.url=failover:tcp://10.197.41.147:61616,
transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory,
java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory}
Getting this error when I start the server. here is the configuration:
parameter.username = "wso2custiomer"
parameter.password = "123456abcd"
parameter.initial_naming_factory = "org.apache.activemq.jndi.ActiveMQInitialContextFactory"
parameter.provider_url = "failover:tcp://10.197.41.147:61616"
parameter.connection_factory_name = "QueueConnectionFactory"
parameter.connection_factory_type = "queue"
parameter.cache_level = "producer"

Related

Kotlin & DynamoDB: Unable to resolve host "dynamodb.us-east-1.amazonaws.com": No address associated with hostname

I'm trying to connect my Kotlin Android app to DynamoDB in AWS using Android Studio. My credential details are replaced in the code below and it is connecting to an AWS sandbox. The created database client is below:
val staticCredentials = StaticCredentialsProvider {
accessKeyId = MY_ACCESS_KEY_HERE
secretAccessKey = MY_SECRET_ACCESS_KEY
}
ddb = DynamoDbClient{
region = MY_REGION_HERE
credentialsProvider = staticCredentials
}
Then I attempted to create the table using this client following these steps :
val tableNameVal = "Users"
val attDef = AttributeDefinition {
attributeName = key
attributeType = ScalarAttributeType.S
}
val keySchemaVal = KeySchemaElement {
attributeName = key
keyType = KeyType.Hash
}
val provisionedVal = ProvisionedThroughput {
readCapacityUnits = 10
writeCapacityUnits = 10
}
val request = CreateTableRequest {
attributeDefinitions = listOf(attDef)
keySchema = listOf(keySchemaVal)
provisionedThroughput = provisionedVal
tableName = tableNameVal
}
var tableArn: String
val response = ddb.createTable(request)
ddb.waitUntilTableExists { // suspend call
tableName = tableNameVal
}
tableArn = response.tableDescription!!.tableArn.toString()
println("Table $tableArn is ready")
However when I do this, I get an error when the createTable method is called:
java.net.UnknownHostException: Unable to resolve host "dynamodb.us-east-1.amazonaws.com": No address associated with hostname
I've tried doing a scan instead but I also get the same error. I thought that with AWS, if you provide the correct credentials and region, it wouldn't need any extra endpoints yet I'm still getting this "no hostname" error. I've looked at other code in JS with similar issues but couldn't get it working. Any help would be appreciated.

Instance created via Service Account unable to use Google Cloud Speech API - authentication error

I followed Google's Quick-Start documentation for the Speech API to enable billing and API for an account. This account has authorized a service account to create Compute instances on its behalf. After creating an instance on the child account, hosting a binary to use the Speech API, I am unable to successfully use the example C# code provided by Google in the C# speech example:
try
{
var speech = SpeechClient.Create();
var response = speech.Recognize(new RecognitionConfig()
{
Encoding = RecognitionConfig.Types.AudioEncoding.Linear16,
LanguageCode = "en"
}, RecognitionAudio.FromFile(audioFiles[0]));
foreach (var result in response.Results)
{
foreach (var alternative in result.Alternatives)
{
Debug.WriteLine(alternative.Transcript);
}
}
} catch (Exception ex)
// ...
}
Requests fail on the SpeechClient.Create() line with the following error:
--------------------------- Grpc.Core.RpcException: Status(StatusCode=Unauthenticated, Detail="Exception occured in
metadata credentials plugin.")
at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task)
at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)
at Grpc.Core.Internal.AsyncCall`2.UnaryCall(TRequest msg)
at
Grpc.Core.Calls.BlockingUnaryCall[TRequest,TResponse](CallInvocationDetails`2
call, TRequest req)
at
Grpc.Core.DefaultCallInvoker.BlockingUnaryCall[TRequest,TResponse](Method`2
method, String host, CallOptions options, TRequest request)
at
Grpc.Core.Internal.InterceptingCallInvoker.BlockingUnaryCall[TRequest,TResponse](Method`2
method, String host, CallOptions options, TRequest request)
at
Google.Cloud.Speech.V1.Speech.SpeechClient.Recognize(RecognizeRequest
request, CallOptions options)
at
Google.Api.Gax.Grpc.ApiCall.<>c__DisplayClass0_0`2.b__1(TRequest
req, CallSettings cs)
at
Google.Api.Gax.Grpc.ApiCallRetryExtensions.<>c__DisplayClass1_0`2.b__0(TRequest
request, CallSettings callSettings)
at Google.Api.Gax.Grpc.ApiCall`2.Sync(TRequest request,
CallSettings perCallCallSettings)
at
Google.Cloud.Speech.V1.SpeechClientImpl.Recognize(RecognizeRequest
request, CallSettings callSettings)
at Google.Cloud.Speech.V1.SpeechClient.Recognize(RecognitionConfig
config, RecognitionAudio audio, CallSettings callSettings)
at Rc2Solver.frmMain.RecognizeWordsGoogleSpeechApi() in
C:\Users\jorda\Google
Drive\VSProjects\Rc2Solver\Rc2Solver\frmMain.cs:line 1770
--------------------------- OK
I have verified that the Speech API is activated. Here is the scope that the service account uses when creating the Compute instances:
credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(me)
{
Scopes = new[] { ComputeService.Scope.Compute, ComputeService.Scope.CloudPlatform }
}.FromPrivateKey(yk)
);
I have found no information or code online about specifically authorizing or authenticating the Speech API for service account actors. Any help is appreciated.
It turns out the issue was that the Cloud Compute instances needed to be created with a ServiceAccount parameter specified. Otherwise the Cloud instances were not part of a ServiceAccount default credential, which is referenced by the SpeechClient.Create() call. Here is the proper way to create an instance attached to a service account, and it will use the SA tied to the project ID:
service = new ComputeService(new BaseClientService.Initializer() {
HttpClientInitializer = credential,
ApplicationName = "YourAppName"
});
string MyProjectId = "example-project-27172";
var project = await service.Projects.Get(MyProjectId).ExecuteAsync();
ServiceAccount servAcct = new ServiceAccount() {
Email = project.DefaultServiceAccount,
Scopes = new [] {
"https://www.googleapis.com/auth/cloud-platform"
}
};
Instance instance = new Instance() {
MachineType = service.BaseUri + MyProjectId + "/zones/" + targetZone + "/machineTypes/" + "g1-small",
Name = name,
Description = name,
Disks = attachedDisks,
NetworkInterfaces = networkInterfaces,
ServiceAccounts = new [] {
servAcct
},
Metadata = md
};
batchRequest.Queue < Instance > (service.Instances.Insert(instance, MyProjectId, targetZone),
(content, error, i, message) => {
if (error != null) {
AddEventMsg("Error creating instance " + name + ": " + error.ToString());
} else {
AddEventMsg("Instance " + name + " created");
}
});

Upgrade from HTTP/1.0 to HTTP/1.1 at server side, SOAP messages >4kb throws '400: Bad Request' Error

I'm consuming a webservice through a WSDL. I generated Java classes using Apache CXF wsdl2java.
For my soap messages >4kb, I get the below error. Messages <4kb has no problem getting response whatsoever. I tried disabling CHUNKING as follows:
soapMessageContext.put(HTTPConstants.CHUNKED, Boolean.FALSE);
I tried adding Content-Length to the HTTP header explicitly so that it disables chunking if its so.
Map<String, List<String>> httpHeaders = new HashMap<String,List<String>>();
httpHeaders.put("Content-Length", Collections.singletonList(filelength));
Map<String, Object> reqContext = ((BindingProvider) port).getRequestContext();
reqContext.put(MessageContext.HTTP_REQUEST_HEADERS, httpHeaders);
repairOrderResponse = port.submitRepairOrder(security,
repairorders);
Please help me through this. I cannot figure out why.
Stacktrace:
javax.xml.ws.WebServiceException: Could not send Message.
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:146)
at com.sun.proxy.$Proxy80.submitRepairOrder(Unknown Source)
at com.ssss.ssjdecommonws.webservices.SSJDECommonService.submitOrder(SSJDECommonService.java:640)
at com.ssss.ssjdecommonws.webservices.SSJDECommonService.getRepairOrderResult(SSJDECommonService.java:529)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:167)
at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:269)
at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:227)
at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:216)
at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:542)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:524)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:126)
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:231)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149)
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:559)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:340)
at org.apache.coyote.http11.Http11NioProcessor.process(Http11NioProcessor.java:353)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:911)
at org.apache.tomcat.util.net.NioEndpoint$ChannelProcessor.run(NioEndpoint.java:920)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.cxf.transport.http.HTTPException: HTTP response '400: Bad Request' when communicating with <MY_ENDPOINT_COMES_HERE>
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1549)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1504)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1310)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:628)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:565)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:474)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:377)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:330)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:135)
... 34 more
This is how I call the service in submitOrder()
SubmitRepairOrderService sService = new SubmitRepairOrderService(u, SERVICE_NAME);
SubmitRepairOrderType port = sService.getSubmitRepairOrderPort();
List<Handler> new_handlerChain = new ArrayList<Handler>();
fdda = new MessageHandler(props);
new_handlerChain.add(fdda);
((BindingProvider) port).getBinding().setHandlerChain(new_handlerChain);
security = null;
repairOrderResponse = port.submitRepairOrder(security,repairorders);
My handler method is given below:
public boolean handleMessage(SOAPMessageContext messageContext) {
try {
SOAPHeader header = null;
boolean outMessageIndicator = (Boolean) messageContext
.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (outMessageIndicator) {
SOAPEnvelope envelope = messageContext.getMessage().getSOAPPart().getEnvelope();
if (envelope.getHeader() != null) {
header = envelope.getHeader();
}
SOAPElement security = header.addChildElement("Security","oas","http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
SOAPElement usernameToken = security.addChildElement("UsernameToken", "oas");
usernameToken.addAttribute(new QName("xmlns:wsu"),
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
SOAPElement username = usernameToken.addChildElement("Username", "oas");
username.addTextNode(userId);
SOAPElement password = usernameToken.addChildElement("Password", "oas");
password.setAttribute("Type",
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText");
password.addTextNode(passcode);
}
} catch (Exception ex) {
throw new WebServiceException(ex);
}
return true;
}
Could you please let me know what other code you would want to see to understand it better?
You can disable chunking on JBoss using below code.
Add this code right after creating port object.
SubmitRepairOrderType port = sService.getSubmitRepairOrderPort();
HTTPClientPolicy hTTPClientPolicy = new HTTPClientPolicy();
hTTPClientPolicy.setAllowChunking(false);
   
Client client =  org.apache.cxf.jaxws.JaxWsClientProxy.getClient( port );
HTTPConduit http = ( HTTPConduit ) client.getConduit();
 
http.setClient(hTTPClientPolicy);
You may need the following jar files in your classpath:

Activemq concurrency fail in Apache camel route

Trying to send multiple requests at same instant to camel activemq route, one request is serviced and the other request is not serviced and sent back as it is. The Jms messages are set with JMScorrelationId too before sending like below
textMessage.setJMSCorrelationID(UUID.randomUUID().toString());
below is my activemq route
from("activemq:queue:TEST_QUEUE?disableReplyTo=true")
.setExchangePattern(ExchangePattern.InOut)
.process(new Processor() {
public void process(Exchange e) throws Exception {
log.info("Request : "
+ MessageHelper.extractBodyAsString(e.getIn()));
/*Processing Logic*/
}
})
.beanRef("testBean","postDetails")
.inOnly("activemq:queue:TEST_QUEUE");
Multiple (Test for 2 requests) requests sent to the above route concurrently not serviced except one. The servicemix.log shows all recieved requests. But only one is serviced.
Below is the code what is sending request deployed in jboss 6.1 as part of web application.
public Message receive(String message, String queueName) {
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
"tcp://localhost:61616");
String userName = "smx";
String password = "smx";
Connection connection;
Message response =null;
try {
connection = connectionFactory.createConnection(userName, password);
connection.start();
((ActiveMQConnectionFactory) connectionFactory)
.setDispatchAsync(false);
Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
Queue destination = session.createQueue(queueName);
MessageProducer producer = session.createProducer(destination);
producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
TextMessage textMessage = session.createTextMessage(message);
Queue tempQueue = session.createQueue(queueName);
textMessage.setJMSReplyTo(tempQueue);
producer.send(textMessage);
MessageConsumer consumer = session.createConsumer(tempQueue);
response = consumer.receive();
response.acknowledge();
session.close();
connection.close();
} catch (JMSException e) {
e.printStackTrace();
}
return response;
}
Is there some or the other parameter im missing?? please suggest.
Camel will auto send back a reply if the JMS message has a JMSReplyTo header, so your route should just be
from("activemq:queue:TEST_QUEUE")
.process(new Processor() {
public void process(Exchange e) throws Exception {
log.info("Request : "
+ MessageHelper.extractBodyAsString(e.getIn()));
/*Processing Logic*/
}
})
.beanRef("testBean","postDetails");
At the end of the route (eg after calling testBean) then the content of the message body is used as the reply message, that are sent back to the queue named defined in the JMSReplyTo header.

google glass notification mismatch development and production server

I try to send notification through menu in my app using mirror api. for development environment I am using a proxy server but in production I am using just SSl cause it is public domain. my callback URL for this two section is bellow
// development
callbackUrl = "https://3a4660af.ngrok.com/notify";
// production
if (callbackUrl.equals("https://www.mydomain.com:8080/notify")) {
callbackUrl = "https://www.mydomain.com:8443/notify";
} else {
callbackUrl = "https://www.mydomain.com:8443/notify";
}
LOG.info("\ncallbackUrl : " + callbackUrl);
Subscription subscription = new Subscription();
subscription.setCollection(collection);
subscription.setVerifyToken(userId);
subscription.setCallbackUrl(callbackUrl);
subscription.setUserToken(userId);
getMirror(credential).subscriptions().insert(subscription)
.execute();
But when I try to read notification from notification class I got mismatch so that the notification action is not working. the notification log in bellow
//development
got raw notification : { "collection": "timeline",
"itemId": "6fa2445e-b14f-46b2-9cff-f0d44d63ecab",
"operation": "UPDATE", "verifyToken": "103560737611562800385",
"userToken": "103560737611562800385",
"userActions": [ { "type": "CUSTOM", "payload": "dealMenu" } ]}
//production
got raw notification : "collection": "timeline",
"operation": "UPDATE",
"userToken": "103560737611562800385", { "payload": "dealMenu" ]null
in Notification class
BufferedReader notificationReader = new BufferedReader(
new InputStreamReader(request.getInputStream()));
String notificationString = "";
// Count the lines as a very basic way to prevent Denial of Service
// attacks
int lines = 0;
while (notificationReader.ready()) {
notificationString += notificationReader.readLine();
lines++;
LOG.info("\ngot raw notification during read : "
+ notificationString);
// No notification would ever be this long. Something is very wrong.
if (lines > 1000) {
throw new IOException(
"Attempted to parse notification payload that was unexpectedly long.");
}
}
LOG.info("\ngot raw notification : " + notificationString);
JsonFactory jsonFactory = new JacksonFactory();
LOG.info("\ngot jsonFactory : " + jsonFactory);
// If logging the payload is not as important, use
// jacksonFactory.fromInputStream instead.
Notification notification = jsonFactory.fromString(notificationString,
Notification.class);
LOG.info("\n got notification " + notification);
In production I cannot received all the perimeters what I need. Why this mismatch happen???