TomEE Maven Plugin: finally server.xml in your pom!


Until 1.x releases to configure the server.xml related to tomee maven plugin (embedded or not) you needed to configure either its direct location through “serverXml” parameter or a “conf” folder containing a server.xml. This is working fine but it was often forcing you to create a folder containing the server.xml only.

Note: if you are not used to tomee maven plugins, you can configure almost all the container through properties in the pom.

To avoid it both plugins now got a new variable to let you provide your server.xml inline!

This new parameter is called “inlinedServerXml” and is just a wrapper for a server.xml content:

<plugin>
  <groupId>org.apache.openejb.maven</groupId>
  <artifactId>tomee-embedded-maven-plugin</artifactId>
  <!-- or   <artifactId>tomee-maven-plugin</artifactId> -->
  <version>${tomee.version}</version>
  <configuration>
    <inlinedServerXml>
      <Server port="8005" shutdown="SHUTDOWN">
        <Listener className="org.apache.tomee.catalina.ServerListener"/>
        <Listener className="org.apache.catalina.startup.VersionLoggerListener"/>
        <Service name="Catalina">
          <Connector port="8080" protocol="HTTP/1.1" />
          <Engine name="Catalina" defaultHost="localhost">
            <Host name="localhost" appBase="webapps"
                  unpackWARs="true" autoDeploy="true">
            </Host>
          </Engine>
        </Service>
      </Server>
    </inlinedServerXml>
  </configuration>
</plugin>

It is however important to note few things:

  • without keepServerXmlAsThis parameter set to true the ports of your server.xml will be replaced by tomee*Port parameters
  • if you activate keepServerXmlAsThis parameter then ensure to align tomee*Port (at least http and stop) to let the plugin controls properly the instance
  • server.xml will be formatted automatically and your formatting can be lost. This last point is not important for tomee embedded but can be important if you use tomee:build goal. In this last case you’ll loose your comment and can desire to switch back to serverXml parameter.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s