Eclipse Mars - Web Application - Tomcat - Maven - Deploy and Debug - eclipse

Is there a foolproof simple method to run and debug a Simple (tutorial level) Maven Web App in a local apache tomacat server from Eclipse Mars?.
I am developing a web app and I am able to run it sometimes, and sometimes not, and I am able to debug it sometimes, and sometimes not. Its a bit frustrating.
My current preference is to run the project from a Maven configuration having as goal tomcat:run. It builds and runs always, but it wont debug, i.e. if I place a breakpoint within my Java code in the servlet code, it is not reached. (some times it is reached the first time I run the project, but then it fails to find the source code of some file, and stops breaking for the subsequent runs...)
I have tried also "Debug on Server" configuration, but then, in that case I had to run a Maven install before running the project or, otherwise, some classes would not be found. And that also stopped working now. It just cant find some of the classes from src, although the Web Deployment Assembly configuration has the source being deployed into WEB-INF/classes.

(you may have been downvoted because there are a few questions lumped in to one. I'll try to answer them all because I'm all too familiar with your pain)
Eclipse's maven integration is notoriously flaky when it comes to debugging webapps, even with MARS. You can indeed use tomcat6:run or tomcat7:run for webapps. Here's a few 'best practices' that keep me sane:
Always execute 'clean' as part of the goal.
Make sure you follow the standard maven WAR project layout. You can break from this but have to be careful to specify all the overridden paths for META-INF etc.
When you stop/kill the process in Eclipse, you will often find that the process actually continues running but has detached itself from eclipse.exe as a parent process. You need to manually kill the java.exe process or you'll find 'port already in use' errors. ProcessExplorer is very useful for keeping an eye on this.
When you hit a breakpoint and it says 'source not found', there are a few things you can try.
Add your maven installation under window-preferences - maven/installations. Set this as the default one.
In your run configuration, make sure that you are using your system installation instead of the embedded one.
When you hit a breakpoint, close the editor and then reopen it by clicking on the point in the debug tree.

So you are trying to debug a maven project with goal "tomcat:run" in Eclipse and the application is breaking at the breakpoints set but you are getting "Source not found" error.
Follow the below steps to fix this:
Go to your debug configuration
In the Main tab, make sure you have "Resolve Workspace artifacts" checked
Make sure the Base Directory is set as your maven project
In the Source tab, make sure you have added your project as a "Java Project" or "Workspace" or "Project"
Step 4 is important, Add -> Java Project/Project and select your project

Related

Eclipse + GWT 2.8.1. : Changes to *.ui.xml files don't show up although super dev mode is active

When I change a ui.xml file (e.g. change css styles), these changes don't show up in the application.
The only way to get the changes visible is in Eclipse to choose
Project-> Clean ... and to remove and recompile the whole project.
My settings:
-noserver -remoteUI "${gwt_remote_ui_server_port}:${unique_id}" -logLevel INFO -war "${workspace_loc:NewComApp/war}" -codeServerPort 9998 com.myapp.MyApp
My tomcat (alhtough I understand that this does not influence the superdevmode):
Anyone experiencing the same problem.
This makes iterations during development very slow, because compiling the whole project because of some minor changes to the layout seems ridiculous.
The ui.xml files are located in the same package as the java source files:
Any advice on this?
After a lot of research and a little help from a friend I want to describe the solution.
First of all you need to understand that SuperDevMode (like DevMode) translates what it finds on the classpath of the JVM where the SuperDevMode runs.
So for the solution in Eclipse it is necessary to point the classpath to the source directory.
For this you need to open the config dialog of your SuperDevMode:
Means make super sure that your source comes first!!
Means that you must make sure all your project and libs are available
For 2. You need to open "Java Build Path" select "Order and Export" your Project Properties in Eclipse.
After that you you just hit F5 in eclipse to see any changes (ui.xml or java code) instantly compiled by SuperDevMode compiler instead of Eclipse Project Build compiler
Along with a tomcat installation this lots of time.

Netbeans runs out of memory after opening many projects

I created a projects group for maven projects. Maven being able to build subprojects, there actually are dozens and dozens of sub-subprojects.
Now I have 405 projects open on Netbeans and I cannot use it anymore because when I start it, the system runs indefinitely trying to perform "opening projects" and eventually running out of memory when it goes in the build phase.
I'd like to start Netbeans again without all those 400+ projects. How to do so?
In case it's needed, I use Netbeans 7.4 on MS-Windows 7.
Edit: a now-deleted answer suggested me to close individually each project. This is not possible as the "close project" action is queued for after the build.
I tried to delete the netbeans folders one by one and succeeded quite early. What I did was delete the whole %APPDATA%\Roaming\NetBeans\7.4\config\Preferences folder, though the precise information of the opened project at startup seems to lie in %APPDATA%\Roaming\NetBeans\7.4\config\Preferences\org\netbeans\modules\projectui.properties.

Ant build won't run in Eclipse

