I'm developing a web project using Eclipse Juno, Tomcat 7 and Maven 3 and have run into a strange problem.
I have a separate project where I compile some stuff and I pick that jar up in my web project as a dependency. So, the end result is one .war.
Now, when I run this war in embedded Tomcat in Eclipse and hit the refresh button on my browser, Tomcat says it cannot find a path in that jar.
In the workspace WEB-INF/lib folder I find the myApplication-common-widgetset-0.0.11-20130926.124257-7.jar
In the Tomcat Deployment directory under wtpwebapps/myApplication/WEB-INF/lib I see myApplication-common-widgetset-0.0.11-SNAPSHOT.jar
The strange thing is that the file under the Tomcat lib is 1kb large and the file in my workspace lib is ~22Mb.
I tried to copy the workspace jar to the Tomcat lib folder and everything works and run as a charm.
Updates:
When I run mvn tomcat:run from the command line in my workspace, everything works.
I "re-installed" both Eclipse (to Kepler, wiping everything, including workspace and home folders) and Tomcat 7. I still have the same issue.
Colleges tried fetching my project from SVN and ran it successfully, both with Eclipse and IntelliJ + Tomcat 7
What could have happened? Why is Eclipse embedded Tomcat not getting everything from the target directory?
The issue I think you're facing is the reality that eclipse does not strictly honour the maven dependencies.
This has to do with the fact that eclipse does not defer to maven when building, deploying and running on tomcat. Eclipse will use your local workspace setup and will thus sometimes introduce a dependency tree that is different from maven.
From the information you've supplied it appears as if that workspace lib file is the one sourced from a maven repository and the one in embedded tomcat deployment directory is a jar that eclipse has built - I'm guessing here.
If that jar is from a workspace project you can try closing the project and letting eclipse find the jar from maven.
This issue with Eclipse and Maven is rather nebulous and so is difficult to figure out exactly what is going on in terms of dependencies so sorry I can't be of more help
Related
I have the Eclipse (STS) with Maven installed. I've named the project ExchangeBoardRest. When I run the program from the embedded VMWare tc server it deploys to localhost:8080/ExchangeBoardRest/index.jsp, etc. I don't want it there but in localhost:8080/exchangeboard/index.jsp.
I'm not seeing where I can change this. I figured perhaps the pom.xml would do this for me (I update the maven project right afterwards). I don't have ExchangeBoardRest in any interesting text files (just in .settings, .project).
I don't want to have to edit the server.xml that VmWare tc creates. Is there something easy I'm missing?
Thanks,
Jerome.
I'm not using STS, but Eclipse and m2e with WTP. But I guess it's the same thing:
Right-click on the project in the project explorer and select Properties.
Locate Web project settings
Change Context root setting as you desire.
I have been trying to deploy a project that I created within eclipse but when I right click on the tomcat server and click "Add and Remove...", I got the message "There are no resources that can be added or removed from the server".
From what I understand it has something to do with the facets? I am not really sure to understand what is going wrong here.
Here is what I did for know:
I created a Maven project.
executed mvn eclipse:eclipse through the command line on the folder of the project
installed m2e
tried to add the project to the tomcat server
You probably want to use either mvn eclipse:eclipse OR m2e, but not both. m2e has gotten MUCH better in the last couple years, so that's what I would suggest.
Make sure you are using Eclipse for Java EE, otherwise you will need to install other plugins like WTP
Install m2e.
Install maven integration for wtp (from the eclipse marketplace)
make sure the artifact type for your project is war
Import Existing Maven Project in eclipse and browse to your pom to import the project.
It should give the correct facets to your project so it looks like a web project.
I'm trying to make a simple base war which includes all the boilerplate setup for spring, etc. to overlay on new projects to avoid rewriting. The overlay itself is working, however, is there a way to display the files that are being overlayed in eclipse in order to edit them without replacing the file in order to overwrite it?
Thanks!
It's a bit difficult for me to ascertain exactly what you are asking. But I'll take a guess!
I assume the WAR overlay Maven module you has an artifact packaging of type WAR. If so, this Maven module can be imported into Eclipse as its own project (File->Import->Maven->Existing Maven Projects).
Our team does this. Our Maven WAR overlay project is imported into Eclipse as a project along with several (downstream) Maven WAR projects also imported into Eclipse. This can be done regardless of whether the WAR overlay and the WAR Maven modules are part of a multi-module Maven project or are separate Maven projects.
Once the Maven WAR overlay project is imported into Eclipse you can work on it like any other Eclipse project, editing the files, validating, etc. When you are done editing you can save your work and then run Maven from the command line and everything will work fine. You get to edit the overlay files in Eclipse and still have all your Maven goodness.
Note that your Maven WAR projects can be imported into Eclipse as a vanilla Java projects or as WTP (web tools platform) projects. This is totally a matter of preference. For the past year, I worked in Eclipse on Maven WAR projects as regular (unfacted) Java projects. However, recently with the awesome M2E-WTP integration, I now get the full benefit of WTP projects AND the power of Maven. Amoung other things, means I can run the combined WAR on Tomcat from directly inside Eclipse. If you want to understand how to use Eclipse/M2E with M2E-WTP to properly handle WAR overlays, then see my other answer here:
How to handle Maven WAR overlays in Eclipse?
If you have further questions post them in the comments section.
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.
I just started maven in general and m2eclipse in specific.
What I have been doing before is follow:
1)Deploy my application to tomcat.
2) make any changes to the java or jsp files.
3) save and run the application again ( no restart is neccessary unless I changed a config file).
now, everytime I make a minor change to my maven project in eclipse I have to do a "pre-clean install" to compile and deploy the application again and then restart weblogic 10 to view the changes.
Is there anyway ( or maybe I m not doing something right) that I when I modify a class or jsp file, the code will get compiled and deployed when I save the file like I was doing before with the eclipse default project builder and tomcat?
Also, When I checkout the maven project from SVN, Eclipes shows bunch of compiling errors due to some missing classes, but when I build the project using m2eclipse everything builds successfull. Why is eclipse not recognizing the classes??
I have looked at the following answer but I was not able to figure out the problem.
How do I start Maven "compile" goal on save in Eclipse?
now, everytime I make a minor change to my maven project in eclipse I have to do a "pre-clean install" to compile and deploy the application again and then restart weblogic 10 to view the changes.
You shouldn't have to do that. Are you using the Oracle Enterprise Pack for Eclipse (OEPE) (available from the market place or from an update site) and the WTP?
Is there anyway ( or maybe I m not doing something right) that I when I modify a class or jsp file, the code will get compiled and deployed when I save the file like I was doing before with the eclipse default project builder and tomcat?
See above.
Also, When I checkout the maven project from SVN, Eclipes shows bunch of compiling errors due to some missing classes, but when I build the project using m2eclipse everything builds successful. Why is eclipse not recognizing the classes??
Try the following: right-click on the project then Maven > Update Project Configuration.