Tel Map

Blog

Running Solr 4.10.3 with Maven, Eclipse 4.4 and Wildfly 8.1.0

The basic setup of Solr 4.10 with Eclipse 4.4 and Wildfly 8.1 requires quite a bit of configuration. First of all, be sure that your system fulfills the following requirements.

Prerequisites

  • Java Development Kit (jdk1.8.0_25)
  • Eclipse Java EE IDE for Web Developers (Luna Service Release 1 (4.4.1))
  • Apache Maven (already included in Eclipse)
  • WildFly Application Server (wildfly-8.1.0.Final)
  • JBossAS Tools (3.0.0.CR1) for Eclipse)

The specified version numbers are the versions I’m using. The tutorial should however apply to other major versions, too.

Setup a WildFly Project in Eclipse with Maven

Open Eclipse and add a new server (“File > new > Server”). If JBoss Tools are installed, you can choose WildFly 8.x and create it without further changes. However if you’re running multiple web projects on the same instance of WildFly you may consider creating an own Server Runtime Environment with a custom WildFly configuration file. Deploying your web app to the workspace metadata instead of the JBoss deploy folder may also be advisable. You find these options by double clicking your server in the “Servers” view.

Maven Configuration

Then create a new “File > new > Maven Project”, skip archetype selection and give it let’s say “illucit-solr” as Artifact Id and “com.illucit” as Group Id. The packaging type must be “war”. The next step is to customize the pom.xml. During this process you have to “maven-update” the project (select the project and press “ALT+F5”) a couple of times. Check out my example pom.xml:

Now create a folder called WebContent right under the project, if not yet present, and place an index.html in it with some content, like “Hello illucIT Software!”. Add the project to your WildFly instance and start the server. When the startup succeeded, browsing http://localhost:8080/illucit-solr/index.html should yield the content of your index.html file.

The URL to the web app can easily be modified by putting a jboss-web.xml file in WebContent/WEB-INF:

The index.html file should now be accessible by browsing http://localhost:8080/index.html.

Adding Solr Dependencies

To run the Solr example, add the following section to your pom.xml:

The following Maven update may take a while. Now if you started Eclipse with a JRE instead of a JDK, a Maven dependency problem Missing artifact jdk.tools:jdk.tools:jar:1.6 occurs. To fix this, launch Eclipse with the a JDK. Edit eclipse.ini and add the following lines

right before the -vmargs parameter. Restart Eclipse and “maven-update” your project. The error should now disappear. Another solution for that problem would be to include this dependency in the pom.xml:

The tools.jar must be referenced relatively to ${java.home}. But this doesn’t solve the eclipse error1, so I continue with the first solution.

If you try to start WildFly now, it fails with the following error message:

To fix this you need to update Google Guava, which is pulled in as a dependency by solr-core in an old version.

WildFly should start now without any errors and all Solr dependencies available.

Copy Solr Files into your Eclipse Project

project The last step is to import the Solr example web app into Eclipse. Download Solr 4.10.3 and unpack it. Extract solr-4.10.3\example\webapps\solr.war and copy the content into the WebContent directory of your workspace. After you deleted the lib directory and weblogic.xml, your project should look like mine.

Visiting the Solr Admin Panel http://localhost:8080/admin.html however fails with an exception Caused by: java.io.IOException: Can't find resource 'solrconfig.xml' in classpath or 'C:\wildfly-8.1.0.Final\bin\solr\collection1\conf' .

So we finally got Solr running with Eclipse 4.4 and WildFly 8.1! The remaining part of the configuration highly depends on your needs and the structure of your Solr index and search. So I leave it up to you, to set this up. But a good starting point would be to copy the solrconfig.xml from solr-4.10.3\example\solr\collection1\conf into the resources directory directly under your project (see also pom.xml, where this directory is defined as resource directory).

  1. Maven not picking JAVA_HOME correctly on Stack Overflow

Leave a Reply

Your email address will not be published. Required fields are marked *