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.
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 do have own developed Java library (MyLib), which I later publish on private Maven repository and have it as Maven dependency in another webapp project (MyWebapp). If I have both projects - MyLib and MyWebapp at the same time opened in Eclipse - is there a way somehow to configure MyWebapp so, that local changes made to MyLib would be directly added to MyWebapp while building/deploying it? The issue is that during development it is not really comfortable always to make some changes in MyLib, make a build, deploy to Maven repository and then make a MyWebapp build, deploy it and only then I can see how the changes are affecting the webapp project...
I would like to reduce the overhead while developing and willing to see how changes are working out. Of course when it comes to real releases the above described flow does really make sense and works great.
Thanks!
There is no simple "just tick this option" solution, unfortunately. You can chose between these options:
Convert MyLib into a Maven module and add it to the sources of MyWebapp. This, of course, will make it harder later to reuse the library alone.
Stop deploying the application. If you look at the classpath in Eclipse, m2e should have added the dependency as a project from the workspace (instead of depending on the JAR in the repository). If not: There is an option for this.
The next step is to create another project which depends on Jetty and MyWebapp. Create a Java application in there (i.e. a file with main()) which creates a Jetty server and configure it to use the current classpath. That way, you can start the webapp just like any other Java application without deploying - Jetty will simply load classes from the classpath that m2e assembled.
we recently migrated to Maven Build manager & git hub repository for our Java web-app. Also i switched to eclipse as eclipse has good set of plugins.
As a new bie, i am simply running mvn clean package from terminal at the code root directory. And then moving the compiled code i.e., /target/SNAPSHOT/* to tomcat/webapps/ROOT location.
And then starting Tomcat7 server. The process is time taking especially when i do code changes in Java & configuration .xml files.
I want to do it completely in IDE environment as i did earlier in Netbeans, update code -> build and run in debug mode, -> do code changes and then commit.
Heard of egit & m2e in eclipse for maven & github integration, but not sure how to use it.
Please walk me through the steps required in doing so. I am completely new to eclipse.
--
Thanks
You might want to consider using maven-jetty-plugin http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin for running the webapp. You will not need to copy over stuff to tomcat. After configuring this plugin, you can simply run your application by doing mvn jetty:run
I generally do not like running webapps inside Eclipse. It's a personal prefrence, but it is always nice to have an IDE neutral way of building and running your applications. If you have m2e things should work simply fine. I have seen maven-jetty-plugin having hot pluggability where if you changed your web.xml, jetty would reload your application.
We use Git for version control and Maven for dependency management and build automation. Once your project has successfully imported into Eclipse and recognized as a valid java web project, you don't need either Git or Maven in order to build/run it inside IDE. Just creat a server using you existing tomcat installation, add the project to server, then select Run as > Run on Server.
The Complete Guide:
Creating a server
Adding projects to a server
Starting a server
For more details, check out Testing and publishing on your server.
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 have a mutil-module Maven project wherein the pom's have the following packaging types
pom
|--jar
|--jar
|--war
The war project depends on jar projects. I imagine this is a pretty typical setup for a webapp built with Maven. I can deploy and debug the project by
running mvn install
copying the war to Tomcat
starting Tomcat in debug mode
from the IDE, connecting the remote debugger to Tomcat
Obviously, performing these steps after every change, quickly becomes a pain. Is there a simpler way to build and deploy the project to Tomcat, such that it can be debugged from the IDE? Instructions for either Eclipse or IntelliJ (ideally both), would be welcome.
In case it makes any difference, I normally create the Eclipse project files using the m2eclipse plugin. In intelliJ I use the import maven project feature.
Thanks.
If you install the m2eclipse-extras (wtp support) you will be able to configure tomcat server within eclipse and deploy the applications from within eclipse. This will also watch the project for changes and automatically redeploy. This might not work well if it is a large application.
The other approach is to use the maven jetty plugin or the maven tomcat plugin that runs it as a web-app without requiring to build a war.
You can also look at jrebel (a commercial tool) that can load the changes to class files / cofiguration without requiring a redeployment.
How about tomcat:run-war-only?
m2e is between maven and eclipse (Tomcat is not involved here). Choose "Build Automatically" (make sure there is nothing under "Problems" tab. If it is,just delete the errors entry from "Problems" tab). This will compiler and convert everything to .class files.
wtp is between eclipse and tomcat (servers in general) for deployment.
m2e-wtp is like a bridge used for deployment of maven projects in tomcat