Setting up apache solr in eclipse - 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

Related

JBoss 6.1.1.EAP Module Deployment: Class not found

The structure is as follows:
Actually deployed module is EAR.
EAR contains WAR module, and WAR module contains another JAR module.
In this last JAR, there are some generated classes and their parent folder is also used as source folder. Its path is "target/generated-sources/java".
The problem that is killing me, is that the deployed application throws ClassNotFoundException on server start, and the classes in question are the generated ones.
Now the trick:
if I explicitly change the Deployment Assembly in WAR project in Eclipse not to contain JAR project as "project", but as an archive from the JAR's project "target" folder, JBoss sees the generated classes and starts.
This solution however works only until next eclipse maven project update, so manual edit of deployment assembly is not really a solution.
Any ideas how to deploy or reorganise packages correctly?
OK, seems I have found the solution.
I looked through the build-path of the mentioned JAR file and saw that the entry Output folder pointed to target/test-classes.
After changing this entry to target/classes the application deploys and starts without any missing generated classes.
This is what worked for me:
Expand the 'target' folder of your maven project inside Eclipse (Project Explorer View);
Refresh it (F5);
Right click on your project on 'Servers' tab, then select "Full Publish";
Start your JBoss.
I had to enforce the JBoss Tool "Full Publish" to get an updated version of my target folder by Refreshing it manually on eclipse.
I don't know why but sometimes the Publishing from maven projects (even Full Publishes) do not copy classes from the target Project as it is in the file system. Maybe it's using some outdated memory info or some cache...
Anyway, this is what works for me.
After an update to Eclipse 4.15 and JBoss tools I got this problem too.
My solution: project -> properties -> Java Build Path --> Source
There my Output folder from my source was linked to project/target/classes, I changed this to project/target/project-projectversion/WEB-INF/classes
When I looked into the standalone JBoss folder I saw the folder structure of my source, but the classes where missing, when I changed the output folder the classes pop up and everything worked like before.
I am pretty sure the update made the problems.

Making Eclipse Maven repository inside the project

I'm a real beginner to Maven and Spring framework in eclipse so excuse me if this sounds trivial..
I have created a MVC web project in eclipse using the STS plugin on my windows computer, but my problem is that the location of the jar and configuration files that maven is set to by default is: C:\Users\MyName.m2\repository
This is a problem for me because eventually I'm going to make a WAR file out of my project and deploy it on a Linux machine, which does not have Maven installed on it.
My question is, is it possible to take all the jar files in my Maven repository, and make a local repository on the project itself rather than on an absolute path on the machine (sort of like a lib folder within the WEB-INF in the project that will hold all the maven jars and that maven will direct itself to it), and thus making the transition to the Linux machine smooth
I understand there is this classpath variable named M2_REPO, but doesn't seem to be editable or accept relative path rather than absolute.
Thanks in advance
Since you are using maven and you are adding your dependencies on your pom.xml, then all the dependencies with a scope of "compile" will be added to your final war file created by the maven war plugin under the WEB-INF/lib folder, this means that you should not worried about having maven in your linux server, since the war file that you are going to deploy will contain all the necessary dependencies. If you want to confirm this, just create a package of your project using "mvn clean package" and check the "target" folder generated by maven, you will see a "war" file, and you can unzip your file to check what contains.

Maven dependency Hibernate library cannot be read

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 :)

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.

How can my project access its "resources" directory both when run in Eclipse and from a Maven-packaged jar file?

I'm working with Maven project in Eclipse (with help of m2e plugin). When I pack my project into jar-file (mvn install), all files from "resources" are located in the root of jar.
Therefore, in my program I should use only bare file names:
File file = new File("foo.txt");
But when I build and run my project by Eclipse, I would have to use the relative path to the file:
File file = new File("src/main/resources/foo.txt");
What should I do to solve this problem?
To access your program's resources, don't use File, FileInputStream and similar classes.
They will not work for anything inside a jar file.
Instead, use Foo.class.getResource(...) or .getResourceAsStream() to access your resources. (Read the documentation before doing so.)
I'm not sure if a program started from eclipse can access these - please try and report back!
Your package configuration in Eclipse is wrong, cause it sees src/main/resources as a package instead of a source folder.
The configuration in Eclipse must look like this: