Przemek Zajadlak
Przemek Zajadlak

Reputation: 43

Exception when instantiating CommonsHttpSolrServer

I have a class like this (it's a java class in eclipse, under a Maven project):

public class SolrJ
{
    public static void main( String[] args )
    {
        String url = "http://localhost:8983/solr";
        try {
            SolrServer server = new CommonsHttpSolrServer(url);
            server.deleteByQuery( "*:*" );
        } catch (MalformedURLException ex) {
            ex.printStackTrace();
        } catch (SolrServerException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}

After running this class I got the following exception:

Exception in thread "main" java.lang.IllegalAccessError: tried to access field org.slf4j.impl.StaticLoggerBinder.SINGLETON from class org.slf4j.LoggerFactory
    at org.slf4j.LoggerFactory.staticInitialize(LoggerFactory.java:83)
    at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:73)
    at org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.<clinit>(CommonsHttpSolrServer.java:77)
    at ultimo.solrJ.SolrJ.main(SolrJ.java:19)

My pom.xml looks like this:

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <artifactId>solr-solrj</artifactId>
        <groupId>org.apache.solr</groupId>
        <version>1.4.0</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <artifactId>solr-core</artifactId>
        <groupId>org.apache.solr</groupId>
        <version>1.4.0</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.5.6</version>
    </dependency>

Can anyone help with my issue please? I've serached through Internet and I cannot find any method to resolve my problem.

Upvotes: 1

Views: 2478

Answers (1)

Related Questions