Results 1 to 6 of 6

Thread: database.properties outside of my deployed jar file

  1. #1
    Join Date
    Jun 2005
    Location
    Boston MA
    Posts
    4

    Post database.properties outside of my deployed jar file

    Hello;

    I am sure my problem is a common problem, but I cannot seem to find an solution in the forums.

    I have a Java application that uses Spring/Hibernate. I package this application up into a batch.jar file that contains all of my class files and applicationContext.xml files. I am also using PropertyPlaceHolderConfigurer in my applicationContext.xml file to load my database specific information. This information is contained in a file called 'database.properties'

    I am trying to run my batch on the UNIX command line like the following.
    java -classpath $HOME/lib/batch.jar:$HOME/properties/database.properties com.putnam.fams.batch.BatchProcessMain

    Spring keeps failing because it cannot find the database.properties file. When I put the database.properties file inside of the batch.jar file it works fine. I need to have it outside of the jar so I am able to change it.

    Any help would be appreciated or please send me to a similar post.

    Thanks
    Peter
    Peter Delaney
    Senior Technologist
    delaneymichaelpeter@gmail.com

  2. #2
    Join Date
    Sep 2007
    Location
    Oceanside, CA
    Posts
    187

    Default

    Have you tried setting just the directory where your properties file lives in your CLASSPATH instead of the full file name? For example:

    Code:
    java -classpath $HOME/lib/batch.jar:$HOME/properties com.putnam.fams.batch.BatchProcessMain
    Then, something like the following for your PropertyPlaceholderConfigurer:

    Code:
    <bean  class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location" value="classpath:database.properties"/>
    </bean>
    Mike Bingham

  3. #3
    Join Date
    Jun 2005
    Location
    Boston MA
    Posts
    4

    Smile This works

    Hello; Thanks for that response. I got dragged into another direction so I wasn't able to respond. This works; I appreciate your help. Thank You Peter
    Peter Delaney
    Senior Technologist
    delaneymichaelpeter@gmail.com

  4. #4

    Default

    Hi, I am using -jar option instead of classpath option.
    /opt/java/bin/java -jar /opt/testhrjobs/script/gmsglp/java1/gmsglp_batch.jar glprunner.xml glpFeed

    the last two arguments are paramaters to main function of the first class that would be invoked.

    Can you please help to frame command to refer a file(data.txt) which sits in
    /opt/testhrjobs/data/gmsglp/incoming/data.txt folder? PLease note code is in script folder and data.txt is in data folder.

    Any help would be appreciated.

    Thanks,
    Mansih G

  5. #5
    Join Date
    May 2013
    Posts
    2

    Default

    Hello,
    can u tell me the way how it worked... iam dying with it..

    where am using this
    nohup java -cp "lib/com.ibm.mqjms.jar:lib/com.ibm.mq.jar:lib/commons-io-2.1.jar:lib/j2ee.jar:lib/org.springframework.transaction-3.0.7.RELEASE.jar:lib/org.springframework.jms-3.0.7.RELEASE.jar:lib/org.springframework.expression-3.0.7.RELEASE.jar:lib/org.springframework.core-3.0.7.RELEASE.jar:lib/org.springframework.context.support-3.0.7.RELEASE.jar:lib/org.springframework.context-3.0.7.RELEASE.jar:lib/org.springframework.beans-3.0.7.RELEASE.jar:lib/org.springframework.asm-3.0.7.RELEASE.jar:lib/commons-logging-1.1.1.jar:lib/dhbcore.jar" -jar rxdatatransfer.jar rxtConfig.xml >& /dev/null &

  6. #6
    Join Date
    May 2013
    Posts
    2

    Default

    Hello,
    can u tell me the way how it worked... iam dying with it..

    where am using the following

    nohup java -cp "lib/com.ibm.mqjms.jar:lib/com.ibm.mq.jar:lib/commons-io-2.1.jar:lib/j2ee.jar:lib/org.springframework.transaction-3.0.7.RELEASE.jar:lib/org.springframework.jms-3.0.7.RELEASE.jar:lib/org.springframework.expression-3.0.7.RELEASE.jar:lib/org.springframework.core-3.0.7.RELEASE.jar:lib/org.springframework.context.support-3.0.7.RELEASE.jar:lib/org.springframework.context-3.0.7.RELEASE.jar:lib/org.springframework.beans-3.0.7.RELEASE.jar:lib/org.springframework.asm-3.0.7.RELEASE.jar:lib/commons-logging-1.1.1.jar:lib/dhbcore.jar" -jar rxdatatransfer.jar rxtConfig.xml >& /dev/null &

    in this case where to include the .properties file...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •