简体   繁体   中英

Debugging Maven Web Application on already installed Glassfish using eclipse

My problem is with respect to debugging web application on an already installed glassfish using eclipse.

If I create a web project using eclipse then eclipse will let be deploy and debug application on an already installed glassfish application server. However, if I have created a web project using maven archetype, eclipse does not let me debug the application.

I can use maven's jetty or tomcat plugin and debug the application but I need to debug application on an already installed glassfish. Basically I have followings 1) Web application created using maven archetype 2) Eclipse IDE 3) Glassfish which is already installed outside of Eclipse IDE

I came across maven's glassfish plugin but as far as I understood it is not for debugging the application.

Please let me know your suggestions.

Thanks

If I create a web project using eclipse then eclipse will let be deploy and debug application on an already installed glassfish application server. However, if I have created a web project using maven archetype, eclipse does not let me debug the application.

This is not true. Whether you use the Maven Eclipse Plugin (which provides WTP support ) or m2eclipse (with the optional Maven Integration for WTP installed from the m2eclipse Extras ), you can deploy a project created outside Eclipse to an existing " Server " (that you can start in Debug mode), as long as you imported it appropriately ( Import... > Existing Project into Workspace if you use the former, Import... > Maven Projects if you use the later).

Basically I have followings 1) Web application created using maven archetype 2) Eclipse IDE 3) Glassfish which is already installed outside of Eclipse IDE

I use the same setup with several projects with no problem (and can debug them on my locally installed GlassFish server).

I came across maven's glassfish plugin but as far as I understood it is not for debugging the application.

There is no need for extra Maven plugins, you can just rely on your IDE if you follow the right steps.

I don't know about eclipse, but IntelliJ IDEA has a remote debug feature. You start your server with something like

-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5055

and then the IDE will connect to that port and you'll have a regular debug.

I'm sure eclipse has this feature.

EDIT: This article shows how to use this feature with eclipse.

I´m going to write it most for me in order to keep trace of my solution:

If you are using the maven.failsafe plugin just force the execution of glassfish internally the current JVM started by maven avoiding the fork with the parameter

-DforkCount=0

in such way you are able to debug both test and server from the usual way, ie. running a debug task from eclipse and setting break points both in test and in server side.

Extra parameter information could be found here, including setting different debug port:

http://maven.apache.org/surefire/maven-failsafe-plugin/examples/debugging.html

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