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 field)
[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.
Related
I have a Advanced Java Application(Spring+Hibernate) with Maven. Project runs without any error.
I follow below process to test the application.
Build War using below command.
C:\Dev\ProjectApp> mvn clean package -Dmaven.test.skip=true
This builds war file inside target folder(C:\Dev\ProjectApp\target).
Place Application.war inside webapps folder(C:\Apps\Apache\Jakarta\Tomcat6\webapps)
run startup.bat from Tomcat6\bin folder.
hit the application in web Browser (http://localhost:8080/).
I want to debug this application from eclipse IDE itself. While application runs in webbrowser. I want to debug using breakpoints.
What are the steps to run this application in eclipse? What are constraints involved in this?
Thanks in Advance !
To simply debug the flow of the application, you can use the eclipse as the basis.
Goto the server view and create a new tomcat server (or any server that you use for dev). Next right-click on your project --> run as --> run on server and select the server that you just created. Keep in mind that the server should have all the configurations that you need to have to run the application. If your project requires some custom settings in the application server, then tell eclipse to take control of the server installation by selecting "Use Tomcat installation". (double click on the server to configure it)
Next add debuggers and start the server from within eclipse.
Happy debugging !
Set the environment variables first
set JPDA_ADDRESS=8000
set JPDA_TRANSPORT=dt_socket
You can edit the startup.bat to have
call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%
and start in the same way as above.
After this you can have your eclipse open a remote debugging session that connects to localhost:8000.
However, I would strongly recommend to use the WTP plugin in eclipse to build and start/stop the tomcat from within eclipse itself.
I am trying to get a GWT Project running on a Tomcat 7 server in eclipse. I installed Tomcat and i can run other web application out of eclipse on Tomcat without a problem.
Now i generated a gwt maven project for eclipse with the following command and importet it as maven project to eclipse:
"mvn archetype:generate -DarchetypeGroupId=org.codehaus.mojo -DarchetypeArtifactId=gwt-maven-plugin"
I can run this now as Web application (with the google plugin) and i can build a "war" with maven and deploy this with the Tomcat management console on the server. Both is working. But if i choose the option in eclipse "Run on server" and choose tomcat than just the html is loaded but not the application itself. See the screenshot: It doesn't find the "GWTModule.nocache.js".
This file is available in the target folder. What do i have to change to tell tomcat to look in the correct directory?
Tomcat is not able to run GWT code in development mode. You can use Tomcat for server side code, but in this case you need to run GWT development mode with -noserver option (to prevent built-in Jetty instance from running). See this article for more details.
I would recommend using the wtp plugin for eclipse. If you do this you can add your project/resource to tomcat when adding a new server. Here are the steps to use if you already have your project imported into eclipse.
Window -> Show View -> Servers
In Servers
New -> Server -> Choose apache tomcat
Point to the location of your tomcat installation/download
Next
At this point you should be able to add your gwt-maven project which will add the target/project.war to the tomcat modules.
Save it
Click on the newly added server, then click the modules tab at the bottom kind of hard to see.
This should have your project shown in the list of web modules.
Start your tomcat instance then on your gwt application right click and choose Run As -> Web application. Make sure your configuration settings are correct and when the development server starts it should give you the development url to browse to.
You can configure some aspects of tomcat in the overview tab, I would recommend making sure that "Modules auto reload by default" is checked so that tomcat will watch the filesystem for class changes.
I have a maven build Java project.
My war file name is: test-1.0-SNAPSHOT.war
I am using M2E plugin in Eclipse.
I have run target mvn package.
Added server as tomcat version 7 in eclipse indigo 3.7. Server started. But my war file didn't deployed in the server.
I have tried by right clicking tomcat server and Add remove..., it says "there is no resources that can be added or removed from the server".
How can i deploy my war file in the eclipse WTP tomcat server?. Do i need to run any maven target?
Make sure that you have "Maven Integration for WTP" installed in your Eclipse instance.
First check if it's available through
Window->Preferences->Maven->Discovery->Open Catalog
If for whatever reason this does not work, you can get WTP integration from this update site (that's the version I am currently using):
https://repository.sonatype.org/content/repositories/forge-sites/m2eclipse-wtp/0.13.0/S/0.13.0.20110623-0455
This integration does a lifecycle mapping of maven-war-plugin into m2e architecture.
Once you've installed the WTP integration, you must restart eclipse and once it's restarted, right click on your web app project and choose: Maven->Update Project Configuration...
Also, I would advise to run a clean build at this time.
Last, but not least, delete and recreate your Tomcat server configuration (I don't know why, but I had to do it quite a few times when I switched to m2e).
I think eclipse is not recognizing your project as a web app, To confirm this
Open to do open J2ee perspective on your eclipse, If you open the project folder of your app, You should see (Deployment Descriptor)
If you don't see it, your app is not web app as far as eclipse is concerned
I have see this in case if you imported/created a maven command line project
To fix this
Select Project ==> Properties ==> Project Facets ==> make sure Dynamic Web Module check box is checked
If you do that the local tomcat server will add your app when do add remove projects
I think eclipse is not recognizing your project as web app,convert your project into web app by command mvn eclipse:eclipse -Dwtpversion=2.0 and try to deploy in Eclipse configured tomcat,it will work.
If you have Eclipse 3.5 or above you should ensure that you have both the m2eclipse (m2e for 3.7) plugin installed and its WTP add-on. With these you shouldn't need to change your configuration by hand.
Did you try to build your project from the command line and deploy it in Tomcat by hand?
By the way, have you read this wiki post? It's a bit old, but it may still be relevant.
Adding 2 cents to Prasanna wonderful solution.
I realized that building maven war files "mvn package" was just creating .war file but eclipse was not picking up that war but was deploying its some internal version of it's app war.
I found that server > Browse Deployment Location.. in Eclipse server view .. it was taking to some abstract location like "C:\Programs\workspaceSTS.metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps"
Where I could see my exploded app deployed but it was not having any /classes folder just limited files.
Using Prasanna's method I realized that eclipse now was deploying full exploded .war now.
So this was happening coz changing the facets to Dynamic Web Module has actually populated "R-click project > Properties > Deployment Assembly "
This Web Deployment Assembly window only tells eclipse what to deploy and what not. So even if your project is NOT setup as Dynamic Web Module , and still if you configure "Web Deployment Assembly" values properly , eclipse will deploy the app fine to Tomcat/ Server.
Sounds simple, but I'm having lots of issues.
I want to run a GWT project in a tomcat on Intellij-idea 10.
Does anyone know how to set up the run config?
Regards,
Charles.
You can use '-noserver' option to start Dev Mode under Tomcat. Edit your GWT run configuration by adding '-noserver -port 8080' to 'Dev Mode parameters' field, then run the Tomcat configuration and after that run the GWT configuration.
This all implies that this is a development run, i.e. for local testing/debugging purposes. This is not deployment to production servers. I also assume you have GWT and Web facets defined for this project.
If you need GWT debugging, then you must run as GWT run configuration: here you can only choose a Default server (Jetty that comes with GWT) or an AppEngine Development server (if installed).
If you must run under Tomcat, then:
a. Add a Tomcat server under Settings - App Servers.
b. Create an Artifact - WAR exploded (under project settings). Add all items in right pane to the left pane.
b. Create a Tomcat run configuration with this Artifact.
You first run gwt compiler for compile gwt module, then compiler creates to your hosted .js and .html files. And you can run tomcat as usual but tomcat does not compiles your gwt modules.
I suggest you t use ant to compile gwt modules.
How to create and run GWT web project in eclipse with tomcat or another app-server?
I created a Gwt Project and when i run or debug it, eclise did use GWT hosted mode server.
I can not find and configuration in project properties to select tomcat or another server for the project/
Regards
In the GWT Run/Debug configuration of the project you want to run/debug, tab Main, deselect the "Run built-in server" option. After that, it's your responsibility to generate the html/js/images of the GWT module you want to run, and place them somewhere where Tomcat or JBoss can see them. That usually means deploying a war at least.