jodconverter doesn't find soffice.bin - ruby

I'm trying to use JODConverter on top of jetty and sinatra. Whenever I fire up my Jetty server, which has the sinatra application deployed to it in a war. i get this exception (much cruft removed):
java.lang.IllegalStateException: invalid officeHome: it doesn't contain soffice.bin:
in my settings.yml file I have the following:
secret: Whatever_you_want_it_to_be
PARAMETER_OFFICE_PORT: 8100
PARAMETER_OFFICE_HOME: /Volumes/OpenOffice.org 3.3/OpenOffice.org.app/Contents/MacOS
PARAMETER_OFFICE_PROFILE: /Applications/OpenOffice.org.app/Contents/MacOS
and here are the contents of those last two directories:
>ls '/Volumes/OpenOffice.org 3.3/OpenOffice.org.app/Contents/MacOS'
about.png crashrep intro.png sbase sdraw simpress soffice sofficerc testtool unopkg urelibs
boot straprc fundamentalrc resource scalc setuprc smath soffice.bin swriter unoinfo unopkg.bin versionrc
>ls /Applications/OpenOffice.org.app/Contents/MacOS
about.png crashrep intro.png sbase sdraw simpress soffice sofficerc testtool unopkg urelibs
bootstraprc fundamentalrc resource scalc setuprc smath soffice.bin swriter unoinfo unopkg.bin versionrc
Notice that both ls's show "soffice.bin" in them
update:
I've also tried this:
> sudo chmod 777 '/Volumes/OpenOffice.org 3.3/OpenOffice.org.app/Contents/MacOS/soffice.bin'
Password:
chmod: Unable to change file mode on /Volumes/OpenOffice.org 3.3/OpenOffice.org.app/Contents/MacOS/soffice.bin: Read-only file system
I've also tried using the second directory for office_home and vice versa. no luck.

If anyone still has the same problem (as I did) the problem was, that the parameter OfficeHome for Mac has to specify the folder "Contents", not the folder "Contents/MacOs/".
The JODConverter is checking if the following exists:
new File(officeHome, "MacOS/soffice.bin")
So the OpenOffice home folder should have been /Applications/OpenOffice.org.app/Contents.

Sounds like you're either missing a JAR file or there may be a conflict in the JAR files being used. Although it's not JRuby, this post should shed some light: http://groups.google.com/group/jodconverter/browse_thread/thread/cdf6600288bfba5a/8ed4558cfde08e39

Related

NXlog will not start - AlienVault Config

I am trying to configure NXlog to work with AlienVault based on the guide here
I installed the custom config file from AlienVault and modified the destination IP only. When I did this I could not get the NXlog service to start - Then I reinstalled the default config but I still cannot get it to open.
I edited the file in notepad which I thing should be safe, however I have read here that it is possibly the UTF-8 BOM - I am not sure how to check if there is one but I do not believe there is because I only used notepad.
The first line in the config file looks like so:
define ROOT C:\Program Files (x86)\nxlog
The NXlog Log file with the errors is only displaying this error:
nxlog failed to start: Invalid keyword: define at C:\Program Files (x86)\nxlog\conf\nxlog.conf:1
Not very helpful - Seems to be choking on the very first word - Anyone seen this before???
I'm pretty sure that's caused by the UTF-8 BOM in your config file. I suggest using and checking with an editor that can handle this. In HEX mode you can confirm whether the file has a BOM or not.
The NXLog EE v4.0 can cope with the BOM properly BTW.
As B0ti mentioned, my problem was caused by the BOM - I couldn't figure out how to fix this on windows so I downloaded the file into a Linux environment and fixed it there. To do so follow these steps -
First I verified there was a BOM in place with the file command:
ex: file filename.txt -This will print information about the file - if there is a BOM you will see that.
Next I followed the answer here for removing the BOM:
Basically just do this in the Linux box - sed '1s/^\xEF\xBB\xBF//' < orig.txt > new.txt
Then I transferred the new file back to the Windows box and all was right with the world!

Open HTML in chrome from command line using app flag

