简体   繁体   中英

TomEE Maven plugin: Deployment path

When deplyoing a webapp using the tomee-maven-plugin, the effective URL the application is hosted on results to:

http://localhost:8080/[artifactId]-[version]/

I would like to set that relative path arbitrarily, like eg:

http://localhost:8080/myservice/

Which configuration parameter in the tomee-maven-plugin does that?

Thanks for a quick hand and best regards

Pascal

You probably get that context path because it is the name of the warfile artifact.

You can set the finalName in pomfile:

 <build>
     <finalName>myservice</finalName>
     [ all other configuration ... ]
 </build>

This will produce a myservice.war file. If you want just to use a different context path without having a differently named artifact, you can specify it in the plugin configuration

<plugin>
  <groupId>org.apache.openejb.maven</groupId>
  <artifactId>tomee-maven-plugin</artifactId>
  <version>1.0.1</version>
  <configuration>
    <finalName>myservice</finalName>
    <warFile>point this to your warfile</warFile>
  </configuration>
</plugin>

or alternatively, you can try to add a META-INF/context.xml to your artifact, containing:

<Context path="/myservice" />

Guido's bogus answer (with 3 upvotes!) wasted a lot of my time. It's full of bad advice.

Responding to Guido's three pieces of advice:

  • "Set the warfile name in the <build> tag" - This is not good advice. You lose your versioning information of your artifact, and to rename your wars to make a deployment plugin happy is entirely bass-ackwards.
  • " <finalName> tag" - This is either outdated information or flagrant misinformation. Either way, it--and the lack of documentation on the plugin--cost me a significant amount of time. See below for the real answer.
  • "Create a META-INF/context.xml in our artifact" - This is technically true but semi-useless advice. Per the apache documentation for Tomcat/Tomee:

When autoDeploy or deployOnStartup operations are performed by a Host, the name and context path of the web application are derived from the name(s) of the file(s) that define(s) the web application. Consequently, the context path may not be defined in a META-INF/context.xml

If Guido deletes his answer, all of the above can be removed.

To specify the context path for a web app in the tomee-maven-plugin:

<configuration>
...
    <context>${artifactId}</context>
...
</configuration>

This will, for example, deploy myapp-1.0.0-SNAPSHOT as /myapp .

Also, while I'm ranting, I may as well make the world a better place and add what else I've learned, since the tomee-maven-plugin's homepage contains virtually no information about the available configuration options...

  • Try running with -X , it prints out an XML block of the current XML configuration. (eg " mvn tomee:run -X and look for " <configuration> ").
  • If you're transitioning from the tomcat-maven-plugin to the tomee-maven-plugin , you can't use any of your existing configuration. Throw it away.
  • The author of the tomee-maven-plugin only provides documentation in random blog posts, so look there if you have issues or even better troll through all the OpenEJB source code. Grrr...
  • If you're using SSL certs there's also little information about what it takes to get up and running:

First, there's an undocumented "classpaths" tag that may be useful to you:

<classpaths>
    <classpath>${someClasspath}</classpath>
</classpaths>

Secondly, there's an undocumented systemVariables tag that you can use, (or you could use <args> ) to specify your keystore and truststore. It looks obvious below, but nowhere else actually tells you what the tomee-maven-plugin expects, and there's a fair amount of misinformation as well (eg that any JKS in the conf will be auto-loaded), so here's what actually works :

<systemVariables>
    <javax.net.ssl.trustStore>${some.path}/truststore.jks</javax.net.ssl.trustStore>
    <javax.net.ssl.trustStorePassword>somePassword</javax.net.ssl.trustStorePassword>
    <javax.net.ssl.keyStore>${some.path}/keystore.pkcs12</javax.net.ssl.Store>
    <javax.net.ssl.keyStorePassword>somePassword</javax.net.ssl.keyStorePassword>
    <javax.net.ssl.keyStoreType>someType (e.g. PKCS12)</javax.net.ssl.keyStoreType>
</systemVariables>

Hope this helps someone someday. :-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM