question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

unable to use environment variable

See original GitHub issue

I’m trying to use an environment variable JAVA_HOME in service.xml config. Somehow it gets not replaced. Is this the right way to work with env variables? As soon as I replace %JAVA_HOME% in service.xml with a jdk folder it works.

  <id>tie-config-server</id>
  <name>Configuration Server</name>
  <description>Distributed Configuration - Properties Server</description>
  <env name="JDK_HOME" value="%JAVA_HOME%" />
  <executable>%JDK_HOME%/bin/java</executable>
  <arguments>-Xrs -Xmx256m -jar ie-config-server.jar --spring.config.location=./properties/config-server.yml</arguments>
  <startmode>Manual</startmode>
  <log mode="roll-by-time">
      <pattern>yyyyMMdd</pattern>
  </log>  
  <logpath>%BASE%/logs</logpath>
  <onfailure action="restart" delay="30 sec"/>    
</service>```


Setting env variable , install and start Commands

D:\admin-bundle> set JAVA_HOME=D:\Oracle\java\jdk1.8.0_144

D:\admin-bundle> ie-config-server install

D:\admin-bundle>net start tie-config-server The iengine - Configuration Server service is starting. The iengine - Configuration Server service could not be started.

Log output:

2017-07-30 22:17:35,433 DEBUG - Starting ServiceWrapper in the CLI mode 2017-07-30 22:17:35,761 INFO - Installing the service with id ‘tie-config-server’ 2017-07-30 22:17:35,854 DEBUG - Completed. Exit code is 0 2017-07-30 22:17:39,505 INFO - Starting ServiceWrapper in the service mode 2017-07-30 22:17:39,551 INFO - Starting %JAVA_HOME%/bin/java -Xrs -Xmx256m -jar ie-config-server.jar --spring.config.location=./properties/config-server.yml 2017-07-30 22:17:39,567 INFO - Starting %JAVA_HOME%/bin/java -Xrs -Xmx256m -jar ie-config-server.jar --spring.config.location=./properties/config-server.yml 2017-07-30 22:17:39,583 DEBUG - Completed. Exit code is 0


regards & thanks for help
cyrill

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
cuzzasoftcommented, Nov 29, 2017

This seems like a bug, unless I’m doing something incorrectly? The docs currently say:

“Configuration XML files can include environment variable expansions of the form %Name%. Such occurrences, if found, will be automatically replaced by the actual values of the variables. If an undefined environment variable is referenced, no substitution occurs.”

If we’re not able to use environment variables, what is the env for? Would be great to be able to use them as otherwise need to get a user to ensure Java is in the system path, rather than getting it from something else.

0reactions
jeacott1commented, Sep 30, 2019

so, I’ve just been doing this

 <executable>start.bat</executable>

and in my bat file I can do things like

SET javapath=javaw
for /d %%D in ("%~dp0\..\jre*") do if not defined f set f=%%~fD
IF defined f (
        SET javapath=%f%\bin\javaw
) 
"%javapath%" -Dloader.path="file:////%~dp0lib" -Dspring.profiles.active=xxx -jar "my.jar" -someparam

I havent tried with env vars, but if winsw copies the environment, at least the bat file will do the expansion.

Read more comments on GitHub >

github_iconTop Results From Across the Web

5 reasons why your .env environment variables don't work
5 reasons why your .env environment variables don't work · 1. Your framework doesn't automatically load .env files. · 2. You added or...
Read more >
Problems with Environment Variables
If the error message states that the environment variable is not set, IT MEANS PRECISELY THAT ! The most likely reason is that...
Read more >
Why can't Windows handle an environment variable in Path?
I'm looking at this in Windows 10 -- variable substitution into PATH failed intermittently to work. Going to Environment Variables & saving ...
Read more >
Can't access environment variables
I can access my environment variables when running my react app locally on localhost:8000 (using netlify dev ).
Read more >
Can't edit environment variables in windows 10
I got around it by opening the System page in Control Panel (Win+X -> Y), going to "Advanced system settings", then clicking "Environment ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found