vladholubiev / serverless-libreoffice

Run LibreOffice in AWS Lambda to create PDFs & convert documents
https://vladholubiev.com/serverless-libreoffice
510 stars 74 forks source link

Running command throws com::sun::star::container::NoSuchElementException Exception #29

Open Rudigern opened 4 years ago

Rudigern commented 4 years ago

Updating my AWS Lambda function with the new LibraOffice compiled for Amazon Linux 2 and when I run the command it throws com::sun::star::container::NoSuchElementException'.

I've confirmed the file is there and tried both pptx and docx but it throws the same exception. I did notice in a test that you run the command twice with it expecting to fail the first time, not sure if it's related.

Thanks for your function and work on this, very much appreciated.

vladholubiev commented 4 years ago

Hey @Rudigern,

What Lambda runtime do you use? Could you please share the file you're trying to convert? What's the desired output file format?

Yeah, you noticed it right. Running the command twice is worth trying. Did it help you?

Rudigern commented 4 years ago

@vladgolubev Using NodeJS 12x. I've used two different files and run it against the old Lambda function and the old one works. I do run it twice but the exception still gets thrown and there is no output file however there is still that long string of numbers that occurs in the console.

2,32,40,99,111,114,101,32,100,117,109,112,101,100,41,32,46,47,105,110,115,116,100,105,114,47,112

Whats the error that occurs to need to run it twice?

Also I'm using the Lambda Layer at

arn:aws:lambda:ap-southeast-2:764866452798:layer:libreoffice-gzip:1

tpiske commented 4 years ago

Hello,

I have this same error converting a docx file to pdf:

terminate called after throwing an instance of 'com::sun::star::container::NoSuchElementException'
sh: line 1:    15 Aborted (core dumped) instdir/program/soffice.bin --headless --norestore --invisible --nodefault --nofirststartwizard --nolockcheck --nologo --norestore --convert-to pdf --outdir /tmp test.docx

I'm using Python 3.8 (Amazon Linux 2) Lambda Layer: arn:aws:lambda:us-east-1:764866452798:layer:libreoffice-gzip:1

Rudigern commented 4 years ago

Looks like someone else has come across this issue too.

fughur commented 4 years ago

Same here trying to run hello world test from https://github.com/shelfio/aws-lambda-libreoffice/blob/master/test.js on both lambci/lambda:nodejs10.x and lambci/lambda:nodejs12.x using new libreoffice build. Running command twice doesn't help.

Here is command i used (works well with previous libre build) cd /tmp && \"/tmp/instdir/program/soffice.bin\" --headless --invisible --nodefault --view --nolockcheck --nologo --norestore --nofirststartwizard --convert-to pdf:impress_pdf_Export --outdir \"/tmp\" \"/tmp/test.txt\"

fughur commented 4 years ago

Okay it seems that only layer.tar.gz.zip is broken, layer.tar.br.zip works well after applying twice call hack. They even have different size after unpacking - ~250mb for .gz (oh false hope) instead of ~350mb of .br.

Rudigern commented 4 years ago

I've confirmed that as @fughur has said, the tar.gz is broken. I've zipped up the compiled version of tar.br and as a tar.gz (I couldn't be bothered changing the function to accommodate yet) and it works. It's missing a whole bunch of fonts that I'll have to look to add but now it works.

curtiseinsmann commented 4 years ago

Can confirm. Running this on an Amazon Linux 2 machine, the binary extracted from lo.tar.gz in release 6.4.0.1 threw this error, even when running it from the command line. Binary extracted from lo.tar.br (unpacked by referencing this code) works from the command line without calling it twice. Running the binary from lo.tar.br in a node runtime works, but only after calling it twice.

lanlin commented 4 years ago

same error here when running on AWS Lambda

/tmp/instdir/program/soffice.bin --headless --invisible --nodefault --nofirststartwizard --nolockcheck --nologo --norestore --convert-to odt --outdir /tmp /tmp/target.txt