Friday, 15 November 2013

Run Web app on embedded tomcat7 through maven

Add the tomcat7 maven plugin to the build section of your pom
      <java_opts>-XX:MaxPermSize=2G -XX:PermSize=2G</java_opts>
Place the configuration under LocalDeployment/myApp.xml the LocalDeployment directory is at the root of the project at the same level as the pom.xml. This can be anywhere as long as you point to it correctly in the plugin configuration
<context path="/myapp" reloadable="false">
    <!-- some  envrionment variables --> 
    <environment name="nodeId" override="false" type="java.lang.String" value="node01">
To run the web app use the following maven goals
mvn tomcat7:run           //run the project without building a war file
mvn tomcat7:run-war-only  //finds a war file in project and runs it
mvn tomcat7:run-war       //build and run a war file for current project
more goals can be found Here

To Debug in IntelliJ idea

Simply right click on any goal in the maven Projects tab Then under plugins->tomcat7 right click on a goal and select debug

To Debug in Eclipse

We need to first run tomcat listening for debug connections
Right click on project --> Run as maven build ... --> Enter goal: tomcat7:run
Select JRE Tab,
Enter in Vm Args: -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044

Now to connect to the debug port (1044)
Right click on project -->  debug configuration
Set Project: to your project
Set connection type to: "SOCKET ATTACH"
Set Host to: localhost
Set Port: 1044 and then press debug

No comments:

Post a Comment