Month: March 2014

Tomcat 7 maven plug-in for remote deployment and remote debugging using jpda in netbeans

Posted on Updated on

I am trying to deploy web application in tomcat 7.0.42 remotely and also want to debug remote deployed web application from Netbeans 7.4. During this faced some issue also resolved it from reference but want to consolidate all this steps at one place. It would be helpful to someone who is trying this first time and also for my reference.

Tomcat maven plug-in for remote deployment:

Step 1: Add tomcat plug in build section

<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://localhost:8084/manager/text</url&gt;
<server>TomcatServer</server>
</configuration>
</plugin>
</plugins>
<build>

Step 2: Inside tomcat-users.xml which is located at catalina_home/conf add following

<tomcat-users>
<user password=”passoword” roles=”manager-gui,manager-script,admin” username=”admin”/>
</tomcat-users>

Step 3: Add following setting in your maven settings. File location is user home/.m2/settings.xml

<settings xmlns=”http://maven.apache.org/SETTINGS/1.0.0&#8243;
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221;
xsi:schemaLocation=”http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd”&gt;
<servers>
<server>
<id>TomcatServer</id>
<username>admin</username>
<password>passoword</password>
</server>
</servers>
</settings>

Step 4: from maven project run command tomcat7:deploy

Enable remote debugging in netbeans 7.4:

Step1:  Go to tomcat/Catalina home directory. Open the startup.bat file.

Set parameters at first empty line :
set JPDA_ADDRESS=8000
set JPDA_TRANSPORT=dt_socket
And last line should be replaced
call “%EXECUTABLE%” start %CMD_LINE_ARGS%
by
call “%EXECUTABLE%” jpda start %CMD_LINE_ARGS%

Step 2: Start the tomcat using startup.bat from command line.

Step 3: From netbeans attach debugger with following setting and debug the code.

Debugger : Java Debugger (JPDA)
Connector: Socket Attach
Transport: dt_socket
Host: localhost
Port:8000

attach debugger

Regards,
-Vinayak B

References:

http://tomcat.apache.org/maven-plugin-trunk/tomcat7-maven-plugin/usage.html
http://tomcat.apache.org/maven-plugin-trunk/tomcat7-maven-plugin/plugin-info.html
http://stackoverflow.com/questions/13336816/tomcat7-maven-plugin-tomcatmanager-status-code403-reasonphraseforbbiden
https://confluence.sakaiproject.org/display/BOOT/Setting+Up+Tomcat+For+Remote+Debugging