spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charles Feduke <charles.fed...@gmail.com>
Subject Re: Exception when using HttpSolrServer (httpclient) from within Spark Streaming: java.lang.NoSuchMethodError: org.apache.http.impl.conn.SchemeRegistryFactory.createSystemDefault()Lorg/apache/http/conn/scheme/SchemeRegistry
Date Wed, 28 Jan 2015 13:47:42 GMT
I deal with problems like this so often across Java applications with large
dependency trees. Add the shell function at the following link to your
shell on the machine where your Spark Streaming is installed:

https://gist.github.com/cfeduke/fe63b12ab07f87e76b38

Then run in the directory where your JAR files are:

find-java-class SchemeRegistryFactory

(I know you said HttpClient but the error seems to be an overload or method
of SchemeRegistryFactory is missing from the class that is loaded by the
class loader. The class loader loads the first class it finds that match
the package/class name coordinates.)

You'll then be able to zero in on the JAR that is bringing in an older
version of that class. Once you've done that you can exclude that JAR's
older dependency from in in your pom.

If you find out that the newer version is incompatible you'll have to
perform some magic with the Maven shade plugin.


On Wed Jan 28 2015 at 8:00:22 AM Emre Sevinc <emre.sevinc@gmail.com> wrote:

> Hello,
>
> I'm using *Spark 1.1.0* and *Solr 4.10.3*. I'm getting an exception when
> using *HttpSolrServer* from within Spark Streaming:
>
> 15/01/28 13:42:52 ERROR Executor: Exception in task 0.0 in stage 0.0 (TID 0)
> java.lang.NoSuchMethodError: org.apache.http.impl.conn.SchemeRegistryFactory.createSystemDefault()Lorg/apache/http/conn/scheme/SchemeRegistry;
> 	at org.apache.http.impl.client.SystemDefaultHttpClient.createClientConnectionManager(SystemDefaultHttpClient.java:121)
> 	at org.apache.http.impl.client.AbstractHttpClient.getConnectionManager(AbstractHttpClient.java:445)
> 	at org.apache.solr.client.solrj.impl.HttpClientUtil.setMaxConnections(HttpClientUtil.java:206)
> 	at org.apache.solr.client.solrj.impl.HttpClientConfigurer.configure(HttpClientConfigurer.java:35)
> 	at org.apache.solr.client.solrj.impl.HttpClientUtil.configureClient(HttpClientUtil.java:142)
> 	at org.apache.solr.client.solrj.impl.HttpClientUtil.createClient(HttpClientUtil.java:118)
> 	at org.apache.solr.client.solrj.impl.HttpSolrServer.<init>(HttpSolrServer.java:168)
> 	at org.apache.solr.client.solrj.impl.HttpSolrServer.<init>(HttpSolrServer.java:141)
>
> Normally, when I use my utility class that uses SolrJ to connect to a Solr
> server and run it by itself (running it stand-alone without Spark),
> everything works as expected. But when I invoke that utility class inside a
> Spark Streaming application, I get the exception above as soon as it is
> trying to establish a connection to the Solr server. My preliminary
> Internet search led me to believe that some Spark or Hadoop components
> bring an older version of *httpclient*, so I've tried to exclude them in
> my pom.xml.
>
> But I still get the same exception.
>
> Any ideas why? Or how can I fix it?
>
> When I analyze my pom.xml dependencies, I get:
>
> $ mvn dependency:tree -Ddetail=true | grep http
> [INFO] |  |  \- org.eclipse.jetty:jetty-http:jar:8.1.14.v20131031:provided
> [INFO] |  +- org.apache.httpcomponents:httpclient:jar:4.3.1:compile
> [INFO] |  +- org.apache.httpcomponents:httpcore:jar:4.3:compile
> [INFO] |  +- org.apache.httpcomponents:httpmime:jar:4.3.1:compile
>
> The whole dependency tree is:
>
> $ mvn dependency:tree -Ddetail=true
> [INFO] Scanning for projects...
> [INFO]
> [INFO] ------------------------------------------------------------------------
> [INFO] Building bigcontent 1.0-SNAPSHOT
> [INFO] ------------------------------------------------------------------------
> [INFO]
> [INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ bigcontent ---
> [INFO] bigcontent:bigcontent:jar:1.0-SNAPSHOT
> [INFO] +- org.apache.spark:spark-streaming_2.10:jar:1.1.1:provided
> [INFO] |  +- org.apache.spark:spark-core_2.10:jar:1.1.1:provided
> [INFO] |  |  +- org.apache.curator:curator-recipes:jar:2.4.0:provided
> [INFO] |  |  |  \- org.apache.curator:curator-framework:jar:2.4.0:provided
> [INFO] |  |  |     \- org.apache.curator:curator-client:jar:2.4.0:provided
> [INFO] |  |  +- org.eclipse.jetty:jetty-plus:jar:8.1.14.v20131031:provided
> [INFO] |  |  |  +- org.eclipse.jetty.orbit:javax.transaction:jar:1.1.1.v201105210645:provided
> [INFO] |  |  |  +- org.eclipse.jetty:jetty-webapp:jar:8.1.14.v20131031:provided
> [INFO] |  |  |  |  +- org.eclipse.jetty:jetty-xml:jar:8.1.14.v20131031:provided
> [INFO] |  |  |  |  \- org.eclipse.jetty:jetty-servlet:jar:8.1.14.v20131031:provided
> [INFO] |  |  |  \- org.eclipse.jetty:jetty-jndi:jar:8.1.14.v20131031:provided
> [INFO] |  |  |     \- org.eclipse.jetty.orbit:javax.mail.glassfish:jar:1.4.1.v201005082020:provided
> [INFO] |  |  |        \- org.eclipse.jetty.orbit:javax.activation:jar:1.1.0.v201105071233:provided
> [INFO] |  |  +- org.eclipse.jetty:jetty-security:jar:8.1.14.v20131031:provided
> [INFO] |  |  +- org.eclipse.jetty:jetty-util:jar:8.1.14.v20131031:provided
> [INFO] |  |  +- org.apache.commons:commons-lang3:jar:3.3.2:provided
> [INFO] |  |  +- org.slf4j:jul-to-slf4j:jar:1.7.5:provided
> [INFO] |  |  +- org.slf4j:jcl-over-slf4j:jar:1.7.5:provided
> [INFO] |  |  +- com.ning:compress-lzf:jar:1.0.0:provided
> [INFO] |  |  +- net.jpountz.lz4:lz4:jar:1.2.0:provided
> [INFO] |  |  +- com.twitter:chill_2.10:jar:0.3.6:provided
> [INFO] |  |  |  \- com.esotericsoftware.kryo:kryo:jar:2.21:provided
> [INFO] |  |  |     +- com.esotericsoftware.reflectasm:reflectasm:jar:shaded:1.07:provided
> [INFO] |  |  |     +- com.esotericsoftware.minlog:minlog:jar:1.2:provided
> [INFO] |  |  |     \- org.objenesis:objenesis:jar:1.2:provided
> [INFO] |  |  +- com.twitter:chill-java:jar:0.3.6:provided
> [INFO] |  |  +- org.spark-project.akka:akka-remote_2.10:jar:2.2.3-shaded-protobuf:provided
> [INFO] |  |  |  +- org.spark-project.akka:akka-actor_2.10:jar:2.2.3-shaded-protobuf:provided
> [INFO] |  |  |  |  \- com.typesafe:config:jar:1.0.2:provided
> [INFO] |  |  |  +- org.spark-project.protobuf:protobuf-java:jar:2.4.1-shaded:provided
> [INFO] |  |  |  \- org.uncommons.maths:uncommons-maths:jar:1.2.2a:provided
> [INFO] |  |  +- org.spark-project.akka:akka-slf4j_2.10:jar:2.2.3-shaded-protobuf:provided
> [INFO] |  |  +- org.json4s:json4s-jackson_2.10:jar:3.2.10:provided
> [INFO] |  |  |  \- org.json4s:json4s-core_2.10:jar:3.2.10:provided
> [INFO] |  |  |     +- org.json4s:json4s-ast_2.10:jar:3.2.10:provided
> [INFO] |  |  |     \- org.scala-lang:scalap:jar:2.10.0:provided
> [INFO] |  |  |        \- org.scala-lang:scala-compiler:jar:2.10.0:provided
> [INFO] |  |  |           \- org.scala-lang:scala-reflect:jar:2.10.0:provided
> [INFO] |  |  +- colt:colt:jar:1.2.0:provided
> [INFO] |  |  |  \- concurrent:concurrent:jar:1.3.4:provided
> [INFO] |  |  +- org.apache.mesos:mesos:jar:shaded-protobuf:0.18.1:provided
> [INFO] |  |  +- io.netty:netty-all:jar:4.0.23.Final:provided
> [INFO] |  |  +- com.clearspring.analytics:stream:jar:2.7.0:provided
> [INFO] |  |  +- com.codahale.metrics:metrics-core:jar:3.0.0:provided
> [INFO] |  |  +- com.codahale.metrics:metrics-jvm:jar:3.0.0:provided
> [INFO] |  |  +- com.codahale.metrics:metrics-json:jar:3.0.0:provided
> [INFO] |  |  +- com.codahale.metrics:metrics-graphite:jar:3.0.0:provided
> [INFO] |  |  +- org.tachyonproject:tachyon-client:jar:0.5.0:provided
> [INFO] |  |  |  \- org.tachyonproject:tachyon:jar:0.5.0:provided
> [INFO] |  |  +- org.spark-project:pyrolite:jar:2.0.1:provided
> [INFO] |  |  \- net.sf.py4j:py4j:jar:0.8.2.1:provided
> [INFO] |  +- org.eclipse.jetty:jetty-server:jar:8.1.14.v20131031:provided
> [INFO] |  |  +- org.eclipse.jetty.orbit:javax.servlet:jar:3.0.0.v201112011016:provided
> [INFO] |  |  +- org.eclipse.jetty:jetty-continuation:jar:8.1.14.v20131031:provided
> [INFO] |  |  \- org.eclipse.jetty:jetty-http:jar:8.1.14.v20131031:provided
> [INFO] |  |     \- org.eclipse.jetty:jetty-io:jar:8.1.14.v20131031:provided
> [INFO] |  \- org.scala-lang:scala-library:jar:2.10.4:provided
> [INFO] +- com.sun.jersey:jersey-core:jar:1.9.1:compile
> [INFO] +- org.apache.hadoop:hadoop-client:jar:2.4.0:compile
> [INFO] |  +- org.apache.hadoop:hadoop-hdfs:jar:2.4.0:compile
> [INFO] |  +- org.apache.hadoop:hadoop-mapreduce-client-app:jar:2.4.0:compile
> [INFO] |  |  +- org.apache.hadoop:hadoop-mapreduce-client-common:jar:2.4.0:compile
> [INFO] |  |  |  +- org.apache.hadoop:hadoop-yarn-client:jar:2.4.0:compile
> [INFO] |  |  |  |  \- com.sun.jersey:jersey-client:jar:1.9:compile
> [INFO] |  |  |  \- org.apache.hadoop:hadoop-yarn-server-common:jar:2.4.0:compile
> [INFO] |  |  \- org.apache.hadoop:hadoop-mapreduce-client-shuffle:jar:2.4.0:compile
> [INFO] |  +- org.apache.hadoop:hadoop-yarn-api:jar:2.4.0:compile
> [INFO] |  +- org.apache.hadoop:hadoop-mapreduce-client-jobclient:jar:2.4.0:compile
> [INFO] |  \- org.apache.hadoop:hadoop-annotations:jar:2.4.0:compile
> [INFO] +- com.google.guava:guava:jar:16.0:compile
> [INFO] +- org.apache.hadoop:hadoop-mapreduce-client-core:jar:2.4.0:compile
> [INFO] |  +- org.apache.hadoop:hadoop-yarn-common:jar:2.4.0:compile
> [INFO] |  |  +- javax.xml.bind:jaxb-api:jar:2.2.2:compile
> [INFO] |  |  |  +- javax.xml.stream:stax-api:jar:1.0-2:compile
> [INFO] |  |  |  \- javax.activation:activation:jar:1.1:compile
> [INFO] |  |  +- javax.servlet:servlet-api:jar:2.5:compile
> [INFO] |  |  +- com.google.inject:guice:jar:3.0:compile
> [INFO] |  |  |  +- javax.inject:javax.inject:jar:1:compile
> [INFO] |  |  |  \- aopalliance:aopalliance:jar:1.0:compile
> [INFO] |  |  \- com.sun.jersey.contribs:jersey-guice:jar:1.9:compile
> [INFO] |  +- com.google.protobuf:protobuf-java:jar:2.5.0:compile
> [INFO] |  +- org.slf4j:slf4j-api:jar:1.7.5:compile
> [INFO] |  +- com.google.inject.extensions:guice-servlet:jar:3.0:compile
> [INFO] |  \- io.netty:netty:jar:3.6.2.Final:compile
> [INFO] +- json-mapreduce:json-mapreduce:jar:1.0-SNAPSHOT:compile
> [INFO] +- org.apache.avro:avro-mapred:jar:1.7.7:compile
> [INFO] |  +- org.apache.avro:avro-ipc:jar:1.7.7:compile
> [INFO] |  |  +- org.apache.velocity:velocity:jar:1.7:compile
> [INFO] |  |  \- org.mortbay.jetty:servlet-api:jar:2.5-20081211:compile
> [INFO] |  +- org.apache.avro:avro-ipc:jar:tests:1.7.7:compile
> [INFO] |  +- org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile
> [INFO] |  \- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.13:compile
> [INFO] +- junit:junit:jar:4.11:test
> [INFO] |  \- org.hamcrest:hamcrest-core:jar:1.3:test
> [INFO] +- org.apache.avro:avro:jar:1.7.7:compile
> [INFO] |  +- com.thoughtworks.paranamer:paranamer:jar:2.3:compile
> [INFO] |  +- org.xerial.snappy:snappy-java:jar:1.0.5:compile
> [INFO] |  \- org.apache.commons:commons-compress:jar:1.4.1:compile
> [INFO] |     \- org.tukaani:xz:jar:1.0:compile
> [INFO] +- org.apache.hadoop:hadoop-common:jar:2.4.0:provided
> [INFO] |  +- commons-cli:commons-cli:jar:1.2:compile
> [INFO] |  +- org.apache.commons:commons-math3:jar:3.1.1:provided
> [INFO] |  +- xmlenc:xmlenc:jar:0.52:compile
> [INFO] |  +- commons-codec:commons-codec:jar:1.4:compile
> [INFO] |  +- commons-io:commons-io:jar:2.4:compile
> [INFO] |  +- commons-net:commons-net:jar:3.1:provided
> [INFO] |  +- commons-collections:commons-collections:jar:3.2.1:compile
> [INFO] |  +- org.mortbay.jetty:jetty:jar:6.1.26:compile
> [INFO] |  +- org.mortbay.jetty:jetty-util:jar:6.1.26:compile
> [INFO] |  +- com.sun.jersey:jersey-json:jar:1.9:compile
> [INFO] |  |  +- org.codehaus.jettison:jettison:jar:1.1:compile
> [INFO] |  |  +- com.sun.xml.bind:jaxb-impl:jar:2.2.3-1:compile
> [INFO] |  |  +- org.codehaus.jackson:jackson-jaxrs:jar:1.8.3:compile
> [INFO] |  |  \- org.codehaus.jackson:jackson-xc:jar:1.8.3:compile
> [INFO] |  +- com.sun.jersey:jersey-server:jar:1.9:compile
> [INFO] |  |  \- asm:asm:jar:3.1:compile
> [INFO] |  +- tomcat:jasper-compiler:jar:5.5.23:provided
> [INFO] |  +- tomcat:jasper-runtime:jar:5.5.23:provided
> [INFO] |  +- javax.servlet.jsp:jsp-api:jar:2.1:provided
> [INFO] |  +- commons-el:commons-el:jar:1.0:provided
> [INFO] |  +- commons-logging:commons-logging:jar:1.1.3:compile
> [INFO] |  +- log4j:log4j:jar:1.2.17:compile
> [INFO] |  +- net.java.dev.jets3t:jets3t:jar:0.9.0:provided
> [INFO] |  |  \- com.jamesmurty.utils:java-xmlbuilder:jar:0.4:provided
> [INFO] |  +- commons-lang:commons-lang:jar:2.6:compile
> [INFO] |  +- commons-configuration:commons-configuration:jar:1.6:provided
> [INFO] |  |  +- commons-digester:commons-digester:jar:1.8:provided
> [INFO] |  |  |  \- commons-beanutils:commons-beanutils:jar:1.7.0:provided
> [INFO] |  |  \- commons-beanutils:commons-beanutils-core:jar:1.8.0:provided
> [INFO] |  +- org.apache.hadoop:hadoop-auth:jar:2.4.0:provided
> [INFO] |  +- com.jcraft:jsch:jar:0.1.42:provided
> [INFO] |  +- com.google.code.findbugs:jsr305:jar:1.3.9:provided
> [INFO] |  \- org.apache.zookeeper:zookeeper:jar:3.4.5:compile
> [INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.7:compile
> [INFO] +- org.apache.solr:solr-solrj:jar:4.10.1:compile
> [INFO] |  +- org.apache.httpcomponents:httpclient:jar:4.3.1:compile
> [INFO] |  +- org.apache.httpcomponents:httpcore:jar:4.3:compile
> [INFO] |  +- org.apache.httpcomponents:httpmime:jar:4.3.1:compile
> [INFO] |  +- org.codehaus.woodstox:wstx-asl:jar:3.2.7:compile
> [INFO] |  \- org.noggit:noggit:jar:0.5:compile
> [INFO] \- com.fasterxml.jackson.core:jackson-databind:jar:2.5.0:compile
> [INFO]    +- com.fasterxml.jackson.core:jackson-annotations:jar:2.5.0:compile
> [INFO]    \- com.fasterxml.jackson.core:jackson-core:jar:2.5.0:compile
> [INFO] ------------------------------------------------------------------------
> [INFO] BUILD SUCCESS
> [INFO] ------------------------------------------------------------------------
> [INFO] Total time: 1.327 s
> [INFO] Finished at: 2015-01-28T13:12:34+01:00
> [INFO] Final Memory: 17M/173M
> [INFO] ------------------------------------------------------------------------
>
>
> And my pom.xml is:
>
>
> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
>   <modelVersion>4.0.0</modelVersion>
>
>   <groupId>bigcontent</groupId>
>   <artifactId>bigcontent</artifactId>
>   <version>1.0-SNAPSHOT</version>
>   <packaging>jar</packaging>
>
>   <name>bigcontent</name>
>   <url>http://maven.apache.org</url>
>
>   <properties>
>     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>   </properties>
>
>   <build>
>     <plugins>
>       <plugin>
>         <groupId>org.apache.maven.plugins</groupId>
>         <artifactId>maven-shade-plugin</artifactId>
>         <version>2.3</version>
>         <configuration>
>           <!-- put your configurations here -->
>         </configuration>
>         <executions>
>           <execution>
>             <phase>package</phase>
>             <goals>
>               <goal>shade</goal>
>             </goals>
>           </execution>
>         </executions>
>       </plugin>
>
>       <plugin>
>         <groupId>org.apache.maven.plugins</groupId>
>         <artifactId>maven-compiler-plugin</artifactId>
>         <version>3.2</version>
>         <configuration>
>           <source>1.7</source>
>           <target>1.7</target>
>         </configuration>
>       </plugin>
>     </plugins>
>   </build>
>
>   <dependencies>
>     <dependency>
>       <groupId>org.apache.spark</groupId>
>       <artifactId>spark-streaming_2.10</artifactId>
>       <version>1.1.1</version>
>       <scope>provided</scope>
>     </dependency>
>
>     <dependency>
>       <groupId>com.sun.jersey</groupId>
>       <artifactId>jersey-core</artifactId>
>       <version>1.9.1</version>
>     </dependency>
>
>     <dependency>
>       <groupId>org.apache.hadoop</groupId>
>       <artifactId>hadoop-client</artifactId>
>       <version>2.4.0</version>
>       <exclusions>
>         <exclusion>
>           <groupId>javax.servlet</groupId>
>           <artifactId>*</artifactId>
>         </exclusion>
>         <exclusion>
>           <groupId>commons-httpclient</groupId>
>           <artifactId>*</artifactId>
>         </exclusion>
>       </exclusions>
>     </dependency>
>
>     <dependency>
>       <groupId>com.google.guava</groupId>
>       <artifactId>guava</artifactId>
>       <version>16.0</version>
>     </dependency>
>
>     <dependency>
>       <groupId>org.apache.hadoop</groupId>
>       <artifactId>hadoop-mapreduce-client-core</artifactId>
>       <version>2.4.0</version>
>     </dependency>
>
>     <dependency>
>       <groupId>json-mapreduce</groupId>
>       <artifactId>json-mapreduce</artifactId>
>       <version>1.0-SNAPSHOT</version>
>       <exclusions>
>         <exclusion>
>           <groupId>javax.servlet</groupId>
>           <artifactId>*</artifactId>
>         </exclusion>
>         <exclusion>
>           <groupId>commons-io</groupId>
>           <artifactId>*</artifactId>
>         </exclusion>
>         <exclusion>
>           <groupId>commons-lang</groupId>
>           <artifactId>*</artifactId>
>         </exclusion>
>         <exclusion>
>           <groupId>org.apache.hadoop</groupId>
>           <artifactId>hadoop-common</artifactId>
>         </exclusion>
>         <exclusion>
>           <groupId>commons-httpclient</groupId>
>           <artifactId>*</artifactId>
>         </exclusion>
>       </exclusions>
>     </dependency>
>
>     <dependency>
>       <groupId>org.apache.avro</groupId>
>       <artifactId>avro-mapred</artifactId>
>       <version>1.7.7</version>
>       <exclusions>
>         <exclusion>
>           <groupId>javax.servlet</groupId>
>           <artifactId>*</artifactId>
>         </exclusion>
>         <exclusion>
>           <groupId>org.apache.hadoop</groupId>
>           <artifactId>hadoop-common</artifactId>
>         </exclusion>
>         <exclusion>
>           <groupId>commons-httpclient</groupId>
>           <artifactId>*</artifactId>
>         </exclusion>
>       </exclusions>
>     </dependency>
>
>     <dependency>
>       <groupId>junit</groupId>
>       <artifactId>junit</artifactId>
>       <version>4.11</version>
>       <scope>test</scope>
>     </dependency>
>
>     <dependency>
>       <groupId>org.apache.avro</groupId>
>       <artifactId>avro</artifactId>
>       <version>1.7.7</version>
>       <exclusions>
>         <exclusion>
>           <groupId>javax.servlet</groupId>
>           <artifactId>*</artifactId>
>         </exclusion>
>         <exclusion>
>           <groupId>commons-httpclient</groupId>
>           <artifactId>*</artifactId>
>         </exclusion>
>       </exclusions>
>     </dependency>
>
>     <dependency>
>       <groupId>org.apache.hadoop</groupId>
>       <artifactId>hadoop-common</artifactId>
>       <version>2.4.0</version>
>       <scope>provided</scope>
>       <exclusions>
>         <exclusion>
>           <groupId>javax.servlet</groupId>
>           <artifactId>*</artifactId>
>         </exclusion>
>         <exclusion>
>           <groupId>commons-httpclient</groupId>
>           <artifactId>*</artifactId>
>         </exclusion>
>         <exclusion>
>           <groupId>com.google.guava</groupId>
>           <artifactId>*</artifactId>
>         </exclusion>
>       </exclusions>
>     </dependency>
>
>     <dependency>
>       <groupId>org.slf4j</groupId>
>       <artifactId>slf4j-log4j12</artifactId>
>       <version>1.7.7</version>
>     </dependency>
>
>     <dependency>
>       <groupId>org.apache.solr</groupId>
>       <artifactId>solr-solrj</artifactId>
>       <version>4.10.1</version>
>     </dependency>
>
>     <dependency>
>       <groupId>com.fasterxml.jackson.core</groupId>
>       <artifactId>jackson-databind</artifactId>
>       <version>2.5.0</version>
>     </dependency>
>
>   </dependencies>
> </project>
>
>
>
> --
> Emre Sevinç
>

Mime
View raw message