Storm pulling in stale dependencies - apache-storm

We are trying to upgrade from Storm 0.10.0 to 1.0.2 and our project uses kafka-spout
Between versions, backtype.storm package-names were changed to org.apache.storm package-names by the storm-community.
As part of our own upgrade, we had to change storm-kafka's version also to 1.0.2
But when I run the topology on storm, I get the error about missing classes from older version:
apache-storm-1.0.2/bin/storm \
jar \
$jarFile \
org.apache.storm.flux.Flux \
$yamlFile \
--remote
+- Apache Storm -+
+- data FLow User eXperience -+
Version: 1.0.2
Parsing file: topology-config.yaml
333 [main] INFO o.a.s.f.p.FluxParser - loading YAML from input stream...
335 [main] INFO o.a.s.f.p.FluxParser - Not performing property substitution.
335 [main] INFO o.a.s.f.p.FluxParser - Not performing environment variable substitution.
Exception in thread "main" java.lang.NoClassDefFoundError: backtype/storm/spout/MultiScheme
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.apache.storm.flux.FluxBuilder.buildObject(FluxBuilder.java:291)
at org.apache.storm.flux.FluxBuilder.buildComponents(FluxBuilder.java:350)
at org.apache.storm.flux.FluxBuilder.buildTopology(FluxBuilder.java:75)
at org.apache.storm.flux.Flux.runCli(Flux.java:153)
at org.apache.storm.flux.Flux.main(Flux.java:98)
Caused by: java.lang.ClassNotFoundException: backtype.storm.spout.MultiScheme
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
I am not sure from where backtype.storm is creeping into my code-base.
I have looked all over the code-base (and mvn dependency:tree) for 0.10.0 and backtype.storm but those things from older-version are no place to be found.
I even excluded all storm-kafka versions from my child-dependencies and then added an explicit dependency on storm-kafka but it did not change a thing.
Maven does not seem to be at fault because I do not see any 0.10* versions in my ~/.m2/repository:
ls ~/.m2/repository/org/apache/storm/*
~/.m2/repository/org/apache/storm/flux:
1.0.2
~/.m2/repository/org/apache/storm/flux-core:
1.0.2
~/.m2/repository/org/apache/storm/storm:
1.0.2
~/.m2/repository/org/apache/storm/storm-kafka:
1.0.2
Clearly storm is doing something wrong here.

Check your topology-config.yaml, Class is loaded dynamically loaded after picking the class name from the yaml file.

So the issue was because of using shaded jar files as dependencies in our code.
One of the shaded jar file used an older version of the storm-dependency and somehow this was not being shown in the mvn dependency:tree
On excluding the storm dependencies from the shaded jar dependency, the above error went away.
TL;DR: I actual exploded the eventual jar file (using jar -xvf final.jar) and saw duplicate classes in backtype/storm and org/apache/storm packages and the classes in backtype/storm were getting picked up perhaps because backtype comes before org lexicographically? (Not sure on this one because I would have expected the package name to take precedence in such cases).

Related

Missing dependency FreeTypeFontGenerator in fat jar packaged with gradlew

I am packaging a jar file with
gradlew desktop:dist
when running it with java 1.8 (openjdk)
java -jar desktop-1-0.jar
a ClassNotFoundException for the FreeTypeFontGenerator class is thrown. The whole Stacktrace is the following
java -jar desktop-1.0.jar
Picked up _JAVA_OPTIONS: -Xmx512M
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException:
java.lang.NoClassDefFoundError: com/badlogic/gdx/graphics/g2d/freetype/FreeTypeFontGenerator
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:135)
Caused by: java.lang.NoClassDefFoundError: com/badlogic/gdx/graphics/g2d/freetype/FreeTypeFontGenerator
at com.mygdx.tools.FontLoader.loadFont(FontLoader.java:13)
at com.mygdx.stages.hud.ClientHud.(ClientHud.java:42)
at com.mygdx.stages.hud.StartmenuHud.joinButtonClicked(StartmenuHud.java:67)
at com.mygdx.stages.hud.StartmenuHud.access$100(StartmenuHud.java:16)
at com.mygdx.stages.hud.StartmenuHud$2.touchDown(StartmenuHud.java:47)
at com.badlogic.gdx.scenes.scene2d.InputListener.handle(InputListener.java:57)
at com.badlogic.gdx.scenes.scene2d.Actor.notify(Actor.java:188)
at com.badlogic.gdx.scenes.scene2d.Actor.fire(Actor.java:158)
at com.badlogic.gdx.scenes.scene2d.Stage.touchDown(Stage.java:281)
at com.badlogic.gdx.backends.lwjgl.LwjglInput.processEvents(LwjglInput.java:357)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:221)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:128)
Caused by: java.lang.ClassNotFoundException: com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 12 more
I already included the necessary dependencies in the build.gradle file within the root directory of my project for FreeTypeFont as described in the libgdx wiki.
I also refreshed the project dependencies (right-click project -> Gradle -> Refresh Gradle Dependencies)
and rebuild the project.
The solution for me was to add
implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
under the desktop section of my build.gradle file.
I tried this out since the import for the controler module looked a bit alike.
I have no idea why this is not documented, but after a refresh of all gradle dependencies (right-click the project -> Gradle -> Refresh Gradle Dependencies) and a rebuild of the project i was able to run the packaged jar without any problems.

spark intelij submit java.lang.NoClassDefFoundError: javax/servlet/Servlet

When I use IntelIJ as IDE for spark applications, I can run the application in IDE while failed to run spark-submit after exporting this application with all the required dependencies.
Getting ERROR message as:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/servlet/Servlet
at org.apache.spark.ui.WebUI.attachPage(WebUI.scala:80)
...
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 27 more
But when I have check the jar, javax/servlet/Servlet is just there! why?
I use jars with hadoop, spark and hive instead of maven pom. Will this matter? The jar file is huge in size (about 200M).
Finally, please forgive me for my pool English!

Unable to install KAR containing camel-spring: spring beans missing

I've built an application bundled in an OSGi JAR package and now I'm trying to create a KAR file to easy deployment to Apache Karaf 4.0.8.
When I drop the KAR file there's a warning message complaining that it's impossible to resolve camel-spring due to the missing org.springframework.beans requirement.
2017-01-18 19:07:12,239 | WARN | raf-4.0.8/deploy | KarServiceImpl | 36 -
org.apache.karaf.kar.core - 4.0.8 | Unable to install Kar feature
interfacturas-kar/1.0.0.SNAPSHOT
org.osgi.service.resolver.ResolutionException: Unable to resolve root:
missing requirement [root] osgi.identity;
osgi.identity=interfacturas-kar;
type=karaf.feature;
version="[1.0.0.SNAPSHOT,1.0.0.SNAPSHOT]";
filter:="(&(osgi.identity=interfacturas-kar)
(type=karaf.feature(version>=1.0.0.SNAPSHOT)
(version<=1.0.0.SNAPSHOT))"
[caused by: Unable to resolve interfacturas-kar/1.0.0.SNAPSHOT:
missing requirement [interfacturas-kar/1.0.0.SNAPSHOT] osgi.identity;
osgi.identity=org.apache.camel.camel-spring;
type=osgi.bundle;
version="[2.17.0.redhat-630187,2.17.0.redhat-630187]";
resolution:=mandatory
[caused by: Unable to resolve org.apache.camel.camel-spring/2.17.0.redhat-630187:
missing requirement [org.apache.camel.camel-spring/2.17.0.redhat-630187]
osgi.wiring.package;
filter:="(&(osgi.wiring.package=org.springframework.beans)
(version>=3.2.0)(!(version>=4.0.0)))"]]
I cannot figure why this is happening! The kar file does contain spring-beans JAR file of an appropriate version:
$ unzip -l interfacturas-kar-1.0.0-SNAPSHOT.kar
...
614354 2017-01-11 19:07 repository/org/springframework/spring-beans/3.2.16.RELEASE/spring-beans-3.2.16.RELEASE.jar
...
The KAR file and its associated feature XML file is completely generated by karaf-maven-plugin, and it also lists the spring-beans dependency:
<bundle>wrap:mvn:org.springframework/spring-beans/3.2.16.RELEASE</bundle>
along with other spring related resources.
Any has some idea how to fix this? Or why is it happening?
BTW, camel-spring actually comes as a dependency of camel-cxf; I'm using blueprint for defining the routes.

Karaf Feature install throwing Unsupported 'Bundle-ManifestVersion' value: 1

Hi guys i am getting the below error while using feture install in karaf
org.apache.karaf.features.internal.util.MultiException: Error
at org.apache.karaf.features.internal.download.impl.MavenDownloadManager$MavenDownloader.<init>(MavenDownloadManager.java:84)[9:org.apache.karaf.features.core:4.0.3]
at org.apache.karaf.features.internal.download.impl.MavenDownloadManager.createDownloader(MavenDownloadManager.java:72)[9:org.apache.karaf.features.core:4.0.3]
at org.apache.karaf.features.internal.region.Subsystem.downloadBundles(Subsystem.java:358)[9:org.apache.karaf.features.core:4.0.3]
at org.apache.karaf.features.internal.region.Subsystem.downloadBundles(Subsystem.java:355)[9:org.apache.karaf.features.core:4.0.3]
at org.apache.karaf.features.internal.region.SubsystemResolver.resolve(SubsystemResolver.java:191)[9:org.apache.karaf.features.core:4.0.3]
at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:263)[9:org.apache.karaf.features.core:4.0.3]
at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1079)[9:org.apache.karaf.features.core:4.0.3]
at org.apache.karaf.features.internal.service.FeaturesServiceImpl$1.call(FeaturesServiceImpl.java:975)[9:org.apache.karaf.features.core:4.0.3]
at java.util.concurrent.FutureTask.run(FutureTask.java:262)[:1.7.0_79]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[:1.7.0_79]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_79]
at java.lang.Thread.run(Thread.java:745)[:1.7.0_79]
Caused by: java.lang.Exception: Unable to create resource for bundle mvn:org.dt.dummy/Diff-Blueprint/0.0.1-SNAPSHOT
at org.apache.karaf.features.internal.region.Subsystem.createResource(Subsystem.java:567)[9:org.apache.karaf.features.core:4.0.3]
at org.apache.karaf.features.internal.region.Subsystem$1.downloaded(Subsystem.java:376)[9:org.apache.karaf.features.core:4.0.3]
at org.apache.karaf.features.internal.download.impl.MavenDownloadManager$MavenDownloader$1.operationComplete(MavenDownloadManager.java:133)[9:org.apache.karaf.features.core:4.0.3]
at org.apache.karaf.features.internal.download.impl.MavenDownloadManager$MavenDownloader$1.operationComplete(MavenDownloadManager.java:127)[9:org.apache.karaf.features.core:4.0.3]
at org.apache.karaf.features.internal.download.impl.DefaultFuture.notifyListener(DefaultFuture.java:344)[9:org.apache.karaf.features.core:4.0.3]
at org.apache.karaf.features.internal.download.impl.DefaultFuture.notifyListeners(DefaultFuture.java:329)[9:org.apache.karaf.features.core:4.0.3]
at org.apache.karaf.features.internal.download.impl.DefaultFuture.setValue(DefaultFuture.java:255)[9:org.apache.karaf.features.core:4.0.3]
at org.apache.karaf.features.internal.download.impl.AbstractDownloadTask.setFile(AbstractDownloadTask.java:61)[9:org.apache.karaf.features.core:4.0.3]
at org.apache.karaf.features.internal.download.impl.AbstractRetryableDownloadTask.run(AbstractRetryableDownloadTask.java:59)[9:org.apache.karaf.features.core:4.0.3]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.7.0_79]
at java.util.concurrent.FutureTask.run(FutureTask.java:262)[:1.7.0_79]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)[:1.7.0_79]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)[:1.7.0_79]
... 3 more
Caused by: org.osgi.framework.BundleException: Unable to build resource for mvn:org.dt.dummy/Diff-Blueprint/0.0.1-SNAPSHOT: Unsupported 'Bundle-ManifestVersion' value: 1
at org.apache.karaf.features.internal.resolver.ResourceBuilder.build(ResourceBuilder.java:80)[9:org.apache.karaf.features.core:4.0.3]
at org.apache.karaf.features.internal.resolver.ResourceBuilder.build(ResourceBuilder.java:69)[9:org.apache.karaf.features.core:4.0.3]
at org.apache.karaf.features.internal.region.Subsystem.createResource(Subsystem.java:565)[9:org.apache.karaf.features.core:4.0.3]
... 15 more
Caused by: org.osgi.framework.BundleException: Unsupported 'Bundle-ManifestVersion' value: 1
at org.apache.karaf.features.internal.resolver.ResourceBuilder.doBuild(ResourceBuilder.java:88)[9:org.apache.karaf.features.core:4.0.3]
at org.apache.karaf.features.internal.resolver.ResourceBuilder.build(ResourceBuilder.java:78)[9:org.apache.karaf.features.core:4.0.3]
... 17 more
feature.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.3.0" name="Diff-Blueprint">
<feature name="Diff-Blueprint" description="Diff-Blueprint" version="0.0.1.SNAPSHOT">
<feature prerequisite="true" dependency="false">wrap</feature>
<bundle>mvn:org.dt.dummy/Diff-Blueprint/0.0.1-SNAPSHOT</bundle>
<bundle>wrap:mvn:osgi/osgi/3.0.1</bundle>
<bundle>wrap:mvn:javax.xml/xml/3.1.0</bundle>
<bundle>wrap:mvn:xmlunit/xmlunit/1.6</bundle>
<bundle>wrap:mvn:junit/junit/4.11</bundle>
<bundle>wrap:mvn:org.hamcrest/hamcrest-core/1.3</bundle>
<bundle>mvn:com.googlecode.json-simple/json-simple/1.1.1</bundle>
<bundle>wrap:mvn:de.odysseus.staxon/staxon-jackson/1.2</bundle>
<bundle>mvn:com.fasterxml.jackson.core/jackson-core/2.0.6</bundle>
<bundle>wrap:mvn:de.odysseus.staxon/staxon/1.2</bundle>
<bundle>mvn:log4j/log4j/1.2.17</bundle>
<bundle>mvn:org.codehaus.jackson/jackson-mapper-asl/1.9.13</bundle>
<bundle>mvn:org.codehaus.jackson/jackson-core-asl/1.9.13</bundle>
<bundle>wrap:mvn:org.unitils/unitils/2.4</bundle>
<bundle>wrap:mvn:commons-logging/commons-logging/1.1</bundle>
<bundle>wrap:mvn:commons-dbcp/commons-dbcp/1.2.2</bundle>
<bundle>wrap:mvn:commons-pool/commons-pool/1.3</bundle>
<bundle>wrap:mvn:commons-lang/commons-lang/2.3</bundle>
<bundle>wrap:mvn:commons-collections/commons-collections/3.2</bundle>
<bundle>wrap:mvn:ognl/ognl/2.6.9</bundle>
<bundle>wrap:mvn:ant/ant/1.6.5</bundle>
</feature>
</features>
Appreciate that I am resurrecting an old thread here, but to elaborate on #Charity's answer, for anybody who discovers this at a later date (as I did)...
The problem is that we are trying to deploy a non-OSGi compliant bundle, to the container. The solution is to "wrap" the bundle that is causing you problems, by using the Wrap protocol described in the OPS4J Wiki.
JAR Example
A simple example using Maven is shown below:
wrap:mvn:commons-logging/commons-logging/1.1
Note that we have to prefix the bundle with "wrap:", and that is all. See the wiki for more complex examples which override settings defined in the manifest.
WAR Example
Deploy a non-OSGi compliant WAR file in much the same way, using the "webbundle" URI handler instead:
webbundle:mvn:com.example/example-web-app/1.0/war
I have found a solution if we wrap the jars which throw Bundle-ManifestVersion: 1 then this will work
Evidently the Diff-Blueprint bundle has Bundle-ManifestVersion: 1 as a MANIFEST.MF header. This indicates that it predates OSGi Release 4.0, which was released in 2005, so it's unsurprising that a modern version of Karaf does not support it.
So you will have to look into the tool that produced that bundle.
Try to edit MANIFEST.MF file of problematic bundle, just change Bundle-ManifestVersion with value of 2 instead of 1.

java.lang.NoSuchMethodError while starting JAX-RS service via Spring (servlet) configuration

I have a question. I'm still new to Spring Framework and how to configure a Jetty server with Apache CXF and JAX-RS services there.
I'm working on a Maven multi-module project and my module is just one part of that whole project. It's written in Java. And it uses the Spring Framework with Spring Beans/BeanFactory there. It's configured in an XML file there.
I followed those documentations:
- http://cxf.apache.org/docs/jetty-configuration.html
- http://cxf.apache.org/docs/jax-rs.html#JAX-RS-ConfiguringJAX-RSservices
- http://cxf.apache.org/docs/secure-jax-rs-services.html
The JAX-RS service is running so far already, but it shows me an empty webpage then. It also shows me in a LOG file that the Java classes (with the JAX-RS annotations #GET, #PUT and so on) of the JAX-RS service are running and called already, but as soon as I send a request, I receive the following error message:
27 Apr 2014 20:05:53 (cdmi) [] /
java.lang.NoSuchMethodError: org.eclipse.jetty.server.Request.getConnection()Lorg/eclipse/jetty/server/HttpConnection;
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:222) ~[cxf-rt-transports-http-jetty-2.4.0.jar:2.4.0]
at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:72) ~[cxf-rt-transports-http-jetty-2.4.0.jar:2.4.0]
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1088) ~[jetty-server-8.1.13.v20130916.jar:8.1.13.v20130916]
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1024) ~[jetty-server-8.1.13.v20130916.jar:8.1.13.v20130916]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135) ~[jetty-server-8.1.13.v20130916.jar:8.1.13.v20130916]
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255) ~[jetty-server-8.1.13.v20130916.jar:8.1.13.v20130916]
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154) ~[jetty-server-8.1.13.v20130916.jar:8.1.13.v20130916]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116) ~[jetty-server-8.1.13.v20130916.jar:8.1.13.v20130916]
at org.eclipse.jetty.server.Server.handle(Server.java:370) ~[jetty-server-8.1.13.v20130916.jar:8.1.13.v20130916]
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489) [jetty-server-8.1.13.v20130916.jar:8.1.13.v20130916]
at org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:53) [jetty-server-8.1.13.v20130916.jar:8.1.13.v20130916]
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:949) [jetty-server-8.1.13.v20130916.jar:8.1.13.v20130916]
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1011) [jetty-server-8.1.13.v20130916.jar:8.1.13.v20130916]
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644) [jetty-http-8.1.13.v20130916.jar:8.1.13.v20130916]
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235) [jetty-http-8.1.13.v20130916.jar:8.1.13.v20130916]
at org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:72) [jetty-server-8.1.13.v20130916.jar:8.1.13.v20130916]
at org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:264) [jetty-server-8.1.13.v20130916.jar:8.1.13.v20130916]
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608) [jetty-util-8.1.13.v20130916.jar:8.1.13.v20130916]
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543) [jetty-util-8.1.13.v20130916.jar:8.1.13.v20130916]
at java.lang.Thread.run(Thread.java:744) [na:1.7.0_55]
Does someone know this error message. What is the error message trying to tell me and how can I solve it?
I'm not sure which further information might be required, but I can add that information if necessary. The dependency for cxf-rt-transports-http-jetty (version 2.4.0) exists in the POM.xml file of my Maven module.
Many thanks in advance!!!
NoSuchMethodError basically means that a class definition has changed between compile time and runtime. This can be caused by using a different version of a jar when running your application than the version things were compiled with.
It looks like sometime between Jetty 8 and 9 the getConnection method was removed from Request. I would check your target folder to make sure you don't have multiple versions of any jars and that the versions you are using are compatible with each other. Also make sure that however you are running Jetty, it's the same version as the libraries your application depends on.
You might also run maven dependency:tree to check that versions in your pom aren't being overridden in unexpected ways.

Resources