optimus_prime
optimus_prime

Reputation: 11

IllegalAccessError when instantiating HttpSolrServer

I am executing a SolrQuery on my class under a Maven project. When trying to execute the query I am getting this error:

SEVERE: 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.HttpSolrServer.<clinit>(HttpSolrServer.java:91)
....

Here is my pom.xml:

<dependency>
  <groupId>org.apache.solr</groupId>
  <artifactId>solr-core</artifactId>
  <version>4.8.1</version>
</dependency>
<dependency>
  <groupId>org.apache.solr</groupId>
  <artifactId>solr-solrj</artifactId>
  <version>4.8.1</version>
</dependency>
<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-api</artifactId>
  <version>1.7.12</version>
</dependency>
<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-log4j12</artifactId>
  <version>1.7.12</version>
</dependency>

It's working in another project which is not using Maven but by adding jars. I used in Maven the same versions used in the normal web project. Can anyone help with this issue?

Upvotes: 1

Views: 170

Answers (1)

sbochins
sbochins

Reputation: 198

You should remove the slf4j dependencies. SolrJ is pulling in different versions of those dependencies. It appears that the versions you are pulling in are overriding the older version that SorlJ uses. This should be what is causing your error.

Upvotes: 1

Related Questions