deploy maven war file to tomcat from IntelliJ - java

I have a maven war project. How can I do do the following from within IntelliJ IDEA:
create .war file
deploy it to a local Tomcat
start Tomcat in debug mode

You need to configure maven-war-plugin to build your war. tomcat<x>-maven-plugin will allow you to deploy it to a tomcat instance and may in fact do the war generation too - I use JBoss at my current office so haven't got any experience with the maven tomcat integration.
see http://tomcat.apache.org/maven-plugin-2.0-SNAPSHOT/ and http://maven.apache.org/plugins/maven-war-plugin/ for some more details on both of these plugins.

You can use the cargo plugin too. It works pretty well for me.

Related

Eclipse JavaEE (Maven)project WAS 7 migration to IntelliJ

I'm trying to migrate a maven project from Eclipse to IntelliJ and would like to start/run/deploy to WebSphere portal.
My problem is that Eclipse IDE allows multiple open projects and one of the projects is an EAR that deploys a war file to WebSphere portal.
Eclipse Project structure:
Websphere Artifact deployed:
So how can I achieve the same thing in IntelliJ IDE using the already installed WebSphere?
I already configured successfully Websphere Portal and I can start the server but I donĀ“t know what type of artifact I'm supposed to configure here because there's no EAR artifact because that was a project back in eclipse:
If I go to artifacts setting for WebSphere I can add the war file, but it is not deployed.
I have googled a lot about this in IntelliJ documentation, IBM documentation but there are no concrete solutions, at least that I have the knowledge to implement. I'm a bit new to IntelliJ. Can someone share a light on this please, thx.
If it is a Maven-based project - just open and import it from the main pom.xml in IntelliJ IDEA - IDE will automatically configure project structure.
If Maven project has corresponding configuration for ear artifact - IDE will automatically create the artifact of the same ear type which then you will deploy to an application server.
If you do not configure ear in Maven, you can create one manually, see examples in documentation.
The name of your artifact is important, even if deployed as an exploded-archive. The file (archive) or directory (exploded) must end with .ear, .war or .jar. The default name set by Intellij may not work.
myProject_ear/ is wrong
myProject.ear/ is correct
The deployment system of your application server is likely configured to only deploy files or directories ending with the correct file-type. This is especially true if the server is using the file scanner to detect modules to deploy or un-deploy.

Jboss Quickstart using Maven (jboss-as:deploy)

I am new to Maven, I am trying to go through the EAP(JBoss) clusterhasingleton quick start guide.
http://www.jboss.org//quickstarts/eap/cluster-ha-singleton/index.html
I can deploy the jar and everything works fine by running
mvn clean install jboss-as:deploy
I need someone to please explain what does "Deploy" mean in Maven/EAP as i have used JBoss 5 and deployment in that version meant copying the jar in deployments folder(i was using ant) where as i can't find the jar file in the deployments folder in EAP although everything is working.
I can see the jars in the local repository in .m2 folder and target folder in the workspace. How does Jboss know that is deployed? and does it look at the local repository and how?
Kind Regards,
Why does it matter?
In any case the maven repo is not relevant. In JBoss 5/6, placing applications in the "deploy" directory would indicate to JBoss that those applications should be deployed.
You can do the same thing in JBossAS 7.x (aka EAP 6) and WildFly 8.x using the "deployments" directory.
It's important to understand that deployments are not in-situ. The actual deployment is stored in a virtual file system. The deployment is written directly to this VFS when you use the maven tool.
The deployment process is much more than just copying WAR and EAR artifacts into the server. For instance, servlets, EJBS, JPA components, CDI components and other managed objects get wired up, validated and perhaps made available in JNDI.

Difference between compiling java app with maven and intellij idea

I develop a java web app in intellij which is then deployed to tomcat (tomcat integrated with intellij). It is a maven project.
So, usually I do this:
I run package goal in maven. Then I run tomcat in intellij.
Or I may not package it with maven and run tomcat in intellij right away.
So what is the difference then?
If I package it with maven and then run tomcat in intellij does the source code get compiled and packaged again and then deployed? Or just war produced by maven goal is deployed to tomcat?
Well if I don't package it and just run tomcat in intellij then it obviously gets compiled by intellij goal.
I am a bit confused here.
You don't need to run mvn package before running your webapp within Intellij.
What you can do is configure your Tomcat server to run your war exploded.
In the run/debug configuration, you can specify before launch operation.
By default,
a make is done
build artifact in exploded mode is done
If you prefer to work with a-non exploded war, last step would be build artifact instead of build exploded artifact.

How do you make this in IntelliJ

How would you make this in IntelliJ:
EJB project
WEB project
EAR project
then deploy the whole app to Glassfish with a single click on run? In eclipse I added the EAR project to glassfish with the plugin.
I have really no clue on where to start or how to connect the pieces in IntelliJ. Or, if you know about some Maven thing I could do to make the same thing
Project Structure (Ctrl+Alt+Shift+S) \ Artifacts. Set "Output directory" to deploy dir of JBoss.
See also
https://stackoverflow.com/questions/5757619/how-do-intellij-build-artifacts-and-run-configs-work-when-using-maven
How does Intellij deploy to JBoss?

How do I build .war file in Eclipse for Glassfish server

I have web application written in java using Eclipse. It has just one servlet that does some file manipulations. How do I build war file so I can easily deploy it to my remote server.
Right-click on the project, select 'Export...', then choose web -> WAR.
You should be able to use Maven to package a WAR to deploy to your remote server. It looks a little daunting, but once you create your own WAR file you should be ok, check out:
http://maven.apache.org/plugins/maven-war-plugin/usage.html
In fact you should be able to manage deployment using the Maven Glassfish plugin here:
https://maven-glassfish-plugin.dev.java.net/
That will allow you to start,stop,deploy,undeploy etc... your web app. Example here:
https://maven-glassfish-plugin.dev.java.net/examples/complete.html
Just for the record,
The default build artifact for a
NetBeans Web project is a war
The default build artifact for a simple
Java project is a jar

Categories

Resources