Local Tomcat Deployment

Hi,

Where exactly does IntelliJ (currently using IntelliJ IDEA Ultimate 12.1.6) deploy files to a local Tomcat 7 instance (on Ubuntu 12)?

I have a WAR project that uses two JAR's. All projects have Maven pom files. My tomcat instance installed under /usr/share/tomcat7.

I've got a "working" Local Tomcat deployment configuration that uses a ':war exploded' artifact defined with an output path of '/home/user/dev/project/target/project' which exists, but it seems like I have to manually do 'maven install' and 'maven package' commands outside of IntelliJ to get the build files into the output path i.e., doing a build from IntelliJ does not populate the output directory.

However, subsequent changes in IntelliJ seem to get picked up and debug works for a while. Until it doesn't: the code in IntelliJ eventually gets wildly out of synch with what Tomcat is running and I have to "re-initialize" the output path with manual maven commands in a terminal window.

I might be grossly misinterpreting what is going on, so if there is some definitive description of how IntelliJ interacts with Tomcat, I would greatly appreciate someone pointing me to it.

Thanks,
Andy

5 comments
Comment actions Permalink

Hi.

Normally, deploy to Tomcat in IDEA is straightforward, it does not require any tricks. I see several possible points to clarify here, not sure what exactly is the key. As a guess:

> doing a build from IntelliJ does not populate the output directory
"Make" action build an artifact only if the artifact has "Build on make" flag. Select any artifact in Project Structure dialog to see the control.

Also it may be useful to know that artifact builder does not check the actual state of output directory. If somebody externally removes some files from artifact's output, next Build action does not necessarily re-creates them, if the project is not changed. *Rebuild* action should re-create everything from scratch.

Does it help?
Alexander.

0
Comment actions Permalink

Hi Alex,

Ah, ok. I didn't try doing the Rebuild - that would explain things indeed. I did have the 'Build on make' option checked on the artifact, but without the rebuild, it didn't seem to do anything.

A follow-on question. If my workspace has the WAR and the two dependent JAR projects loaded as modules - does a rebuild recompile those projects as well and deploy them into the WAR? Or does it simply rely on maven to pull the latest versions from the local maven repository?

Thanks,
Andy

0
Comment actions Permalink

Could you elaborate?

E.g. WAR and dependent JAR projects loaded as modules: does it mean <modules> element in pom.xml? My Maven requires to set POM packaging to a project that has such modules.

Can you show a sample configuration with all three modules?

Thank you,
Alexander.

0
Comment actions Permalink

No, I'm perhaps using the wrong terminology.

The three projects are related in Maven via dependencies.  War --> Jar1 --> Jar2.

I imported them individually into my IDEA workspace as modules (I think - I have .iml files in each directory).

I'm used to the maven plugin in Eclipse which is able to resolve maven dependencies in the workspace and keep them up to date there. I'm wondering if the same thing is true in IDEA.

Andy

0
Comment actions Permalink

Thank you.

I have played with similar configuration and it works for me. Let's check it step by step.
1. I've created the Maven projects with dependencies: WAR -> JAR1 -> JAR2. Used some code from jars in war's jsp page.
2. Imported the 3 projects into IDEA. IDEA modules created. Checked Project Structure dialog / Modules / WAR module / Dependencies: dependencies to both jar modules are added. Is that the same for you?
3. Web artifacts are created the same time automatically. Checked Project Structure dialog / Artifacts / this war exploded. Output of both jars are properly configured to go to WEB-INF/lib. Same for you?
4. Created Tomcat configuration, added that artifact. Run, seen the jars output on the page.
5. Modified java sources in jar modules. Done Update / Redeploy for the running Tomcat in Run tool window. Refreshed the web page, seen the effect.

Does something in similar scenario go wrong on your side?

Regards,
Alexander.

0

Please sign in to leave a comment.