2

Hi Stackoverflow community, i am having an issue about reading a file from my java webapp. I want to get a file from a directory in my webapp, then converting it to PDF. Everything works just fine in my developpement environement ( Windows) but when i am puting this on sever ( LINUX), when the server reach the code to read my doc file to convert it, java throw this exception :

com.sun.star.lang.IllegalArgumentException - Unsupported URL <file:///

Here is the code :

fileDocToConvert = new File(GET_REAL_PATH()+repo_Name+slash+fileName);

fileDocToConvert path become then : /usr/share/tomcat7/webapps/myapp/repo_name/exemple.doc

the exception fired up when i try to convert :

OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
connection.connect();
DocumentConverter converter  = new OpenOfficeDocumentConverter(connection); 
//HERE...=> //     converter.convert(docFile, pdfFile);

I am using :

jodConverter 2.2.1, openOffice 3, Java7, Tomcat 7

I start the openOffice service this way :

soffice --headless --accept="socket,host=127.0.0.1,port=8100;urp;" --nofirststartwizard

I can't get a way to follow to solve this issue.

Thank you in advance

Colin Dumitru
  • 3,327
  • 6
  • 30
  • 47
Badr DRAIFI
  • 335
  • 4
  • 12
  • What are the values of `docFile` and `pdfFile` then? You only show `fileDocToConvert`. (Also, to join paths in Java, it's probably a better habit to use [`File.pathSeparator`](http://docs.oracle.com/javase/7/docs/api/java/io/File.html#pathSeparator) or the `File(File, String)` constructor for cross-platform apps.) – millimoose Feb 02 '13 at 12:28
  • docFile is fileDocToConvert, its value is : fille:////usr/share/tomcat7/webapps/myapp/repo_name/exemple.doc pdfFile has no value cause of the expception thrown when JodConverter try to convert that file ( docFile) to pdfFile. – Badr DRAIFI Feb 03 '13 at 00:14
  • By "`pdfFile` has no value" do you mean you're passing in `null` to `converter.convert()`? It seems to me like it should have as a value the path where you want the result of the conversion to be saved. I don't think the converter can "fill in" the `File` parameter for you. – millimoose Feb 03 '13 at 13:01

3 Answers3

3

I resolved the problem, by installing some missing components of OpenOffice ( Calc, Writer ). The problem was that OpenOffice can't understand the path of the file given to it.

Thank's for your help millimoose.

Raduan Santos
  • 1,023
  • 1
  • 21
  • 45
Badr DRAIFI
  • 335
  • 4
  • 12
0

Have got java.lang.Exception: Unsupported URL <file:////... error message when started multiple libreoffice instances from different users and with conflicting same port setting.

user3132194
  • 2,381
  • 23
  • 17
0

The problem for me was that OpenOffice or another program that uses components of OpenOffice in it cannot understand the path of the file given to it as a place to save the file. Save the file that you are trying to save somewhere else on your computer and see if that works.

John
  • 1