It is just a simple maven project with 1 dependency. I can compile it with not error but when I run it, it won't work. I am guessing that it is some problem with classpath, as when I manually passed all dependecies classpath to the commandline, it runs fine.
screenshot
Also I tried to open the project in idea, and it worked fine.
Related
I am quite new to eclipse and want to develop a maven project in java.
Compilation from within eclipse works but
If i get a compilation error on the eclipse console,
there is no link to the source code.
I would expect eclipse to have such a link.
Does it exist? and if so, how to activate it???
Maybe the problem is, that i already have a maven project
and now want to use eclipse on it.
If you're developing a Maven project in Eclipse, you should create it as a "Maven Project", which will utilize the "m2e" or "maven2eclipse" plugin. When you do it this way, then Eclipse will use the same source folders your Maven build will use (defaulting to src/main/java and src/test/java), and Eclipse will look at the dependencies specified in the pom.xml file and make sure those dependencies are all downloaded and available for the Eclipse compiler. If this is all done properly, then if there are any red marks in the project, then those represent the same compile errors that you would get if you built the Maven project from the command line. Watch out for any red marks in the pom.xml file itself. When that happens, Eclipse doesn't attempt to compile anything.
Scala code run successfully in Eclipse but its jar not run
I have Scala project with SBT, its run well in Eclipse but when I try to run jar file which is generated after packaging is not running its throw error like
SBT version= 0.13.8 ,scala version =2.12.2 ,java=1.8
Click here to seethe Error
click to see the build.sbt
Please co-operate me to solve this issue
This Error due to then dependency is not included in the jar file at the time building the project , so its throws ClassNotFoundException , we can fix this issue by assemlying the dependency into single jar . for this solution please follow the below link
https://alvinalexander.com/scala/sbt-how-build-single-executable-jar-file-assembly/
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.
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 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)