Announcement Announcement Module
Collapse
No announcement yet.
database.properties outside of my deployed jar file Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    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>

    Comment


    • #3
      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

      Comment


      • #4
        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

        Comment


        • #5
          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 &

          Comment


          • #6
            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...

            Comment

            Working...
            X