Closed raghukaramel closed 7 years ago
What's the problem you're seeing?
It hangs at line - AmazonS3 s3Client = new AmazonS3Client(awsCredentialsProviderChain.getCredentials());
I don't see any error or any messages
Where are you expecting credentials to be loaded from? ie: which credential provider in the provider chain.
Are you running this on EC2?
Sorry, I'm not that familiar with mule.
~/.aws/credentials
No I am running it on my local. Mule is a spring based application container - more info can be found here - https://www.mulesoft.com/platform/mule
Can you try this:
AmazonS3 s3 = AmazonS3Client.builder().withCredentials(new ProfileCredentialsProvider()).build();
I tried that and couple other ways to create S3Client, but all of them fail the same way. Here are the different things I tried
//BasicAWSCredentials awsCreds = new BasicAWSCredentials("abc", "xyz");
//AmazonS3 s3Client = new AmazonS3Client(awsCreds);
//AmazonS3 s3Client = AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(awsCredentialsProviderChain.getCredentials())).build();
//AmazonS3 s3Client = new AmazonS3Client(new ProfileCredentialsProvider());
have you been able to step through to see where it's hanging?
Yes, when I am stepping through the code, the cursor disappears for few seconds on the above line of code and then the control get transferred to line 76 of the below code - /*
import org.mule.api.MessagingException; import org.mule.api.MuleEvent; import org.mule.api.MuleException; import org.mule.api.construct.FlowConstruct; import org.mule.api.construct.Pipeline; import org.mule.api.processor.MessageProcessor; import org.mule.context.notification.MessageProcessorNotification; import org.mule.context.notification.ServerNotificationManager;
/**
Intercepts MessageProcessor execution to fire before and after notifications */ class MessageProcessorNotificationExecutionInterceptor implements MessageProcessorExecutionInterceptor {
private MessageProcessorExecutionInterceptor next;
MessageProcessorNotificationExecutionInterceptor(MessageProcessorExecutionInterceptor next) { this.next = next; }
MessageProcessorNotificationExecutionInterceptor() {
}
@Override public MuleEvent execute(MessageProcessor messageProcessor, MuleEvent event) throws MessagingException { ServerNotificationManager notificationManager = event.getMuleContext().getNotificationManager(); boolean fireNotification = event.isNotificationsEnabled(); if (fireNotification) { fireNotification(notificationManager, event.getFlowConstruct(), event, messageProcessor, null, MessageProcessorNotification.MESSAGE_PROCESSOR_PRE_INVOKE); }
MuleEvent result = null;
MessagingException exceptionThrown = null;
try
{
if (next == null)
{
result = messageProcessor.process(event);
}
else
{
result = next.execute(messageProcessor, event);
}
}
catch (MessagingException e)
{
exceptionThrown = e;
throw e;
}
catch (MuleException e)
{
exceptionThrown = new MessagingException(event, e, messageProcessor);
throw exceptionThrown;
}
finally
{
if (fireNotification)
{
fireNotification(notificationManager, event.getFlowConstruct(), result != null ? result : event, messageProcessor,
exceptionThrown, MessageProcessorNotification.MESSAGE_PROCESSOR_POST_INVOKE);
}
}
return result;
}
protected void fireNotification(ServerNotificationManager serverNotificationManager, FlowConstruct flowConstruct, MuleEvent event, MessageProcessor processor, MessagingException exceptionThrown, int action) { if (serverNotificationManager != null && serverNotificationManager.isNotificationEnabled(MessageProcessorNotification.class)) { if (flowConstruct instanceof Pipeline && ((Pipeline) flowConstruct).getProcessorPath(processor) != null) { serverNotificationManager.fireNotification(new MessageProcessorNotification(flowConstruct, event, processor, exceptionThrown, action)); } } } }
I'm sorry, I don't see line numbers. Can you link me to a line in the repo? What version of the SDK are you using?
Here is the repo link - https://github.com/mulesoft/mule/blob/mule-3.4.1-HF1/core/src/main/java/org/mule/execution/MessageProcessorNotificationExecutionInterceptor.java
I am currently using AWS S3 SDK 1.11.106, I also tried the latest version 1.11.124 and few other older versions as well 1.10.x, 1.9.x etc. I am seeing the same behavior with all different versions.
This looks like mule code - I'm looking for what part of the SDK you feel this is a problem with...
not sure about... that's where I am looking for help
This repo is for the Aws Java SDK, the code you've posted isn't from our library. Have you tried asking in the mule repository? I'm unsure how else I'm able to help as you indicate the problem is not with the AWS Java SDK.
I agree, it looks like a Mule issue. I have opened a case with Mule and working with them currently.
Closing this for now, feel free to re-open if you feel this is an issue with the SDK.
I am building an application in Mule that uploads file to S3 using Java SDK and initialization of AmazonS3Client is failing at runtime. I am using Mule Enterprise Edition 3.4.0, Java 1.7 and S3 SDK 1.11.106.
Here is the code that I am using... any suggestions?
package com.intuit.s3.test;
import org.mule.api.MuleMessage; import org.mule.api.transformer.TransformerException; import org.mule.transformer.AbstractMessageTransformer;
import java.io.File;
import com.amazonaws.AmazonClientException; import com.amazonaws.AmazonServiceException; import com.amazonaws.auth.DefaultAWSCredentialsProviderChain; import com.amazonaws.services.s3.AmazonS3; import com.amazonaws.services.s3.AmazonS3Client; import com.amazonaws.services.s3.model.PutObjectRequest;
public class S3FileUpload extends AbstractMessageTransformer { private static String bucketName = "my-bucket-test123"; private static String keyName = "java-sdk-test-upload.txt"; private static String uploadFileName = "/tmp/s3-upload-test.txt";
}