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.
Related
I'm using the Spring STS in Eclipse to create a simple web-based spring boot project. I can run it fine in Eclipse, but when I try to export it as a JAR file I get:
rg.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
My public static void mainis located in Application.java, with the #SpringBootApplication annotation.
I've double checked all the Maven dependencies a hundred times.
What am I doing wrong?
Most likely, you're using the built-in Eclipse exporter to generate your jar, which only includes the target files actually produced in that project. In order to have a "fat" (standalone executable) jar, you need to use the Spring Boot Maven or Gradle plugin to "repackage" the jar.
First, make sure that you have the repackage goal included in your build setup, then use the Maven package target. The simplest way to do this is to run mvn package from the command line (you may need to install the Maven CLI package for your OS); you can also right-click the POM in Eclipse and "Run As" to execute specific Maven operations from within Eclipse.
It is a single line command, on window 7/10 machine, with command prompt to your project folder (Inside your project workspace). I do not do with Eclipse IDE POM maven goals, but you can do with maven goal there also. ON window machine I prefer cmd.exe for exporting and running.
mvnw clean package
on unix kernel based
./mvnw clean package
You have to go inside workspace and than to the project root folder. You will see a maven wrapper mvnw, with that you don't need to have maven installed and .mvn folder at the same level provides necessary jar for that.
For a project
D:\workspace\Zuteller Workspace\zusteller>mvnw clean package
it will create zusteller-0.0.1-SNAPSHOT.jar in the target folder at the same level.
D:\workspace\Zuteller Workspace\zusteller>java -jar target\zusteller-0.0.1-SNAPSHOT.jar
You can run self-contained application(embedded Tomcat) and access at localhost:8080/your project
I am running my project on weblogic , the source code of the project is at 'C:/Source Code' and when I run mvn clean install the .ear file is getting created in C:/Ear/abc.ear, and I have imported the project in eclipe from C:/Source, the abc.ear is autodeployed in C:/oracle/Middleware.../Autodeploy
Now whenever i make changes in any java class i have to manually replace the class file which is build in eclipse to C:/oracle/Middleware.../Autodeploy.
Is there any way to automate this so that the changed class file would be automatically available to the C:/oracle/Middleware.../Autodeploy/abc.ear
For Eclipse development with WebLogic, install the Oracle Enterprise Pack for Eclipse to better integrate with WebLogic. You will no longer need to use the autodeploy and your application will update automatically.
http://www.oracle.com/technetwork/developer-tools/eclipse/downloads/index.html
I am trying to fiddle with the gradle-tomcat-plugin and I am having some issues with some of the preliminaries. Assuming that my WAR is present in one of my folders, what do I need to do in order to run the war in an embedded tomcat using gradles tomcat plugin? The readme mentions the tomcatRunWar but I am a little lost as to how to use it in my gradle file
Any help would be appreciated.
Thanks
if you have set up everything right
go to your root directory (your build.gradle file should lie there), then execute
gradle tasks
and you should see tomcats different tasks
tomcatRun: Starts a Tomcat instance and deploys the exploded web
application to it.
tomcatRunWar: Starts a Tomcat instance and deploys
the WAR to it.
tomcatStop: Stops the Tomcat instance.
tomcatJasper:
Runs the JSP compiler (Jasper) and turns JSP pages into Java source
using.
and then you just run it
gradle tomcatRunWar
myself I prefer jetty plugin
(Am a maven noob)
Have a maven built webapp which uses spring, etc.
When I run "mvn clean install", it generates a .war file in the target directory.
I copy the .WAR file to tomcat for deploying the app.
Debug the app
Edit the code
This process takes a lot of time. When I earlier used ant, I would point tomcat's server.xml to my webapps directory. Also, Eclipse would put all of its classfiles in my webapp\WEB-INF\classes folder. If I had to modify any JSPs, I would just edit and there was no need of additional copying. If I modified a .java file, Eclipse would build it and put the .class file in the WEB-INF\classes folder so that Tomcat would pick it up.
Now, each time I make changes to a .jsp, I need to manually copy the .jsp to tomcat's webapps directory. Isn't there a way that a maven built app can optimize this process ?
So, where do you point your tomcat at that makes development productive?
project (where pom.xml resides)
src
main
java
resources
webapp
WEB-INF
target
webapp
webapp.war
Basically, I would like to know how to configure eclipse(3.7.1) and tomcat/maven so that the edit/deploy/debug cycle is really fast.
UPDATE1
1) I was able to get m2e(http://download.eclipse.org/technology/m2e/releases/) installed in indigo(v. 3.7.1 of eclipse). it had 2 components
a) maven integration for eclipse
b) slf4j logging
It installed successfully asking me to restart eclipse. I restarted.
2) Next, I installed m2e-wtp (at http://download.jboss.org/jbosstools/updates/m2eclipse-wtp/)
It had 3 components
a) maven integration for eclipse
b) maven integration for eclipse Extras
c) maven integration for WTP.
When I selected all 3, I got some error. So, I unselected the 1st two and only selected the 3rd one and then it installed successfully asking me to restart eclipse. I restarted.
#Raghuram
I ran the 4 steps that you suggested below. Only the 4th step resulted in an error and my webapp could not get deployed. It resulted in an error "File not found --- .svn/.wcprops/.
http://i.imgur.com/Pg1aq.png
What should I make of it ?
Thanks again,
I'd recommend you to use cargo to deploy automatically to a local container (that can be downloaded and started)
Maven+Cargo
Then having that started with jpa activated (so that you can remotly debug your code) you just have to attach a listener and debug from eclipse, intellij, whatever.
For JSP, talking Intellij, you must tell your IDE where to package files (right-click 'package file") which is done in the project setup (output classes dir in WEB-INF/classes)
Check Tomcat 7 - Maven Plugin? for an example cargo configuration for Tomcat 7. After the confiuration is valid you can deploy to your Container using mvn cargo:deploy and mvn cargo:redeploy
If you use Eclipse Indigo with m2e and m2e-wtp, you can pretty much develop and debug your web application without any manual step.
Add tomcat as a server in Eclipse
Import your maven project as a maven project in Eclipse.
Build the project (using Eclipse or using maven)
Choose "Run as server...".
Eclipse will pretty much take care of hot deploying jsps as well as classes on changes.
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?