I have encountered a strange problem when accessing an Azure Storage Blob from an Azure Function. I have a Function written in Java which is supposed to download some data from a Blob and then execute a PowerShell command. The PowerShell command can launch another Java application, which accesses the same Blob. I have this process working except for where the Function first downloads the Blob, which always gives a timeout while trying to get the size.
The weird thing is that the Java application launched by the PowerShell command uses the same code to download the Blob and can do so without any trouble at all.
Here is the relevant code snippet:
try {
blob = new BlobClientBuilder().endpoint(connStr).buildClient();
int dataSize = (int) blob.getProperties().getBlobSize(); // <- timeout occurs here
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(dataSize);
blob.download(outputStream);
outputStream.close();
String result = new String(outputStream.toByteArray(), "UTF-8");
return JsonParser.parseString(result).getAsJsonObject();
}
catch(Exception e) {
System.out.println("ERROR: "+e.getMessage());
e.printStackTrace();
return null;
}
Some relevant info:
The Blob is very small - only a few KB.
The same connection string is used in both cases.
The Blob is not the trigger for the function, but rather stores data for it.
EDIT
After getting better logs with a Log Analytics workspace, I found the timeout is being caused by a NoSuchMethodError.
java.lang.NoSuchMethodError: io.netty.handler.ssl.SslProvider.isAlpnSupported(Lio/netty/handler/ssl/SslProvider;)Z
I've seen this error before when I had the wrong version of netty-all-x.x.xFINAL.jar. Having already fixed this in the jars I upload with my code, I am now wondering where the Function gets libraries from other than what I include.
Following the exception mentioned in the edit led me to this thread:
https://github.com/Azure/azure-functions-java-worker/issues/381.
The issue was that the dependencies for the Function App itself were loading before my dependencies for my code and there is a conflict between them as mentioned here: https://github.com/Azure/azure-functions-java-worker/issues/365.
The solution was to set FUNCTIONS_WORKER_JAVA_LOAD_APP_LIBS = 1 in the Configuration settings of the Function App.
One more solution is to find out the exact error by running azure in local environment. most of the time following error is misleading.
FailureException: ClassCastException: java.lang.NoSuchMethodError cannot be cast to java.lang.RuntimeExceptionStack: java.lang.reflect.InvocationTargetExceptionat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at
following link will help you to run and debug azure function in local.
https://learn.microsoft.com/en-us/azure/azure-functions/functions-create-maven-eclipse
most of the time the issues is also due to dependency jars conflicts as explained in previous post.
Related
I'm trying to create an object in Minio. Sometimes it works and sometimes no.
When I execute :
minioClient.makeBucket(bucketName); // bucketName es a random unique string
I donĀ“t get error, but if If ask Minio if bucket exists:
minioClient.bucketExists(bucketName)
it returns false
After that, If I try to launch once again minioClient.makeBucket(bucketName) because minioClient.bucketExists(bucketName) is returning false, then I get this error (simplified):
BucketAlreadyOwnedByYou
So that, when I get previous error, I try to create object in Minio :
minioClient.putObject(bucketName, objectName, is,null,customMetaData,null, null ); // is is an InputStream of the file I want to store in Minio
But I get this error, saying bucket does not exist;
ErrorResponse(code=NoSuchBucket, message=The specified bucket does not exist, bucketName=888bf891-064f-4270-b0f0-85514c0eae02, objectName=L7aEmF8Ppk, resource=/888bf891-064f-4270-b0f0-85514c0eae02/L7aEmF8Ppk, requestId=16733C7840E6854D, hostId=null)
Any help will be appreciated.
I'm using version 6.0.13 of Minio Java API
This not how MinIO should behave. I have only seen this error where it was either a programming error or a setup error.
When it is a setup error, the root problem is that instead of creating 1 server pool with 4 distributed nodes, people have created 4 server pools each with a single node. This means that when your application gets load balanced, it will sometimes hit the server pool where you created the bucket and sometimes not.
Another cause can be an non-consistent filesystem used as backend. For example NFS with certain settings can have behavior like this. The recommended filesystem is XFS.
Without knowing more about your setup I cannot tell you which one it is.
We need to call a user defined java function within php code,so javaBridge connection is needed.
we have done the php-javabridge-configuration and it is working fine.
http://phprambabu.blogspot.in/2016/04/php-javabridge-configuration.html
To connect php with java class, we are running the java class from eclipse on tomcat server, HTTP port:8086 and mentioning the same port number in java.inc file, and its path is added in php file as "required_once(Java.inc)".
-> this shows error in Java.inc file
but changes made in Java.inc seems correct according to other resources found on internet and stackoverflow.
changes in Java.inc
define ("JAVA_HOSTS", "localhost:8086");
...
if(!defined("JAVA_HOSTS")) {
if(!java_defineHostFromInitialQuery(java_get_base())) {
if ($java_ini=get_cfg_var("java.hosts")) define("JAVA_HOSTS",$java_ini);
else define("JAVA_HOSTS","127.0.0.1:8086");
}
}
php file content snippet
function createBridge() {
$demo = new java("main.bridge");
echo 'New Bridge instance created';
$demo->fn();
return $demo;
}
Here,
running java src folder contains -> "main" folder contains -> "bridge.java" -> fn() function
if mentioned changes are done in java.inc, Fatal error occurs:
Fatal error: HTTP status 403, Access to the specified resource has been forbidden.
Apache Tomcat/7.0.72
in C:\xampp\htdocs\JavaBridge\java\Java.inc on line 869
Line 869 refers to 3rd line of below snippet:
function dieWithBrokenConnection($msg) {
unset($this->protocol->client->protocol);
trigger_error ($msg?$msg:"unknown error: please see back end log for details",E_USER_ERROR);
}
And we are using Xampp for local server.
Please let us know if I'm doing something wrong in between or any other useful stuff that can help us out.
I get an exception when trying to upload a file to Amazon S3 from my Java Spring application. The method is pretty simple:
private void productionFileSaver(String keyName, File f) throws InterruptedException {
String bucketName = "{my-bucket-name}";
TransferManager tm = new TransferManager(new ProfileCredentialsProvider());
// TransferManager processes all transfers asynchronously,
// so this call will return immediately.
Upload upload = tm.upload(
bucketName, keyName, new File("/mypath/myfile.png"));
try {
// Or you can block and wait for the upload to finish
upload.waitForCompletion();
System.out.println("Upload complete.");
} catch (AmazonClientException amazonClientException) {
System.out.println("Unable to upload file, upload was aborted.");
amazonClientException.printStackTrace();
}
}
It is basically the same that amazon provides here, and the same exception with the exactly same message ("profile file cannot be null") appears when trying this other version.
The problem is not related to the file not existing or being null (I have already checked in a thousand ways that the File argument recieved by TransferManager.upload method exists before calling it).
I cannot find any info about my exception message "profile file cannot be null". The first lines of the error log are the following:
com.amazonaws.AmazonClientException: Unable to complete transfer: profile file cannot be null
at com.amazonaws.services.s3.transfer.internal.AbstractTransfer.unwrapExecutionException(AbstractTransfer.java:281)
at com.amazonaws.services.s3.transfer.internal.AbstractTransfer.rethrowExecutionException(AbstractTransfer.java:265)
at com.amazonaws.services.s3.transfer.internal.AbstractTransfer.waitForCompletion(AbstractTransfer.java:103)
at com.fullteaching.backend.file.FileController.productionFileSaver(FileController.java:371)
at com.fullteaching.backend.file.FileController.handlePictureUpload(FileController.java:247)
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:498)
My S3 policy allows getting and puttings objects for all kind of users.
What's happening?
ProfileCredentialsProvider() creates a new profile credentials provider that returns the AWS security credentials configured for the default profile.
So, if you haven't any configuration for default profile at ~/.aws/credentials, while trying to put object, it yields that error.
If you run your code on Lambda service, it will not provide this file. In that case, you also do not need to provide credentials. Just assign right IAM Role to your lambda function, then using default constructor should solve issue.
You may want to change TransferManager constructor according to your needs.
The solution was pretty simple: I was trying to implement this communication without an AmazonS3 bean for Spring.
This link will help with the configuration:
http://codeomitted.com/upload-file-to-s3-with-spring/
my code worked fine as below:
AmazonS3 s3Client = AmazonS3ClientBuilder.standard().withCredentials(DefaultAWSCredentialsProviderChain.getInstance()).withRegion(clientRegion).build();
I have a project published in the Internet that is used by thousands of users every day. Basically, I'm using a server in AmazonAWS with the server part compiled in Java 6 running in a Tomcat. I'm using AMF to publish the services and my client is built in Flex 4.6 using Flash Builder to generate the classes to connect to the AMF services. The code I'm using to connect to the services is this:
public var cpcService:RemotingServicesImpl;
private function callService():void
{
FlexGlobals.topLevelApplication.callingService=true;
encryptedSession=ResourcesUtil.buildSessionId(globalSettings.sessionId, globalSettings);
var responder:Responder=new Responder(gameStateLoaded, gameStateFailed);
var token:AsyncToken=cpcService.getGameState(encryptedSession, taskKey);
token.addResponder(responder);
}
private function gameStateFailed(ev:FaultEvent=null):void
{
DisplayUtil.trackErrorInfoEvent("FATAL - FatalError", "getGameState-" + FlexGlobals.topLevelApplication.mainView.currentState, ev, encryptedSession);
}
private function gameStateLoaded(ev:Object):void
{
// my fantastic code when everything is ok
}
Normally, everything is ok and my application is working, but some calls (like 1 every 500) are not working, I know it because in the trackErrorInfoEvent function I'm registering an event in the Google Analytics, so I know this is randomly happening. This is the error:
faultCode = "Client.Error.MessageSend"
faultDetail = "Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Failed: url: 'https://appcog.cognifit.com/messagebroker/amf'"
faultString = "Send failed"
rootCause = (null)
Of course the URL is correct and is working all times.
I have seen in some blogs that adding this line:
<add-no-cache-headers>false</add-no-cache-headers>
the problem is fixed, but I have that line in my config file and is still happening.
I have checked my server logs and I have no records for service interruptions at any time.
I really apreciate any help, thanks in advance!
I am using WPS4R provided by 52north
Up to 3 days ago everything was fine and WPS could connect to R by use of Rserve properly but now this connection can not be made. I uninstalled everything, including Apache Tomcat,R and Java JDK, and then installed everything again. the problem still exists. This is the error that I get when I send the request. I am sure the code I used is correct, because it used to work and I did not chang any thing .
This is the error:
An R Connection Error occoured:
class org.rosuda.REngine.Rserve.RserveException - eval failed,
request status: error code: 127 null
The 127 is a parse error that is coming from R, this is not a workspace issue. If you want to get the error message back. Wrap the call to execute your script/r command with the following to get the error message. I have used this in the past and it works well. See the FAQ for more information.
http://www.rforge.net/Rserve/faq.html
c.assign(".tmp.", myCode);
REXP r = c.parseAndEval("try(eval(parse(text=.tmp.)),silent=TRUE)");
if (r.inherits("try-error")) System.err.println("Error: "+r.toString())
else { // success .. }