How to configure IntelliJ 11 + remote tomcat 6 + maven imported modules? - debugging

Here is what I have now:
Imported multiple maven modules into IntelliJ project
Maven targets run OK from the Maven Projects flyout - a war file is created.
Making the project from the "Build|Make Project" is OK too. But here no war is created, just the .class files.
Tomcat 6 running on another machine
Manually deploying the war produced by the package maven goal to the remote tomcat works OK.
A local tomcat 6 instance is configured as an application server. I am not going to use this instance, but the JetBrains documentation says I must have a local instance in order to have an application server configured with the IDE.
No artifacts and no facets are configured for the IntelliJ project.
The remote tomcat is run with JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=1317,suspend=n,server=y
I want to be able to debug my server in the IntelliJ. Which means, that I must have a Run configuration, which does the following:
Produces the respective war file. Making the project does not produce any war, so it should be either modified to produce one or the war should be created as part of a Run configuration. I have no idea which one is the right way.
Deploys or redeploys it to the remote tomcat instance.
Lets me remotely debug the code.
How do I do it?
EDIT
Correction. One of the projects has the Web facet automatically added to it, because IntelliJ has noticed the ...\src\main\webapp\WEB-INF\web.xml file.
EDIT2
Here is my remote tomcat run configuration dialog:
The documentation says I should have the Perform on 'Update' action option in the dialog. Where is it?
EDIT3
I have added Spring support and Spring web services plugins to IntelliJ, since we are using them. Now IntelliJ recognized it and added the Spring facet:
However, there is still no Perform on 'Update' action option in the remote Tomcat Run Configuration dialog.
What am I missing?
EDIT4
The mystery of a missing Perform on 'Update' action option is resolved - How to enable the Perform on 'Update' action option in the remote Tomcat run configuration in IntelliJ?

1) Producing a WAR
To have IntelliJ IDEA produce the war file, you need to have a 'web' facet defined for the module.
Go to File > Project Structure > Modules
Select your module
Add (via the '+' icon or Alt+Insert) a web facet.
Configure the facet. (If you are following standards, the defaults should be OK, but check them.)
Once you have a web facet defined, you can then define a WAR artifact.
Go to the "Artifacts" page in the Project Structure dialog.
You will first need to create an exploded war artifact.
Click the add button
Select "Web Application: Exploded" and then "From Modules"
In the popup, select your module. Verify that the web application artifact is correctly defined. Again, if you are following standards, the defaults should be good.
Once the exploded artifact is defined, click the add artifact button again and select "Web Application: Archie", and then "For {module-name}:war exploded" (or what ever you named your exploded artifact if you did not use the default name).
Verify the configuration.
IDEA will now create a war file when you build.
2) Deploy to Remote Server
You can do this as part of your run/debug configuration. See next section.
3) Remotely Debug
You simply need to create a run/debug configuration to do this.
Go to Run > Edit Configurations from the menu
Click the Add Icon (or type Alt + Insert) and select Tomcat Server > Remote from the pop-up list
Configure the run/debug settings. I recommend clicking the Help button. It will show you what the various options are. (Be sure to pay attention which are available for Local, Remote, or Both.) Take a look at the "Remote Staging" information on the Help page. Also, be sure to select the deployment tab and select the artifact you want to deploy (and specify the context path.) The Startup/Connection tab, "Debug" section will have needed debug connection information that needs to be configured on the remote Tomcat server.
By default, "Make" should be listed in the "Before Launch" section. And once you add the artifact to be deployed, the before launch should also show that the artifact will be built. If not, add it.
Once defined, you can execute this run/debug configuration. To debug, launch using the "debug" button or shortcut (Shift+F9). This will make your project, create the war, deploy it, and then connect the debugger. If you just want to run without debugging, click the Run button, or use the shortcut Shift+F10.

Related

unable to create maven project in eclipse photon

