I am getting a class not found exception for my Login Controller when I try to login to my application(It is a spring MVC Application). Before running the maven clean command the Application was running perfectly, I used maven clean and then again done a build using maven package command, suddenly it stopped working. I tried restarting the TomCat, re-deployed the application on TomCat, restarted the Eclipse IDE but nothing has worked so far.
Why this happens and what is the possible solution to this ??
Are you trying to run your project under Eclipse?
And does it generate source files?
If these are both true, you probably need to update the project config (select project or pom, right-click, Maven..Update..Project Configuration and Maven..Update..Project Dependencies).
The problem is that when Maven does a clean, it gets rid of the generated directories, which Eclipse observes and removes from your Build Path. But then when Maven rebuilds the directories, Eclipse doesn't notice it - you have to give it a hint.
Check your project for build errors and build path errors.
Make sure you've defined an M2_REPO classpath variable in Eclipse (Preferences - Java - Build Path - Classpath Variables).
If you're using the m2eclipe plugin, right-click your project and click on Maven - Update project configuration. That will configure an Eclipse build path for your project based on your pom dependencies.
If you're not using m2eclipse, execute mvn eclipse:clean eclipse:eclipse in your project folder. Then refresh your project in Eclipse.
What you haven't said is that you've checked and the missing class is in fact present.
A quick way to check is in the code editor SHIFT+CTRL+T and type the name of the missing class. Eclipse should not only show you the class if it exists, on highlighting the class, Eclipse should tell you which jar it is in.
Based on the info you have provided, I would say some dependecy in your POM has been removed by mistake or you need a newer version of some jar. If you find the class is not present, then you can figure out which jar you need by googling something like Maven 2 MyMissingClass jar that usually works for me.
Delete the .metadata folder in your eclipse workspace and then again open the workspace and import the required project.
This will solve your problem.
In .metadata folder it maintains the temporary copy of the project.
what worked in my case was simply removing the project from work space and importing it back again.
But I still don't know why it worked Vs why other things mentioned did not work (I tried updating dependencies in fact I removed all the dependencies from pom.xml and added everything again)
Related
I have a JEE project and I use maven to build it. In the pom.xml, I specify certain dependencies, e.g. for org.jboss.ejb3 or org.jboss.logging.
Building the application works, both inside/ with the IDE as well as manually invoking "mvn clean install" from the cmd. My issue now is that all imports from the dependencies included in the pom.xml are marked as "cannot be resolved" which results in correct code being marked as incorrect as well as auto-completion not working. I have tried re-importing the project but that has not yielded anything at all.
Also, I have already searched the internet (including Stackoverflow) but none of the answers found were able to help me fix it.
Without knowing what errors you are seeing I am going to assume that your issue is with eclipse project properties (build path, src directory specification, output classes directory, etc).
You tagged m2eclipse plugin, so you should be able to right click on your project in eclipse select maven->update project configuration. If you do not see that option under maven then you should first see an option called maven->enable dependency management. Click that first and then you should be able to see update project configuration option.
If this does not fix it, then open your project directory containing the pom.xml file in command prompt and run mvn eclipse:eclipse.
One of the above should resolve those pesky error messages provided that your maven build itself is successful.
explored all solutions to this, including clearing out metadata folder and making sure the compiler matches the project version. I also have build automatically checked.
When I save my files in eclipse they update in the filesystem, but when I attempt to run my maven project and deploy it to the JBoss server it runs and old version.
I've even put in compiler errors on purpose and it doesn't bother it at all.
Please try building your project with a clean command
mvn clean install
and also refresh your workspace in eclispe. Might help!
do maven clean install through eclipse maven plugin, to avoid different code base confusion, it seems you are editing some different code base on eclipse which is different when you build through maven.
recheck the path for both the cases.
At the end copy the jar from the eclipse project itself after refresh the project on eclipse.
I faced the same issue, due to eclipse was not loading the new jar, caching the old one. it's required to refresh the project on eclipse before taking the build jar.
I have imported a java project into a new eclipse workspace and it gave me a lot of errors:
It says "Project 'myProject' is missing required library: /User/linus/.m2/..." (The directory is longer but not of interest for you)
Now, I have looked inside my Finder to see what is in ".m2" but there is no such directory where it should be. Additionally I let it show all the hidden files but no success. Lastly I tried to get into the folder with the terminal (using cd and then the directory eclipse gave me) but that did not work either.
I saw this post but it did not help me.
I reinstalled Maven to make sure it can be used, this is the output if I type mvn --version and mvn in the terminal:
Does anyone have an idea?
Thanks in advance
EDIT:
I reinstalled Maven and now there is a /.m2 folder. It contains /.m2/repository/ but there is nothing in it...
May I suggest you read a Maven tutorial like http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
IMHO it's a wonderful build tool because it gets required jar files per the specification in the project object model ("pom") file which your Maven-ized project should have, and you don't have to keep track of jars on your own.
Look in your project for pom.xml, you might even post it here.
To check the sanity of the project and maven on your computer (ignoring Eclipse for a moment), be sure you have a good Internet connection, open a Terminal window, change directory ("cd") over to the project directory, and type "mvn install".
This should trigger the usual Maven build cycle. One of the first things it should do is download all the jars as identified in the pom.xml and store them deeply nested within your /Users/linus/.m2/ directory. Then it should compile all your java classes. Eventually it will probably build a jar file and copy it to somewhere.
If all this works, visit http://eclipse.org/m2e/ for directions to add the Maven plugin (m2e) to your Eclipse. Then your Eclipse should understand how to download jars and build the project per the pom.xml file.
Eventually this all should fix the original "Project is missing required library" problem.
I have two maven projects and both are working fine independently. I am able to create a jar file and run it from console as well as from eclipse.
I copied over some classes from the second project into the first and made a few changes so that it runs as a single project with features from both.
I have two pom files, so I combined them into a single pom file.
The thing is that I am able to run it from eclipse fine and able to get the output I was hoping for.
But I am not able to run it after executing the jar file created from "mvn package".
I am using shade maven plugin.
If I use maven build.. with clean install as goal, it again showing errors.
My question is this, why this discrepancy?
We would need more information to correctly diagnose the issue. One thing to look at is to ensure that any changes to dependencies which are projects in Eclipse have been installed as a command line build will only look in your repo, not at your Eclipse project.
This may happen when you have a dependency which exists as an open project in your eclipse workspace.
Try closing every project except the one where you're having this problem. Does it still compile in eclipse then?
I have a that uses maven... and I want to put it in my working environment with eclipse(Galileo)... the project is in a svn server, and I can create check out the project and everything looks OK. I even can run the unit test and everything is working there.
However, now that everything is there I wanted to work in the code, and oh surprise there are no packages in my project... I mean all the source code is in the src folder and browsing through it i can see all my files, ut if I open the files from there, the files are opened as text files with no coloring, but worst no help at all about errors in compilation.
I don't know what im I doing wrong now, because I had the same project in other machine and it was working well.
So here is what I did, please let me know if you notice if I did something wrong, miss any steps or anything that can help me:
In the SVN Repository (Using subclipse 1.6.10) I added my SVN Repository
Browsed to the folder where I have the pom file
Right Click> Check out as a Maven project...(Using m2eclipse 0.10.020100209)
Used the default options and finish.
The projects were created with no problem. I said projects because this maven project has modules, and each module became a project in eclipse.
Back in the java perspective, Right click in the project, Run as > maven test(Using JWebUnitTest, because I am testing a servlet)
BUILD SUCCESS!!
But as I said there is not packages so I can't really develop in this environment.
Any help??
Thanks!
When performing a svn checkout as maven project, m2eclipse writes what it does in a console window, accessible using the "console" panel, where there is a drop-down list of all available consoles. What does this console tells ?
Besides, if you can perform a maven test, you can also, in the maven menu (of your contextual menu) do a "update project configuration" which should do the same thing and configure eclipse for your project.
As a last test, is there a maven icon over your project ?
Have you tested your setup on command line with Maven ? Does a mvn package work without errors ? The location for the sources in Maven is src/main/java + Package name. Have you opened the project as a Maven project?
Thanks for your help, however I noticed that eclipse itself was behaving weird when I try to create a package there and I didn't have the option.
So I found out that for some reason that eclipse installation wasn't giving me any of the Java basic options.
So I download a new eclipse installation.. and I repeat the whole process and now is working...
No clue what was the problem with this eclipse because I was using it for other projects and I don't know when I lost the basic functionalities!
Thanks anyway!