I have the Maven Web App, where I have to many dependencies. I am trying to create the Remote Debug configuration in eclipse to debug jars when my home page open. As I am aware to to the debugging on java code, how can i do the same with maven dependencies.
Thanks,
You can debug libraries from maven the same way you debug your code. Nothing special need to be configured in debugger.
You just need to make sure for the libraries you're going to debug, sources are available in eclipse.
You can either download and specify them manually, or let maven download sources automatically for you.
Related
I'm currently working with a maven multi-module application in eclipse.
In some classes I can set breakpoints, and after starting tomcat (via eclipse) in debug mode, they get registered (meaning, a small tick icon is displayed next to the blue round breakpoint icon), and the debugger stops there.
In some other classes, the breakpoint is not registered, and the debugger doesn't stop there.
Why? And what's the mechanism underneath, like, are breakpoints only registered for classes that were already loaded? Or how does that work?
Update:
Using Eclipse 4.5.2 under Linux, Tomcat started under Oracle Java 1.6.0_45
It is hard to provide answer for such generic issue... however here are some hints. Let's assume the structure of your multi-module is following:
foo-project (parent, POM packaging)
foo-library (JAR packaging)
foo-webapp (WAR packaging, depends on foo-library)
Now from Eclipse's point of view, you have 3 "separate" projects. You are running your foo-webapp on Tomcat and that is what you are debugging. If you place breakpoint inside foo-library that is a different project, potentially unconnected to foo-webapp.
So what you need to do is to make sure your foo-webapp has project dependency on foo-library so that Eclipse knows when you run one project, the other is used as well. This is usually done manually automatically but by the m2e plugin. So I hope you are using that and not the obsolete maven-eclipse-plugin. Next thing you should make sure is that your dependency is correctly defined in the pom.xml... if the required version is not the same as the version of the library, m2e might link you JAR and not the project itself. And last not least you need to Enable Workspace Resolution for m2e to actually start connecting projects.
If you are sure all the things above are correct in your case, you might try to update the project according to the POM via Right click on project > Maven > Update Project....
When everything is in place you should see your project dependencies under Maven Dependencies in your Java Build Path tab.
I have a fairly complex Java EE project which can be built fine from Maven. After importing it to IDEA, I had set up a working deployment of the frontend WAR and the backend EAR to a local Weblogic 12c server. The project also have several 'common' artifacts packaged as jars and used by both the frontend and backend artifacts. For deployment, I used the exploded artifacts to save some time on packaging/unpacking, everything works fine till that point.
During development, I edit some Java sources and try to redeploy the updated artifacts to the running Weblogic. I press Shift+F10, choose Redeploy artifacts, I see IDEA building the project, the project redeploys on the server, and more often than not, I do not see any of the recent changes. Even if I choose Rebuild project explicitly and then try to redeploy artifacts after, no changes can be seen on the server. The only safe way to make my changes appear in the deployed artifacts is to invoke maven from the command line calling the package goal, and then redeploying from IDEA. (No JRebel is installed, is being used either in the IDE or on Weblogic, and I'd like to stay that way).
Is that expected behaviour from IDEA? Could this be something specific to our project or something global? Should IDEA be able to discover which projects needs rebuilt and repackaged and then redeploy the EAR/WAR artifacts properly to the server? Does it need any help from my side achieving that goal?
Whats your run/debug configurations? Check this, if not already sois not.
in the quick menu, edit configurations > Run/debug configurations window:
Server tab:
On 'update' action: restart server
Before launch: set 'run maven clean' and 'run maven install'
Deplowment tab
inserts your ear's here.
don't sure this specific answer your question but what I can suggest you is to try configure
weblogic maven plugin
then you can execute deployment from command line / or from IDEA with maven support.
http://docs.oracle.com/cd/E21764_01/web.1111/e13702/maven_deployer.htm
http://www.youtube.com/watch?v=hagaMr6UL6U
Evenif your final goal is to do the whole built process done by IntelliJ build and deployment options I will first try the following:
If your project was set up properly in maven you should be able to load you maven pom.xml within you IntelliJ. All the maven build commands and deployment setting you were doing through mvn command line will show up in your IntelliJ's maven panel in a nice three structure.
If this works out then clearly one of the libraries that are built through your IntelliJ build are not being deployed properly into the right location. You need to narrow down which one of the jars, the ear, or the war has to be affected by a single change you make and then check whether the date of the file is updated in the location it is to be deployed or not.
To wrap up, my humble sugestion though is to use either maven or gradle intelliJ panels for your J2EE projects. As you do achieve the defined goal of having your project built completely through the IntelliJ idea. Also whatever plugin you add to your maven shows up in you idea's maven/gradle panel. It is a fairly straight forward approach and you achieve a powerfull and flexible deployment and build tools within IntelliJ like your wanted.
So I tried to get the Maven Gwt archetype up and running. So some background info, I got Maven 3.0, and I have JDK 1.7 in Eclipse.
I ran the archetype, imported the project, and had a bunch of warnings and errors, I solved most of them but this one: GWT SDk servlet.jar was missing in WEB-INF/lib
So I searched stack overflow, and used someones suggestion of using quick-fix to synchronize them. Now I get a warning saying that I have not J2SE1.5 installed.
Do I need J2SE1.5 to run my web app? Why is JDk 1.7 not enough?
Next, I get the warning
Classpath entry com.google.gwt.eclipse.core.GWT_CONTAINER will not be exported or published. Runtime ClassNotFoundExceptions may result.
Which I also have no clue why it is saying that.
But I am able to run the clean install gwt:run Maven goals without any problems.
I could suppress the warnings but my ADD would kill me, I'd rather understand the issues if I am going to just ignore them.
If you have a GWT_CONTAINER entry in your build-path with a Maven project, then you're doing it wrong (gwt-maven-plugin archetype most probably does it wrong, but I don't have the patience to fix all its warts and nobody else seems to bother; maybe we should simply get rid of it).
You should first install the Google Plugin for Eclipse (GPE), which works hand-in-hand with M2Eclipse (M2E) to autoconfigure the project when it detects it's a GWT project (makes use of the gwt-maven-plugin IIRC).
Then make sure you don't have any .project, .classpath or .settings/ files/folders and import your Maven project in Eclipse. M2E and GPE should do everything for you. In the event that GPE doesn't add the GWT nature to your project, go check "Google Web Toolkit" in the project preferences, you'll see that GPE will have automatically selected the gwt-user from your POM as the GWT SDK.
See http://code.google.com/p/google-web-toolkit/wiki/WorkingWithMaven (which suggests avoiding the gwt-maven-plugin archetype).
All in all, it's easier to simply start from scratch: add a dependency on gwt-user and add the gwt-maven-plugin, then do everything else with GPE wizards in Eclipse.
You might also find https://github.com/tbroyer/gwt-maven-archetypes helpful.
I am considering using Maven 3 for my Spring projects which I have been developing using Eclipse and Tomcat. Until now;
I have been disabling "Republish automatically" because sometimes I don't need publish, I only save .java files (classes) and keep development on debug mode.
I republish (by clicking Eclipse's "publish" button on Servers view) only when I changed js, jsp or htm-like files, not class files, so I can keep developing without restarting Tomcat.
Now I am going to use Maven for debug/run on development but whenever I changed my code, I don't know how to do this "publish" issues on Maven as it doesn't use Eclipse's Tomcat directly. I stop maven and start again. Do I have to do this for all changes on my code? How can I make this maven -tomcat:run- "publish/republish" for js/jsp/html files and "do nothing" for .java files?
Unfortunately, yes, you'll have to run maven for every change.
Maven't isn't really intended to be used this way - it assumes that you're going to use maven when you're ready to build (ie after development), but use something like Eclipse if you're trying to see your changes in real time. It has no mechanism for listening for changes.
For my webapps I use both maven and Eclipse, with the m2e and the 'Maven Integration for Eclipse WTP' plugins. With that setup I can see my changes in real time using an embedded Tomcat instance in Eclipse, and when I'm done, I use maven to build.
Give those two plugins a shot - I think it'll meet your needs.
I had the same problem. And it happens because I ran maven eclipse:eclipse. Then, Server stop publishing (click on publish and said it was synchronized). I downloaded again .classpath and .project and other innerit files of eclipse project structure from cvs and server starts publishing again. May be this could help.
Regards,
For the benefit of Googlers:
I was getting NoClassDefFound errors using tomcat:run to start the app.
It took some googling but the following post notes that using tomcat:run-war enables your dependencies to get picked up from the WAR:
http://www.hascode.com/2010/06/java-server-facesjsf-2-tutorial-step-1-project-setup-maven-and-the-first-facelet/
However, for debugging and hot code replace, it's simplest to run Tomcat from the Servers view in Eclipse.
I've written a plugin for Maven2 in Eclipse.
How can I run the plugin in debug mode in Eclipse?
If possible, I'd like to avoid remote debugging an external process and I'd also like to avoid installing plugins into Eclipse.
Make sure that "workspace resolution" is enabled for the project you're running the plugin from, then right click on this project and select Debug As > Maven build...
It is possible to debug integration/functional tests. See the following resources:
http://maven.apache.org/plugin-developers/plugin-testing.html
http://docs.codehaus.org/display/MAVENUSER/Review+of+Plugin+Testing+Strategies
http://docs.codehaus.org/display/MAVEN/Maven+Plugin+Harness
Just in case (and for other readers), the wiki page Dealing with Eclipse-based IDE explains how to remote debug an external Maven process (not sure why you want to avoid this).