I have been trying to create a maven project in eclipse photon.I also tried checking proxy settings,linked a "settings.xml" file in user settings,linked a "catalog.xml" under archetype.But it didn't worked.Eclipse is configured with java 8 version.I am unable to upload photos so i will describe.
These are the steps I followed while creating Maven project.
File->New->other->Maven->Maven Project->Next->Next->Selected Archetype-quickstart1.1->Next->provided Artifact and Group Id and Finish.
Here I'm getting could not resolve archetype error.
It's not very clear the issue you are facing and how you are creating the maven project. Eclipse comes with a great in built maven support. It's not necessary to configure settings.xml unless you are using your own repository instead of the default repository .m2
However assuming that you have installed Eclipse Photon correctly. Here are the steps involved in creation of simple maven project.
Click on File-->New-->Others.
On the new window look for maven and click on Maven Project.
This will launch new window **New Maven Project*. If you don't want to select available archetypes, then click on the checkbox named "Create Simple Project(Skip Archetype Selection)" and click on next.
Fill in your project details and click on finish. That's it.
Eclipse will generate a fresh maven project for you.
The other configurations are required based on the type of project you are creating.
Hope this helps !!!

How do you prevent Liberty from expanding a published WAR file

We are using some library that doesn't work for some reason if the WAR is expanded under the apps folder. When the eclipse tooling publishes the WAR to a remote server, the WAR is expanded. How do I prevent the server from unzipping the published WAR?
If an app doesn't work when expanded, but the exact same app works as a binary, then that indicates something wrong in the server. I'm not aware of specific cases where we wouldn't support an expanded EAR instead of an EAR binary.
It sounds like you're this far already, but the first thing to check is if you're using resources inside of the workspace or inside of the server. You can check this by looking at the server on disk and seeing if the apps directory has either something like TestWar.war.xml or TestWar.war (directory).
To move the resources to the server, if you are using something like WDT (the Eclipse tooling you get from dragging the icon on wasdev.net into your Eclipse workspace) you can modify the Liberty server settings to do this.
In the Servers tab, double-click the WebSphere Application Server Liberty entry and you should see the Overview configuration screen. Uncheck Run applications directly from the workspace and now if you look at the server on disk you will see the files directly inside of the server.
But, to answer your question, it's not so much that we're unzipping the published WAR so much as we're not zipping it to begin with. If you right-click the EAR project and go to Export that's a one-off way to make an EAR binary, but otherwise you may want to look at a simple build description system through Ant or Gradle or Maven along with similar standards to build the archives.

Spring STS howto add tomcat7 sources

It seems that the configuration wizard for the configuration of servers has no option of attaching sources (namely tomcat7). How can I configure the entire source code for all the used tomcat7 libs ?
Once you have launched Tomcat, there is a launch configuration generated for you. You can access this launch configuration from the "Run..." menu. Once you selected the launch configuration, there is a "Source" tab on the right where you can configure the lookup path for sources. Add the source zips of the libraries to that list and the debugger should find that.

How to copy files with IntelliJ

I'm using IntelliJ 14.1.1 on Windows.
I have a project (mainly java) with a little web module, built with maven.
In my web module, I'd like to accomplish this scenario :
I edit a Javascript file located in the web module, folder resources/js
When IntelliJ automatically saves the file, I'd like it to be copied automatically to target/classes so that my web server detects the change and reload it automatically.
My goal is to have immedlate feedback : I edit a JS file, and then I have it available in my browser.
The only way I found is to go to "Maven Project", and assign a shortcut to the maven goal which compiles the module. But this takes too long, and it's far from the "Ctrl+S" of Eclipse (Eclipse auto build let me have this behavior).
I also tried to use the File Watcher option of IntelliJ, but it seems it can only parse less/css and I cannot make a simple copy of file/folder with it.
Any help would be welcome to achieve such an immediate feedback on typing in IntelliJ.
Thank you

Deploy a Maven application in IntelliJ 12 without building with Maven

I have problem with configuration of maven project in IntelliJ. I deploy my application to JBoss, when I start JBoss server via IntelliJ, application is deployed without any additional actions, but when I try to redeploy application after some changes, IntelliJ try to make project with it's own make process, and it fails. I have to make project via maven and restart server to redeploy application. Can I somehow tell intelliJ to use maven while redeploy application? I cannot see such option in Run/Debug configuration window.
I think you are using exploded artefacts (present icon) Server, Deployment Section. Right?
There you can choose the external artefact and disable the make flag.
I always using exploded artefacts, because of the hot code deployment. So I do no need to deploy artefacts again and again.
Please be aware if there is already an artefact (e.g. foobar.war) in the same location (maven target directory), you have to change the name of the exploded artefact (e.g. foobarE.war). Idea is creating a folder named foobarE.war.

Resources