3

I've been trying to use maven-war-plugin to filter web.xml with profile defined properties, and I made it work on deploying but not on my local server (Apache Tomcat 7.0.65).

I have this on web.xml

<env-entry>
    <env-entry-name>variableName</env-entry-name>
    <env-entry-value>${property.variableName}</env-entry-value>
    <env-entry-type>java.lang.String</env-entry-type>
</env-entry>

This on pom.xml

<property.variableName>This is a variable</property.variableName>

And this on the code:

InitialContext init = new InitialContext();
String variable = (String)init.lookup("java:comp/env/variableName");

The fact is that... on the generated web.xml (target/...web.xml), the variable is filtered with the new value, but deploying on local when I try to print the 'variable' value is logs ${property.variableName}

Any idea about how to fix this?

Thanks in advance and regards,

Deses
  • 1,074
  • 2
  • 12
  • 25
Yolo
  • 31
  • 6
  • How are you deploying to your local server? Are you copying over the war? Are you using the cargo plugin? – Dave Feb 09 '16 at 17:46
  • I add the web project to the resources list on a tomcat server and then 'start the server' (I'm using eclipse sts). When I compile the project, the generated web.xml on target folder have the values filtered, so I can deploy the .war file into a remote server, but when deploying on localhost it seems to take the source web.xml as it is with no value filtered. – Yolo Feb 10 '16 at 09:53

1 Answers1

0

I finally made it work. Seemed to be something related with deployment assembly which was not recognizing some folders or something like that.

The following post helped me to find it: Maven: how to fill a variable in web.xml file

Community
  • 1
  • 1
Yolo
  • 31
  • 6