Rohit Bajaj
asked on
how to pass command line arguments to Jetty
HI,
I am starting jetty like : service jetty start
This links to the jetty.sh file...
Now in my java code i have the following lines :
If i make an environment variable with name FLOCK_APPS_CONFIG it works.
But i dont want to make an environment variable. I want to use another approach
in which some way i pass this parameter while starting jetty.
How can i do this ?
Thanks
I am starting jetty like : service jetty start
This links to the jetty.sh file...
Now in my java code i have the following lines :
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:properties/${FLOCK_APPS_CONFIG}/log4j.properties</param-value>
</context-param>
<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:properties/${FLOCK_APPS_CONFIG}/database.properties</value>
</property>
</bean>
If i make an environment variable with name FLOCK_APPS_CONFIG it works.
But i dont want to make an environment variable. I want to use another approach
in which some way i pass this parameter while starting jetty.
How can i do this ?
Thanks
ASKER
i will be running the service from a headless user in linux. it wont have any environment variablea no bash profile. so i guesa i cannot do that
ASKER
i can have the parameter also in a file. but the problem is how does spring pick it up at runtime. as based on this parameter i will pick up correct configuration file.
it wont have any environment variablea no bash profile. so i guesa i cannot do thatYou (almost certainly) guess wrong
ASKER
Hi,
That didnt work even for a normal user i tried : export FLOCK_APPS_CONFIG=staging; service jetty start
But i got the following error in jetty logs :
IllegalArgumentException: Could not resolve placeholder `FLOCK_APPS_CONFIG` in string value "classpath:properties/${FL OCK_APPS_C ONFIG}/log 4j.propert ies
That didnt work even for a normal user i tried : export FLOCK_APPS_CONFIG=staging;
But i got the following error in jetty logs :
IllegalArgumentException: Could not resolve placeholder `FLOCK_APPS_CONFIG` in string value "classpath:properties/${FL
ASKER
For the normal user also it works only when i put export FLOCK_APPS_CONFIG=staging in ~/.bash_profile
As what user is jetty running?
ASKER
i am logged in as root.its running as root only
ASKER
i have read about parameters passing with -D option. dont know much but if there is some way to pass it inside jetty.sh script file which is inside of bin ...probably things will work
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window