tomcat eclipse and WTP with maven - eclipse

I have a maven multi-moudule project. I tried to use WTP with Eclipse 3.6 and i can't figure out how to configure my project so everything will work right with tomcat. Sometimes not all the classes are being published or/and the provided scope jar are deployed to lib dir (even though they are not supposed to). I know there are alot of sites which explain how to do it. But still i find it hard to deploy my multi module project on tomcat 6 server bundled in eclipse. Anyone has easy way? Thanks,
EDIT: I downloaded Eclipse 64bit and Maven Integration for Eclipse\WTP and then this seems ok. But still i can't understand why it doesn't work on 32bit.

look in the plugin marketplace for a free plugin called m2e-wtp. That will take care of the provided scope issues. As for classes not being deployed, the usual places I look at are the deployment assembly and/or Java Build Path. Make sure that the entries (and the dependent modules) are all there and located in the right place.

Related

Eclipse stopped deploying any of the project's [maven] dependencies to tomcat

I'm having this problem for a while now. I tried so many things that failed that I had to switch to netbeans in order to be able to develop. But netbeans lacks some important features, so I really need this to work in eclipse.
From scratch:
I have a "parent" maven project with several modules in our svn repo. 2 of the modules are web projects that I need to deploy in a tomcat server. These web projects have several dependencies, among them are the other modules of the parent maven project.
I had this configuration running with eclipse ganymede, but 3 weeks ago I started to get ClassNotFoundExceptions while starting the server, I have no clue why this started happening.
Since then I've tried to get new Eclipse (Java EE) packages, but no matter how I do it, this is what happens:
I get eclipse with maven+svn running and add my tomcat installation to eclipse's server list.
I check out the parent project, this includes the modules. Eclipse gives me a whole list of projects.
The crap starts: I cannot add the 2 web projects to the tomcat, it tells me no projects can be added (meaning "you dont have any web projects!"). Also, I cannot choose "Run as -> Run on Server" on Servlet classes ("Selection did not contain any resources that can run on a server"), even though they clearly extend HttpServlet. Since I spent way too many hours into this, I found out how to deal with this: Convert the project into a "Faceted Project" in the project's properties.
Now I can add both projects to the tomcat server
When starting the server, i get
FATAL: Error loading WebappClassLoader
context: /BEWeb
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader#55ae3b4d
de.comp.utils.servlet.SInvokerServlet
This class is in one of the modules that are listed as a dependency
WEB-INF/lib of the deployed project ist empty. No libs at all, maven and/or eclipse doesn't do what it did 3 weeks ago.
I tried messing around with the eclipse files in .settings and also with .project and .classpath, but nothing useful turned out.
Can someone point me in the right direction? I'll do everything from scratch if you need me to, it would not make a difference as I did this a lot of times already (with different versions of eclipse, maven, tomcat, ...)
If you need me to post any files, I'll be happy to comply.
Since this kept me awake at nights for quite some time now, I'll put a bounty on this one.
thx so far.
================================
EDIT in order to answer the upcoming questions
Just to check: building your projects from the command line and deploying them by hand does work, right?
Yes, mvn package works fine, copying that .war file to tomcat results in a working application, also the war file contains all dependencies.
When you say "get new Eclipse (Java EE) packages", do you mean you are now using Eclipse Indigo (3.7)?
Yes. But I had the same problems with 3.5, the eclipse versions didn't show any difference in their behavior.
When you say "I get eclipse with maven+svn running", are you using m2eclipse or have you generated eclipse configuration using maven eclipse plugin?
I have m2e installed and checked out the projects from svn using "Right click -> Checkout as Maven Project". There are no eclipse-specific files in the repository though, it seems they are being generated upon checkout.
When I use mvn eclipse:eclipse, then close+reopen the projects, I cannot add them to the tomcat server ("There are no resources that can be added or removed from the server"), meaning that eclipse does not recognize them as web projects.
First of all: do not use the maven-eclipse-plugin together with m2e/m2eclipse, the two are not compatible. m2e should be able to import your Maven projects and set them up as Eclipse expects.
Did you install the WTP add-on for m2e? This blog post may be worth reading.
If any of your pom.xml files invokes any specific plugin (e.g. for code generation) you may need a corresponding m2e add-on. This wiki post may give you an idea of why.
Another attempt you might consider is setting up a Helios based environment. Check that all the plugins you might need are still available, though.

Managing external jar dependencies

I'v written a selenium framework which needs to be extended to the team. I've checked in the code in SVN. How can I make sure that external jars are added to build path and folder that folder by other team members? Basically I want to manage these dependencies better. Somebody said, Maven can take care of these so I tried to install m2eclipse plugin for eclipse 3.2 without any success. Can Maven solve this problem and is there any better way of managing it?
Do the easy way: commit the jars into SVN. It will save everybody a lot of time.
If you are amenable to using Eclipse, Maven, and m2eclipse, I would suggest using SpringSource Tool Suite. It is an Eclipse based IDE with Maven and m2eclipse pre-bundled. This bundling makes getting those three tools to work together very easy.

