Launch the correct context root with Netbeans (and Maven)

I have a little problem when I run a project from my Netbeans 7.2 (I also use Glassfish 3.1.2 server) ...

In fact, I am migrating existing projects from Ant to Maven, my pom.xml is finished, and I used the context root setting as described here: http://maven.apache.org/plugins/maven-ear-plugin/examples/customizing-context -root.html , but when I run the project from netbeans, it deploys with the name of my .ear: localhost:8080/MyApplicationEAR-0.1-SNAPSHOT instead of localhost:8080/MyApplicationName (referenced by <contextRoot>/MyApplicationName</contextRoot> )

If I write the correct URL in my browser, it works fine, but it is not very nice.

Is there a problem with Netbeans or am I forgetting something?

EDIT: Application.xml is automatically generated by Maven and the context root is well-formed, but Netbeans doesn't seem to matter with that ...

+3
source share
2 answers

If you are using Maven and deploying it to JBoss, try this.

You must edit the pom.xml file and add the following line to the <build> section.

 <finalName>${artifactId}</finalName> 
+3
source

I just tried this with Netbeans 7.3 beta and it works.

I assume that you put artifact tags and groupId in your module tag. If not, this could be your problem. Here is an example of my plugin:

  <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-ear-plugin</artifactId> <version>2.8</version> <configuration> <version>6</version> <defaultLibBundleDir>lib</defaultLibBundleDir> <generateApplicationXml>true</generateApplicationXml> <applicationName>Gen</applicationName> <modules> <ejbModule> <artifactId>Testing-ejb</artifactId> <groupId>de.roeperweise.testing</groupId> <bundleFileName>ejb.jar</bundleFileName> </ejbModule> <webModule> <artifactId>Testing-web</artifactId> <groupId>de.roeperweise.testing</groupId> <bundleFileName>web.war</bundleFileName> <contextRoot>/custom</contextRoot> </webModule> </modules> </configuration> </plugin> 
+2
source

Source: https://habr.com/ru/post/945307/


All Articles