Maven dependency Hibernate library cannot be read - eclipse

I'm getting the following error in eclipse.
Archive for required library: '~/.m2/repository/org/hibernate/hibernate-core/4.2.1.Final/hibernate-core-4.2.1.Final.jar' in project
I've done Maven->Update Project and still it can't recognize the library.
I've verified that the jar file exists in the location mentioned.
This post has the same error as I do but I double checked my pom and there are no duplicates.

Check access settings for file '~/.m2/repository/org/hibernate/hibernate-core/4.2.1.Final/hibernate-core-4.2.1.Final.jar' if you are using *nix system,
Also make sure you can open hibernate-core-4.2.1.Final.jar archive using third party tools e.g. 7zip or winrar. from my experience many times maven in eclipse does not properly download dependency and downloaded jar is corrupted. If that is the case you can manually download this jar and replace it in .m2 repository.

Try to run maven task eclipse:eclipse from command prompt
open command prompt, Change Directory to project root directory and type
mvn eclipse:eclipse
And go back to eclipse and refresh project and see will it works :)

Related

Where is the Maven that Eclipse/STS is using so I can run it from command line?

I have a Java Spring MVC web app in Eclipse/STS.
I can build the WAR file by right-clicking on the project and choose "Run As > Maven Install". The WAR file is created under \target\MYPROJECT.WAR
Now I want to run this from the command line because I'm writing a script that will build the WAR, and make a deliverable ZIP file (with the WAR, readmes, docs, and config files).
I'm on a Mac, when I run 'mvn install' from the root of my project, it says "command not found: mvn". I prefer not to setup a separate maven installation, I'd rather use the same one that Eclipse is using.
Where is the Maven installation that Eclipse/STS is using?
Answering the question after getting helpful comment from #greg-449
The answer is, you cannot (or are not supposed to) use Eclipse/STS's built-in Maven from the command line.
So instead I installed a separate Maven instance.

Eclipse runnable jar export misses some folders

How I did the export:
select the project
right click > export...
Runnable JAR file
The problem:
The jar somehow misses folders in the project that is not under the src/.
I tried exporting as a regular Jar, in which I can select what files to be included. But after some searching, it seems there is no way to auto include dependencies not directly in the project (I'm using Maven and another external lib added by an eclipse plugin).
The "runnable jar" export apparently uses a launch profile to create the jar. I tried to tinker with the launch profile, but was unable to a setting to specify needed files/folders in the project for run.
I found a few articles about using Maven directly, with pom's maven-assembly-plugin to pack the jar without Eclipse. I did a quick digging, and it seems that's a bit raw. If it could be done directly in eclipse, that'd be great.

jar file got extra ".jar" extension in lib folder

I am facing a weird issue. I don't know whether it is an "apache-tomcat-5.5.25 with Openejb" issue or Eclipse.
I have one Maven project. I do maven clean and maven install. After that I add that project into "apache-tomcat-5.5.25 with Openejb" server and then publish the project into the server.
The problems start here. When I check the published lib folder, I find that some of the jar files have an extra extension of ".jar". For example "xyz.jar" becomes "xyz.jar.jar".
Any ideas why this happens?
Follow the problem upstream: What did Maven produce in it's target folder?
If it's there, too, run Maven with -X, write the log into a file and search that file for the broken JAR name.

Setting up apache solr in eclipse

I am trying to set up Solr in eclipse by following the instructions here: http://hokiesuns.blogspot.com/2010/01/setting-up-apache-solr-in-eclipse.html.
The distribution of Solr that I downloaded does not have WEB-INF directory. I have added the jars that I found in lib to build path. However I get invalid run configuration error.
Can anyone who has Solr set up in eclipse please confirm their settings and configurations.
here's something that might help from a quick googling: In this sort of configuration Maven proves a life savior. Looking for a maven archetype (predefined project structure) I've found this. So in an empty dir try to run the mvn archetype:generate command they are quoting and finally if you are using eclipse run mvn eclipse:eclipse for the eclipse specific files so you can do Import > Existing Maven Projects from eclipse.
The problem was that I had not extracted the war.
As Jem pointed out , the .war exists in dist directory. However dist directory itself doesnt exists in the downloaded source :).
You need to do
ant dist
in the apache folder to get this.
Hope that helps someone else. I was able to get solr up and running using the command line as well as eclipse.
Check the .war file in dist. It has a WEB-INF directory.
So extract the war file and use the files in the lib directory.
For this example I had to make a "classes" directory in WEB-INF

how to fix Eclipse losing reference to third party jar in project sets

Occasionally I see eclipse lose the reference to the third party jars contained in the a projects. (you get the the build path error stating the jar cannot be found)
Its easy enough to fix as you can remove the jar, save the properties of the project and then go in and re-add the jar that it could not find, eclipse can then see the path to the jar and you can then compile again.
the problem is that if you have a lot of projects in your build you would have to do this task a lot.
Is there anything you can do to force eclipse to recognise that it actually has the jar on its classpath?
I have also faced the similar situation many times with my projects in eclipse. The jar file path is correct in the .classpath file and the jar is present still eclipse do that. To fix it you open the .classpath file and resave it and refresh the probject in eclipse and it builds fine.
That's a weird behaviour...
If that's ok you can use Maven 2 for your projects. This means that you have to follow Maven's project structure, which is quite ok, but it can be a pain if you decide to migrate old projects.
Then you can run mvn eclipse:eclipse whenever you want and that will fix your problem in a few seconds.