开发者

how to stepin/debug a Maven web project in eclipse

I have a Maven project which is a web project and is packaged as a war.

I use tomcat-maven-plugin v1.2-SNAPSHOT to do a tomcat:deploy when i want to deploy.

But my question is how do i debug it / set breakpoints like i can do for normal web projects in eclipse (where a Debugging perceptive is shown and the server is paused.)

(i am a noob in this fiel开发者_如何学God)

[EDIT] I am not asking how to deploy to TOMCAT. i am rather asking how to setup the debug mode .FYI i am not able to right click on my project and select run> run on server, even though i have generated WTP specific files through maven.


mvn tomcat:deploy deploys an app to an external Tomcat server. If you want to debug that, you'll need to run that Tomcat server with debugging enabled and set up a remote debugging profile in Eclipse.

Edit: There's a succinct guide to doing this on the Tomcat wiki. The simplest approach is to start Tomcat with catalina jpda start. That will start Tomcat in debug mode listening on port 8000 for debugger connections. Then in Eclipse, you create a "remote" launcher configuration and tell it to connect to localhost:8000.


It doesn't matter whether you deploy it with maven or with Eclipse WTP as long as you started the server to which you deploy from eclipse and eclipse knows where the sources of the code you deployed are placed.

Keep attention if you have set the CATALINA_HOME environment variable, this will used to deploy to with mvn tomcat:deploy. But you can also define this in the configuration of the pom.xml.

<configuration>
    <url>http://www.mydomain.com:1234/mymanager</url>
</configuration>


I'm not sure that it is feasible through the Maven plugin.

But you can generate eclipse specific files: mvn eclipse:eclipse -Dwtp.version=2.0 (The WTP version depends on the WTP version of your Eclipse).

Then, you can update your project and deploying it into a Tomcat like you can do for normal web projects.


This solution worked in my case, you can try this

Add module to Server

Go to the Servers view.
Double click on the Tomcat server.
You will get the server editor view. Click on Modules tab in view (at bottom) Click add External Web Module enter the path to your built files (e.g., C:\svn\projectName\trunk\test\project\target\webapp) and give a path.
Save.

Debug Server

Right-click on Tomcat in Servers view.
Choose Debug.

Debugging Startup

If you are debugging the startup of your application you might need to increase the startup timeout in the server view.

Thanks.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