Download files to Openshift directory - download

I am using Openshift to allocate a Java application. This app contains a method that needs to download a xml file inside the project to explore it later.
So, the thing is that I need the path for the directory where I want to download the file.
And that is the trouble, I don't know how to call the path I want.
For example:
String filePath = "webapps/downloads/file.xml";
But Openshift tells me the error:
/var/lib/openshift/56e18fa***********0029/jbossews/webapps/downloads/file.xml
(No such file or directory)
The structure of my project is:
Project
src > main
java
resources
webapp
webapps > downloads
I Hope I have explained well. Thanks in advance!

Related

where does jetty serve files from

I just installed jetty 9.4.6. I dropped one of the war files from the demo area into $JETTY_BASE/webapps. The war file got expanded into /tmp/jetty-10.1.100.103-8080-test.war-_test-any-4774924669679182185.dir
I then tried a curl on it like this: :8080/test/index.html. I get a 503 error. I verified that index.html exists.
So does jetty serve the compressed war file or does it serve from the tmp folder? Any doc links would be greatly appreciated.
Yes, it creates a temp directory, though you can also define and persist your own if you'd like.
By default, Jetty will create this directory inside the directory
named by the java.io.tmpdir System property. You can instruct Jetty to
use a different parent directory by setting the context attribute
org.eclipse.jetty.webapp.basetempdir to the name of the desired parent
directory. The directory named by this attribute must exist and be
writeable.
You can find more in the official documentation here.

How to use executable resides in jar which is launched from java web start?

I have created a Java Web Start Application. So my application launch from the web browser. I need to run an executable file on MAC OS. So I have packaged my executable file inside my jar file. But I am not able to load it from the classpath as it gives me File or Directory does not exists exception. Then I have tried by extracting the jar file, but as it is launched from the web browser, I am not able to get the location of the jar file. I have seen the path of java cache from the Java Control Panel, and I have searched on that path but not getting anything.
Is there any option to use the executable which resides in jar file without extracting jar file ?
How do I get my downloaded jar file in the system ? I have checked the java control panel path but I am not getting the jar file.
I want to copy the executable to temp directory. How do I ?
Please help me on this.

How to configure relative datasource file for SQLite?

I'm trying to configure a SQLite database for an Spring Web App. The thing is that I'm not able to reach the database file that I've created in src/main/resources using a relative path.
I've tried several configurations for the jdbc url but none of them worked:
jdbc:sqlite:mydb.sqlite (here I changed the file location to the project root)
jdbc:sqlite:${jdbc.url} (here I passed the url as a parameter thru PropertyPlaceholderConfigurer)
jdbc:sqlite:src/main/resources/mydb.sqlite
A weird thing that I realized about is that the app is using Eclipse's directory as the directory to find the database file. I mean, when I put jdbc:sqlite:mydb.sqlite it creates an mydb.sqlite on Eclipse's directory not in project's root.
Check the JVM system property named "user.dir" and set the path relative to it. It is the "current dir" of your java app. It can be different if you run from eclipse or from cmd line or inside webserver(tomcat).
So, System.getPropery("user.dir") will tell you current dir of your running app. Set the path to db relative to that directory.
I would say eclipse does not run your app from the project dir, as it should by default. Check your "run" settings in the eclipse.

How to make a path relative in the vmargs?

In my project I have an eclipse cdo-server which is set up as described here: http://wiki.eclipse.org/Setting_up_a_CDO_Server .
My project structure is like this:
-cdo-server plugin
|- config folder with cdo-server.xml
|- pom.xml
-cdo-server-product
|-pom.xml
-master
|-pom.xml
When I start my cdo-server.product as Eclipse application everything works fine.
When I build it and materialize it with Maven, it also has a BUILD SUCCESS. But when I start the CDO-CommonRepositoryServer.app which was built with Maven, there is the error:
!MESSAGE CDO server configuration not found:
/Users/pathtoCDO-Server/CDO-CommonRepositoryServer.app/Contents/MacOS/${resource_loc:/cdo.server/config}/cdo-server.xml.
This is logical, because this is the wrong path. When I enter the absolute path to the cdo-server.xml in the vmargs (-Dnet4j.config=/Users/pathtoCDO-config/cdo-server.xml) it also works. However, I want to make it relative, so that everybody in our git-repo can use it and not only in my folder structure.
Is there any possibility to make this path relative?
With -Dnet4j.config="${resource_loc:/cdo.server/config}" it only works when i run it as an eclipse application, but not as maven built .app file.
Update:
Now I can start the CDO-CommonRepository.app file if I take
-Dnet4j.config=../../../../../../../../../../cdo.server/config
as path, but then I can only start it with the maven built file and I cannot start it from inside Eclipse anymore...
I've created a new question for this new problem: Slash in property name in pom.xml
I just solved my problem in copying my files with Maven copy-resources in this stupid /Users/pathtoCDO-Server/CDO-CommonRepositoryServer.app/Contents/MacOS/${resource_loc:/cdo.server/config}/cdo-server.xml folder.

How to package JMeter with Jar Bundler on Mac

I'm unable to use "Jar Bundler" on mac to create JMeter.app from ApacheJMeter.jar, I was wondering if anyone else had previous experience with configuring this tool? The problem for me seems to be that the lib folder being searched is set to an incorrect base path:
org.apache.jmeter.NewDriver: JMeter home directory was detected as: /Users/username/Applications/JMeter.app/Contents/Resources
I looked here: http://developer.apple.com/library/mac/#documentation/Java/Reference/Java_InfoplistRef/Articles/JavaDictionaryInfo.plistKeys.html
But no matter how I configured any of the said properties, the logs looked the same.
The real trick is making sure the bin and lib folders can be found. The only jar file you will need to add is ApacheJMeter.jar. Look in the bin/jmeter script for additional properties to put into the properties tab of the Jar Bundler. The java arguments in the bin/jmeter script should be copied into the VM Options field. Check Set Working Directory to Inside Application Package. Now create application. Open up the .app folder that was just created and copy the bin and lib folders into the Resources directory. Done.

Resources