I have an Ant build.xml which no longer runs when launched in Eclipse.
I click on the External Tools Configuration, select the Ant Build I've been running, and click Run.
Nothing happens -- no console window and the build doesn't appear to launch (the classes are not compile nor is the WAR file created).
I recently added a plugin (Spring IDE), this is the only thing I can think of that has changed recently as far as my Eclipse configuration.
I can run the Ant build fine from the command line.
Can anyone suggest where I might look to track down my error?
I'm using the Eclipse Helios release, Build id: 20100617-1415 on Windows XP.
As per pstanton's comment this symptom will occur if your ANT_HOME folder is not correctly defined in Eclipse. Eclipse seems to ignore the ANT_HOME system property.
window->preferences->ant->runtime->Classpath Tab
I faced same problem today , reason behind this was ANT_HOME path variable explained in other answers also.
Initially I added ANT_HOME at 2 places given below and it was not working.
window->preferences->ant->runtime->properties Tab
window->preferences->ant->runtime->Classpath Tab
But when I remove Classpath tab ant home entry ( by setting it to default using Restore default option on right bottom of preferences window ) it worked :). So far it is just a surprise for me because I added same ant home path at both the places.
You can check out the example in this Apache Ant tutorial.
But you can also try to run your same build.xml ant files through a Java Launcher, with org.apache.tools.ant.Main as the Main class.
That would at least prove your scripts are working in an Eclipse environment.
When you look at the Ant FAQ, you also see:
I installed Ant 1.6.x and now get java.lang.InstantiationException: org.apache.tools.ant.Main
The cause of this is that there is an old version of ant somewhere in the class path or configuration.
Maybe your error message is somehow hidden, but it can be worth checking your classpath and see if no other ant library is there.

eclipse debugger: attaching source-code of maven dependencies?

I'd like to use the source code of maven-managed dependencies when debugging our webapp in myEclipse 8.
I have managed to attach the sources to the libraries in the "Maven Managed Dependencies" classpath container, i.e. when I open a class file from a dependency (e.g. using Ctrl-Shift-T), I see the source code.
However, when I define a server connector for my tomcat, deploy the wepapp to it, and launch it in debug mode and execution halts on a breakpoint in that same class, the editor pane only displays the text "source not found", and a button to edit the "source lookup path". I have attempted to manually add the "Maven Managed Dependencies" classpath container, only to be told "Use maven project settings to configure depedency resolution". However, I see no useful setting in that property pane ...
How can I attach those sources? I am aware that this works with the m2e plugin and wtp, but I'd rather avoid convincing the rest of my team to switch plugins ...
Looks like issue MNGECLIPSE-983
I have confirmed that if I manually pick the External Archive option and find the relevant -sources jar (navigating that big .m2/repository tree to find it) and then add the jar as a sources it does work, and surprisingly it does remember the next time which isn't too bad.
That's at least doable I think for me because we don't often need to step debug through external dependencies, but when we do, it's often frequent, so adding it once while a bit of a pain, can be done on a case by case basis.
I have since discovered that this problem only occurs if the server is launched using a launch configuration.
The problem does not occur if the server is started by:
click the server icon in the toolbar -> context menu appears
mouse over the intended server -> submenu appears
click on "Start"
While this precludes sharing the server configuration by checking the launch configuration into version control, it at least allows seamless debugging.
Please do the following steps in Eclipse IDE(Tested with Version: 3.5.2),
In Package Explorer, Right Click on the Project which integrated with Maven container.
Select Maven 2 and then select "Fetch Source JARs".
The above action wil fetch sources of all the 3rd party jars present in the Maven Classpath.
Regards,
Rajesh.
Just put the .m2/repository/ folder itself with the search subfolders option.

Ant build consoles get clobbered by dependent projects in Eclipse

I have a set of dependent projects in Eclipse, each with its own Ant build script. If I make a change in multiple projects, then select "Build All" (Ctrl+B), each Ant build is invoked in the correct order. But if there is an error in one project, Eclipse still tries to build the other projects also, and in the process clobbers the Ant console so that the build errors are no longer visible. This wouldn't be quite so annoying if I could open up the offending project and select "Build Project", but Eclipse out-smarts me: it won't rebuild until I open some file in the project, edit it, and save (typically I add and remove a space character wherever my cursor happens to be). An answer to any of the following questions would be welcome.
How can I configure Eclipse to (in preference order):
terminate a "Build All" as soon as any project's Ant build fails?
save all console output for "Build All" instead of resetting the console for each project?
spawn a separate console for each new instance of Ant?
allow me to force a "Build Project" even if it doesn't think anything has changed?
[UPDATE] Bonus Question:
How can I configure Eclipse so that fixing any build errors in a depended-on project counts as a "change" for the purposes of "Build Project"?
Have you tried redirecting standard out to file via a run configuration? A few screen shots to help if not... (you may try 'append' this is not in my screen shot :) )
One alternative is to have each Ant build log itself, e.g., using the following in build.xml
<record name="build.log"
loglevel="verbose"
append="false" />
Oddly, Eclipse seems to disable this logging somehow when running an Ant build.
I am not too big on ant, but can't you make the builds dependent on one another?