(Before downvote im aware how to do this using code thats inline to this command but not how to do it using a file that uses the --app="data:text/html,<sometags></sometags>)
How would I open a local html (mar.html) file using this command
C:\'Program Files (x86)'\Google\Chrome\Application\chrome.exe --profile-directory="Default" --app=
Specifically, the issue is my lack of familiarity with the --app flag
I tried
C:\'Program Files (x86)'\Google\Chrome\Application\chrome.exe --profile-directory="Default" --app="mar.html"
C:\'Program Files (x86)'\Google\Chrome\Application\chrome.exe --profile-directory="Default" --app="file:///mar.html"
Both don't work.
Giving me the error
Your file was not found
It may have been moved or deleted.
ERR_FILE_NOT_FOUND
You almost got it. The file descriptor path must be absolute and encoded.
Encoding the path correctly with cli tools like "urlencode"(gridsite-clients) did not work for me.
If you have NodeJS installed and would use a linux machine, you could use this command.
chromium --app=`node -e "console.log('file://'+encodeURI(process.argv[1]))" "$(realpath "/path/of/your/file.html")"`
This works also fine with relative paths.
For windows you have to rewrite this yourself.

How to move jar file from one folder to another in Ruby?

In my Ruby script I have to copy one jar file from lib to a different location. Below is the piece of code where I am trying to do so:
FileUtils.mv("#{$HOME_PATH}/lib/myjar1.jar", "#{$HOME_PATH}")
But it is not able to move the jar file to destination. I am seeing the following error:
No such file or directory - file:/home/path/lib/myjar1.jar or file:/home/path/myjar1.jar
I double checked that myjar1.jar is present in source directory. Not sure why I am seeing that error.
I also tried using FileUtils.cp_r("#{$HOME_PATH}/lib/myjar1.jar", "#{$HOME_PATH}") and I am seeing the following error: unknown file type: file:/home/path/lib/myjar1.jar.
Any guidance in copying or moving a jar file is appreciated.
Im assuming you are starting from your home directory (hence the $HOME_PATH). I prefer to use the given ENV hash in IRB.
In IRB this works in MAC OSX:
>> FileUtils.mv("#{ENV['HOME']}/Desktop/my.jar", "#{ENV['HOME']}")
0
The FileUtils#mv method returns 0 as that is the return code of the Unix version of mv which just means it was successful.

Downloading all files from a FTP directory, running into problems with escaping spaces

I have my camel configured to download all files from a specific FTP directory. Now this is all easy enough and everything seems to be working fine. However, I am running into errors when the files contain a space in their names such as File 123.csv. I know I could specifically target the files with an escape character. The only difficulty is that these files are dynamic in nature and change daily, so I will not know which files may or may not have spaces.
I figure I can just read all the file URI and make adjustments from there. But I was wondering if there is any Camel specific way to handle this.
Errors: java.lang.IllegalArgumentException: Illegal character in path at index 60: hdfs://test.net/user/CamelTests/File Layout.csv
GenericFileOnCompletion - Rollback file strategy: org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy#fe8d1b for file: RemoteFile[File Layout.csv]
Camel Code
from("{{ftp.serverLP}}/Memo/Loss?username=ftp&password=pass")
.to("hdfs2://Test.net/user/CamelTests/?fileSystemType=HDFS")
.log("Downloaded file ${file:name} complete.");
Try changing the .to(..) to use a non-HDFS file system.
The error posted seems to indicate a problem with the destination to which the files are being copied (HDFS), not the FTP source.

Specifying index path with Hibernate Search and Spring

I have problem setting the correct path for my index. It would be great if it was inside my spring application, since it would work even after I deploy my application to Cloudbees I guess.
This is my obejct that I trying to index:
#Entity
#Table(name="educations")
#Indexed(index="educations")
public class Education {
I have the following in servlet-context.xml:
<resources mapping="/resources/**" location="/resources/"/>
I specify the lucene index path like this:
Properties props = new Properties();
props.put("hibernate.search.default.indexBase", "resources/lucene/indexes");
entityManagerFactory.setJpaProperties(props);
Which doesnt give me any error but I cant find the folder either, which I dont understand. I tried searching for it.
I also tried:
props.put("hibernate.search.default.indexBase", "classpath:/lucene/indexes");
and
props.put("hibernate.search.default.indexBase", "/resources/lucene/indexes");
But still cant find the folder. However after a while of struggling with this I try to put it in my home directory. (which might give me problem later when deploying to the cloud):
props.put("hibernate.search.default.indexBase", "/lucene/indexes");
I getting the following
Cannot write into index directory: /lucene/indexes for index educations
So I assume its a permission error. I try the following in terminal (OSX):
sudo chmod -R u+rwX /lucene/indexes/
and
sudo chmod -R 755 /lucene/indexes/
But still the same error. Can someone spread some light on this?
Thank you!
Edit:
After some more investigation I am sure it is a problem of permissions. If I specify the full path to my root of the Spring application, it works. I still don't know how to specify this without giving it the full path.
Relative paths are relative to the directory the Java process is launched from. If you have some startup script or similar look in the directory of this script. Absolute paths work fine, but of course you need permissions to write to it.
If you want a more generic solution for your case, you could for example set the right directory as a system property when starting the application and read it from there when creating your Properties. Or you try in another way to determine the full path of your app at runtime.
I couldn't find where the folders were located either so i came up with the following solution:
First i get the location of the working directory by calling System.getProperty("user.dir"). This is OS independent so it works both on linux and windows. The working directory is the directory from which your application is loaded. Next i simply append the relative path that i want as a location for my lucene indexes to the working directory folderpath. Then i use that as the value for hibernate.search.default.indexBase. Now i'll always know where to look for the lucene indexes.
Heres the code:
String luceneFilePath = System.getProperty("user.dir") + "/resources/lucene/indexes";
Properties props = new Properties();
props.put("hibernate.search.default.indexBase", luceneFilePath);
entityManagerFactory.setJpaProperties(props);

Resources