Setup multi-module maven/tomcat project.

Hi all!
Guys, i have a problem), i came from eclipseIDE, and cant start work properly in idea, cause, i cant understand how to control my project)
Description of my problem: We have a multi module project. structure like this:  SuperProject(with kernel pom.xml, but without any sources. just documentation, scripts and etc.) and  in this folder another project SUBProject(have src, and another pom.xml that dependence from root pom.xml in SuperProject). Here screenshot of my workplace: , u see - upsa - main-root project, and i work with workload .
Now - i cant configure tomcat properly(i can't debug, for example, simple dont stop at breakpoints...) to deploy my(workload) project. How i can target to tomcat(i had install tomcat local and want run locale) to run artifact from upsa/workload/target folder? Now its run from upsa/target . and i have problem eith this, cause, if for example i change xml file, and run again my app, it dont change it real! And another big problem  - i cant debug my app, it simple dont stop at breakpoint. i setup application server like in examples, just set home directory.
I would appreciate, if u can help me, because Idea - very-very cool after eclipse, but u see, a have a problems... tnx!

Comment actions Permalink

Are you running Tomcat:
     1) via an IntelliJ IDEA run/debug configuration?
     2) Externally?
If you are doing option 1, you should be getting breakpoints (assuming you launch Tomcat using the "Debug" icon (Shift+F9)). After making code changes, in order to get those changes to take, you need to refresh the deployment using the "Refresh Deployment Status" button on the left side of the debug tool window (or run tool window).

Here's an example Tomcat Run/Debug Configuration:

If you are using option 2, debugging and refreshing will not work directly from IDEA. You would need to configure a 'remote' Tomcat run/debug configuration for debugging. And would need to manage refreshing the deployment via a script or such.

Comment actions Permalink

ok, thnx. But i want to deploy my app from Idea, and start tomcat from idea.
First - how i can target rigth WAR file(for example project/target/project.war) and want tha Idea build it and then deploy it, not make different classes folders and files in project on upper folder(my project nested from parent)
Second - how exactly refresh after changes(classes refreash good, but not xml from resources)
And last - is it real to debug webbapp without remote connect? cause i read a lot about problems with it.
Thank you!

PS - maybe i should attach screenshots of my project structure and configs?

Comment actions Permalink
But i want to deploy my app from Idea, and start tomcat from idea.

The screenshots I show above are for a Tomcat run/debug configuration that allows you to run and deploy your web application from within IDEA. To create one:

  1. On the menu, go to Run > Edit Configurations
  2. In the top left, click the "Add New Configuration" icon
  3. Select Tomcat Server > Local from the popup
  4. In the right pane:
    1. Give your configuration a name
    2. Select (or create) an Application Server. To create one, just click the "Configure..." button, click the Add button, then set the root of your Tomcat installation in the "Tomcat Home" text field.
    3. On the Run/Debug Configuration dialog, go to the Deployment tab, click the add icon and select "Artifact". Select either the "my-application:war" or "my-application:war exploded" option. Typically selecting the exploded option is fine and saves some IO. If you do not see these options, you need to go to your Project Structure settings (File > Project Structure (Ctrl+Alt+Shift+S)) and add the artifacts. Typically they are there by default assuming you have a web facet defined. Note that you can select multiple artifacts (and set to different context paths) if needed. Such as a service and a client UI applications.
    4. After selecting the artifact to deploy, set the context that should be used in the "Application Context" text field on the right. (You may have to enlarge the dialog to see it.)
    5. Back on the Server tab you can set if you want the browser to automatically open (and to what page) when the configuration is run
    6. Set any VM options you may need
    7. On the Logs tab, you can add any logs you want to have shown in the run or debug window when the configuration is run. You can define a log using Ant file pattern syntax. By default, IDEA will show only the latest file that matches the pattern. And it only shows new content added to file during the current run session. So if the files are names "my-app-YY-MM-DD.log", you can set the path to "/path/to/logs/my-app-*.log". Note that IDEA will automatically show items logged to catalina.out so you do not need to create a mapping for that.
    8. Towards the bottom there is a "Before Launch" option. You typically want "Make" selected there so IDEA will build a fresh war before it launches. Otherwise you must remember to do a make before launch. Alternatively, you can select a maven goal to run. See notes below for pros and cons of each option.
    9. You can set the "On 'update' action" option to a desired value. Click the help button to get more information about the options
  5. Click OK to save the dialog.
  6. To run, make sure the configuration is selected in the "Run/Debug" drop down on the main toolbar then either run (Shift+F10)  or debug (Shift +F9) it. You can also open the run popup (Alt+Shift+F10) or the debug popup (Alt+Shift+F9) and select the configuration from there