Eclipse Automatically Download / Update JAR files

I just created a Web App project from a repository through Eclipse's SVN support. What I would be doing is have an ANT build going and then finally deploy through Tomcat.
I am using Eclipse IDE for Java EE developers on an Ubuntu system.
There are a number of jar files needed
to support my project - like Struts,
Hibernate, etc. etc.
Do I need to
manually download each of them
and put them in the lib folder?
OR
Does Eclipse have a solution to
automatically UPDATE these from the internet? Any plugins to automatically take care of this?
You should consider using Maven for your project. It's VERY well supported in Eclipse, and handles all dependencies (as well as other things, such as releases).
The problem is there's a bit of a learning curve, but if you intend your project to get to a considerable size, I'd say it's very important.
Maven has support for ant builds and most libraries are in the central Maven repository. You just say your project has a dependency on the external project and it will automatically download the dependencies.
http://maven.apache.org/

m2eclipse and Eclipse WTP

I have a very large workspace with about 30 projects all together. I am using Eclipse 3.5 with m2eclipse. I check out of my subversion repository using the defaults in order to import the projects into my workspace.
I create a Tomcat server instance, and publish my web project to the tomcat server. Sounds easy enough.
The problem is that it does not appear as though the transitive dependencies for my other projects are being automatically added to the container, so when the container starts up I get classnotfound exceptions, etc.
I go into the web project's properties, and I notice that the Java EE Module Dependencies are NOT checked for some of the transitive dependencies. I check them, and everything seemingly works until I do a project clean build, when the Java EE Module Dependencies are automatically reset by eclipse, so I need to recheck them. This is maddening, and I was hoping there was some way to automatically pull in all of the transitive dependencies when working with Eclipse WTP.
I should mention, using standard maven build works just fine, and everything gets pulled in appropriately into the resulting WAR file. It just doesn't work so good with WTP for some reason.
You need to make sure that you have "Maven integration for WTP" feature from m2eclipse installed. There is a simple tutorial available at http://docs.sonatype.org/display/M2ECLIPSE/WTP+mini+howto
What version of WTP and m2eclipse you are using? Check that dependency version declared in project's pom.xml matches with version declared in workspace project and make sure that workspace dependency resolution is enabled.
Also, you can try to run "Maven / Update project configuration" from the project popup menu and check that there is no errors on Maven console and in Eclipse's own log.
If the above won't help, try to reproduce issue on a smaller project and then submit it with a bug report
It appears as though the latest version of m2eclipse (.99x) solves all of my issues.
If you are tempted to use m2eclipse wtp extras you need to be aware that they are not supported by Sonatype and, although mostly OK, are not 100% robust.
See http://maven.40175.n5.nabble.com/What-is-the-recommended-alternative-to-m2eclipse-extras-WTP-integration-td135727.html

JavaRebel with a Multi-module Enterprise Project in Maven

Does anybody have experience working with JavaRebel, specifically for a large web application built using Maven? There is a JavaRebel plugin for Maven that seems under-documented, does anybody have comments on how it works, can you really update one class in a Multi-module Enterprise Project and have it "automagically" change on your Server?
Are there any issues with different IDEs and this setup? For example NetBeans will not let you compile one class at a time in a Maven project (from what I can tell).
Disclaimer: I work for ZeroTurnaround.
JRebel (formerly JavaRebel) installation involves the application configuration file "rebel.xml" and modifying the container startup command line.
The Maven plugin is used to generate the "rebel.xml" file, that is used by the JRebel agent running in the container to find the files in the workspace. This allows to use IDE building to compile .java files and skip the Maven build process, as the changes to files will be picked up from the workspace. However as it relies on the IDE to compile the classes, it does depend on the IDE ability to compile efficiently. I know for sure that Eclipse will compile classes one at a time and am fairly sure you can configure NetBeans and IntelliJ IDEA to do the same.
In addition to the Maven/rebel.xml configuration you also need to configure the container startup command line. You may also need to install and IDE plugin or do some additional configuration to have the best expirience with JRebel. Following through the steps of Installation manual ensures that.
Hope this helps.
Disclaimer: I've not actually used this plugin myself.
This tutorial implies that JavaRebel works well with Eclipse 3.4. If you are also using m2eclipse it should work ok with Maven projects as well (as long as you ensure that Maven and Eclipse are compiling to the same target folder so the Eclipse incremental compiler can be used to modify the class file).
According to this post, you should configure the javarebel-maven-plugin to generate the rebel.xml (used to mount external folders to the application classpath). There's also a general installation guide you may find useful.