I'm transitioning from Eclipse to IntelliJ Idea and having some trouble getting my Maven Web project running as I'd like. In Eclipse, I ran it using mvn tomcat:run, which worked fine with JSP debugging. In IntelliJ, I created a run configuration to use this command, and it works, but JSP debugging doesn't work.
I tried to find info on getting JSP debugging to work on IntelliJ, and the only info I found involved setting up a Tomcat server in IntelliJ, not using Maven's tomcat with mvn tomcat:run. The problem is, I can't figure out how to do this without IntelliJ using it's own builder instead of building the project with Maven. I can add Maven goals like "mvn compile", but when I set it to deploy exploded war, and adds 'build myproject:war exploded artifact' to the build queue, which calls IntelliJ's builder.
IntelliJ's builder takes forever to build my project. I've never even let it finish. To be fair, the project is huge, but Maven builds to fairly quickly. Also, everyone in my company is using Maven to build it, so I need to use Maven as well.
Can anyone help me either get JSP debugging working using mvn tomcat:run, or on an Intellij managed Tomcat with the project built by Maven?
In IntelliJ you can easily debug a "remote" tomcat instance (one running in a different JVM than IntelliJ):
Run -> Edit Configuration -> "+" -> Tomcat Server -> Remote
That will create a new run configuration. Look at the information on the "Startup/Connection" tab for the parameters to add to the tomcat JVM. Mine are:
-Xdebug -Xrunjdwp:transport=dt_socket,address=57813,suspend=n,server=y
Finally, start tomcat by launching the required maven command. Then run the above run configuration (click debug button).
Related
I get a spring boot with maven project from github, which works well in my teammates computers. I am using Intellij idea and I am confused about how to run it in my computer. Should I initialize a project or can I just use the project directly by open folder?
In edit configuration part, I choose maven and the directory containing pom.xml. In that case it gives noGoalsSpecified error. So should I include a goal in command line part of edit configuration. In short, how to run the project?
I have little issue with my Intellij Idea. When I change chode, for example just add annotation, or edit some function, and run my project (or run debug) these changes are missing. I must stop project and run mvn clean package
When I run / debug project again, these changes are reflected. I guess problem is Idea running project from target folder, but it is only my cogitation. Do you have ideas whats is wrong? In project I am using Tomcat 8.5, spring 5, and hibernate 5 if depends on it. Thanks
Check Before launch options in your Run/Debug Configuration. Make sure you have Build step there - that is the instruction for IDE to build your project before launching the Tomcat server and deploy the application.
If you do not use IDE's make you can add mvn clean package Maven goal there.
I downloaded the glass-java-starter from github and followed all of the instructions on the glass developers site. I got it imported into Eclipse as a Maven existing project as instructed and I changed the oAuth file ID and Secret as specified. When I try to start the project or debug the project I am getting the following exception: Source not found for http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException. The instructions give a command line command for running the project, $ mvn jetty, but nothing for Eclipse. How do I debug this project with Eclipse?
You will need to use one of the maven plugins available for Eclipse to initiate the run:jetty goal.
There are a few available. One of them is Eclipse m2e.
Install the plugin
Create a new run configuration of type Maven Build
Specify a goal of jetty:run
Other solution would be:
set jetty debug port:
export MAVEN_OPTS='-Xdebug -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=y'
then run jetty through maven command line
mvn jetty:jetty
After that use Eclipse remote debugger on port 4000.
The war file, product that mvn produce in this sample app is compatible with tomcat or any other standalone server, so just build a war to "webapp" directory of standalone tomcat or jetty or "deploy" directory of standalone JBoss.
Eclipse has plenty of plugins to run those in debug mode.
At the moment I'm running the demo StockWatcher in Eclipse. This uses the embedded servlet container which is fine for my purposes. The only change I would like to make is running from the command line instead of inside Eclipse. Does anyone know what command I use and what classpath this requires?
Edit - I have not used maven I have created the project purely using eclipse and gwt plugin
If you used the webAppCreator wizard (I see that you used the Eclipse plugin, but maybe both of them used the same code internally), you should have an ant script (build.xml) generated for you. With it you can run the GWT app via targets so:
ant hosted - run hosted mode (or Development mode, I'm looking at a fairly old ant script)
ant gwtc - compile to JS
ant war, ant build, etc.
See what's in that file (build.xml) to get a better understanding of what is available and what you can do.
Update: see here for documentation on webAppCreator and available ant targets.
With the maven jetty plugin you can run your application with jetty from command line. (You first have to compile & create war with maven gwt plugin I think)
mvn jetty:run
maven gwt plugin
maven jetty plugin
Did you use Maven for this project? If that, then you can run it as mvn gwt:run from command line
I have Maven2 war project built, I'm using the cargo start plugin, and it works great for deploying the web app. To run the maven command, I use a .bat file in my workspace, and I have en external run config to run the the bat file. I can't seem to stop the server from the Eclipse console, or re-deploy.
Does anyone have any advice on how quickly start/stop/re-deploy to Tomcat locally while developing.
Did you try JavaEE tools and m2eclipse? As far as I can see it should work well in most common situations. What m2eclipse does for you is to exactly map the maven configuration to an eclipse projects with the necessary facets set. Also, if the Dynamic Web Application facet is set for your project, you will be able to deploy it to a Tomcat server that you set up in the Server view of JavaEE tools. This configuration allows hot redeploy.
More information on JavaEE tools:
http://eclipse.org/home/categories/index.php?category=enterprise
There is a full Eclipse distribution with the EE tools available on their download site:
http://www.eclipse.org/downloads/
m2eclipse is freely available from Sonatype:
http://m2eclipse.sonatype.org/
At work we use the mentioned software as well. Additionally we use the JBoss tools that provide a feature called Project Archives that let you individually build your web application archive (ear/war/...).
To get startet you should perhaps start a fresh workspace and import the existing maven project (via the import existing maven project wizard). If everything went fine you can set up your tomcat in the server view. Maybe switch to the Java EE perspective. Right click on the newly added server and select Add to add the dynamic web project you just imported. If it doesn't show up in the list try to update the project configuration via the project's maven context menu.
Well, you could use cargo:redeploy to Undeploy and deploy again a deployable (that's a shortcut to cargo:deployer-redeploy). But I personally don't use Cargo this way, I use it mostly for integration testing (i.e. during the build) and use Eclipse WTP during development (this works whether you're using the maven eclipse plugin or m2eclipse).