how i can target rigth WAR file(for example project/target/project.war) and want tha Idea build it and then deploy it, not make different classes folders and files in project on upper folder(my project nested from parent)

The war file is specified in the run/debug configuration (see step 4.3 above). When IDEA imports a maven based project, it sets it's Make settings to mimic the settings in your maven POM, including the build directories it uses. So by default, the artifact definitions will be to the maven artifacts. If you go to File > Project Structure (Ctrl+Alt+Shift+S) and look on the "Artifacts" pane, you will see a definition for the WAR file and the Exploded WAR file. If you select one, you will see that the "Output Directory" is to the target directory. Assuming that in step 4.8 of the above instructions you set "Make" as the "Before Launch" option, an updated version of the project will be deployed when you run Tomcat. Typically selecting "Make" is a faster option. IDEA tracks files that have changed and only compiles those that have changed. The only time you would want or need to use "Run Maven goal 'package'" as the "Before Launch" option is if your maven build is configured to do some additional processing such as token replacements.

how exactly refresh after changes(classes refresh good, but not xml from resources)

On the run or debug tool window, there is a "Refresh Deployment Status" button . Clicking it will refresh the application. How it does that is set in the You can set how via the "On 'Update' action" option in the Run/Debug Configuration (Step 4.9 above). There is also the option to "Show dialog". When that is selected, a dialog will open when you click the "Refresh Deployment Status" button. You can then change the methodology used each time you refresh.

You may have to select the "restart server" option, or at least the "redeploy" option. Tomcat itself (or a framework you are using) may cache files & resources, or it may not recognized updates to certain configuration files. As a result, the "update resources" and the "update classes and resources" may not work correctly. I typically use the restart or redeploy options just to ensure everything refreshes. I only use the "update classes and resources" when I'm working on a very specific item that I know is updated properly and need rapid redeployment cycles. I never use the update options if I have changed a configuration file (and especially the web.xml file). I like to be absolutely sure everything is reinitialized fresh. I recommend you start with "restart server" and ensure that everything updates properly. Once you are sure that that is working, try the "redeploy" option. Then try the update options.

is it real to debug webapp without remote connect? cause i read a lot about problems with it.

I've been using both local and remote debugging with Tomcat in IDEA almost daily for the past 8 or 9 years. I've never had issues. It has always worked smoothly. Currently I work on a project that has four different web applications/services. I deploy all four locally and debug between them. (For example I'll have breakpoints in the UI web application and the other service web service applications the UI calls.)  More than a dozen coworkers have all had the same positive experience. We've had a number of people migrate from Eclipse to IDEA solely because of how easy it is to deploy and debug a web service in IDEA. So I'm not sure what "problems" people might be referring  to in your reading. If you have some specifics, let us know. There is likely an easy resolution.

The one potential gotcha is whether you have your breakpoint set to Suspend all threads (the default) of just the active thread. If all threads are suspended, it might cause timeout issues in other code. Also if it is a shared server, and others try to access it, they will not get to it if you are at a breakpoint with all threads suspended.

There is more information in the tutorial at: It's not based on a maven project, but everything applies. Also search the Help guide for Tomcat.

Comment actions Permalink

Thank you vary mach for this answer, its very usefull!
Now i have no problem to deploy my new resources files, tnx )
Buuut, still cant connect and debug app, here sreenshots:
Im using tomcat 5.5, run my Intellij Idea on kubuntu12.04(GNU/Linux), and as u can see we are using SSL.
U also see the problem (on last two image). this happend when a i try use this (as debug port).
In my system i use only JAVA_HOME variable (others(like $CATALINA_HOME, $CATALINA_BASE) i think, setting in starting
WHAT can i do in this case?
And, u said that u dont khow about problems, here:


Comment actions Permalink

Thank you for all!
I try to setup tomcat 6 and deploy app.... and IT'S work! really!
Now we have a problem, and i think i must report a bug, maybe? Or its a problem only of tomcat? btw, with the same instance of tomcat eclipse work fine.
That's mean - Intellij Idea have a minor bug =)


Please sign in to leave a comment.