I've a java web-app with JSF 2.2 and Spring 4.2.
My goal is to deploy my web-app on glassfish 4.1.1, and the OS is ubuntu server 16.04.

I try to deploy my web-app with the following command

```
asadmin deploy myWebApp.war

```

but after I fill userName and password I've an error that tell me my application doesn't see an environment variable.

The configuration that generates the error is the following

```
@Autowired
private Environment env;

@Bean
public PropertiesFactoryBean myExternalProperties() {
    PropertiesFactoryBean res = new PropertiesFactoryBean();
    res.setFileEncoding("UTF-8");
    res.setLocation(new FileSystemResource(env.resolvePlaceholders("${MY_ENV_VAR}") + "external.properties"));
    return res;
}

```

but if from the command line I launch the following command

```
printenv MY_ENV_VAR

```

the variable is correctly filled.

I've tried in two different ways

1. Place the environment variable in /home/myUser/.bashrc adding the line export MY\_ENV\_VAR=myPath
2. Place the environment variable in /etc/profile.d/myShFile.sh adding the line export MY\_ENV\_VAR=myPath

But no luck. Can you help me?
On Windows the application is working, I suppose I'm doing something wrong while setting the environment variable.