风暴信号出错

jxct1oxe  于 2021-06-21  发布在  Storm
关注(0)|答案(1)|浏览(246)

嗨,我正在运行一个拓扑和使用风暴信号发送消息到拓扑一次又一次。但是我在日志文件中得到错误。
classdefnotfound:backtype.storm.contrib.signals.pout.basesignalspout
有谁能告诉我找不到班级的原因吗?
更新:代码文件已更新
我的喷壶课:

@SuppressWarnings("serial")
public class NumberSpout extends BaseSignalSpout
{
    public NumberSpout(String name) {
        super(name);
        // TODO Auto-generated constructor stub
    }

    private static final Logger LOGGER = Logger.getLogger(NumberSpout.class);
    @SuppressWarnings("rawtypes")
    @Override
    public void open( Map conf, TopologyContext context, SpoutOutputCollector collector ) 
    {   super.open(conf, context, collector);
        LOGGER.info("In open method of spout");
    }

    @Override
    public void nextTuple() 
    {
    }

    @Override
    public void ack(Object id) 
    {
    }

    @Override
    public void fail(Object id) 
    {
    }

    @Override
    public void declareOutputFields(OutputFieldsDeclarer declarer) 
    {
        declarer.declare( new Fields( "name" ) );
    }

    @Override
    public void onSignal(byte[] data) {
        LOGGER.info("Received signal: " + new String(data));
    }
}

我的主题课:

public class PrimeNumberTopology 
{
    private static final Logger LOGGER = Logger.getLogger(PrimeNumberTopology.class);

public static void load(){
    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout( "signal-spout", new NumberSpout("test-signal-spout"));
    Config conf = new Config();
    conf.put(Config.NIMBUS_HOST, "127.0.0.1");
    conf.setDebug(true);
    Map storm_conf = Utils.readStormConfig();
    storm_conf.put("nimbus.host", "127.0.0.1");
    Client client = NimbusClient.getConfiguredClient(storm_conf)
            .getClient();
    String inputJar = "/home/jamil/Downloads/storm-twitter-word-count-master/target/storm-test-1.0-SNAPSHOT.jar";
    NimbusClient nimbus = new NimbusClient("127.0.0.1",6627);
    // upload topology jar to Cluster using StormSubmitter
    String uploadedJarLocation = StormSubmitter.submitJar(storm_conf,
            inputJar);
    try {
        String jsonConf = JSONValue.toJSONString(storm_conf);
        nimbus.getClient().submitTopology("test1topology",
                uploadedJarLocation, jsonConf, builder.createTopology());
    } catch (AlreadyAliveException ae) {
        ae.printStackTrace();
    } catch (InvalidTopologyException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (TException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}
public static void main(String[] args) 
{   
    load();
    /*SignalClient sc = new SignalClient("localhost:2181", "test-signal-spout");
    sc.start();
    try {
        sc.send("Hello Signal Spout!".getBytes());
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {
        sc.close();
    }*/

}
}

我的pom.xml文件

<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>com.storm</groupId>
    <artifactId>storm-test</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>storm-test</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-compiler-plugin</artifactId>
                <version>2.0.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib/</classpathPrefix>
                            <mainClass>com.storm.PrimeNumberTopology</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>

            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.github.ptgoetz</groupId>
            <artifactId>storm-signals</artifactId>
            <version>0.2.0</version>
        </dependency>
        <dependency>
            <groupId>storm</groupId>
            <artifactId>storm-lib</artifactId>
            <version>0.8.1</version>

            <!-- keep storm out of the jar-with-dependencies <scope>provided</scope> -->
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>github-releases</id>
            <url>http://oss.sonatype.org/content/repositories/github-releases/</url>
        </repository>
        <repository>
            <id>clojars.org</id>
            <url>http://clojars.org/repo</url>
        </repository>
    </repositories>
</project>

我的错误日志文件:

2014-10-26 19:45:19 b.s.d.worker [ERROR] Error on initialization of server mk-worker
java.lang.NoClassDefFoundError: backtype/storm/contrib/signals/spout/BaseSignalSpout
    at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.6.0_32]
    at java.lang.ClassLoader.defineClass(ClassLoader.java:643) ~[na:1.6.0_32]
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.6.0_32]
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:277) ~[na:1.6.0_32]
    at java.net.URLClassLoader.access$000(URLClassLoader.java:73) ~[na:1.6.0_32]
    at java.net.URLClassLoader$1.run(URLClassLoader.java:212) ~[na:1.6.0_32]
    at java.security.AccessController.doPrivileged(Native Method) ~[na:1.6.0_32]
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205) ~[na:1.6.0_32]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:323) ~[na:1.6.0_32]
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) ~[na:1.6.0_32]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:268) ~[na:1.6.0_32]
    at java.lang.Class.forName0(Native Method) ~[na:1.6.0_32]
    at java.lang.Class.forName(Class.java:270) ~[na:1.6.0_32]
    at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:624) ~[na:1.6.0_32]
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1611) ~[na:1.6.0_32]
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1516) ~[na:1.6.0_32]
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1770) ~[na:1.6.0_32]
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1349) ~[na:1.6.0_32]
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369) ~[na:1.6.0_32]
    at backtype.storm.utils.Utils.deserialize(Utils.java:82) ~[storm-core-0.9.1-incubating.jar:0.9.1-incubating]
    at backtype.storm.utils.Utils.getSetComponentObject(Utils.java:218) ~[storm-core-0.9.1-incubating.jar:0.9.1-incubating]
    at backtype.storm.daemon.task$get_task_object.invoke(task.clj:73) ~[storm-core-0.9.1-incubating.jar:0.9.1-incubating]
    at backtype.storm.daemon.task$mk_task_data$fn__3402.invoke(task.clj:180) ~[na:na]
    at backtype.storm.util$assoc_apply_self.invoke(util.clj:792) ~[storm-core-0.9.1-incubating.jar:0.9.1-incubating]
    at backtype.storm.daemon.task$mk_task_data.invoke(task.clj:173) ~[storm-core-0.9.1-incubating.jar:0.9.1-incubating]
    at backtype.storm.daemon.task$mk_task.invoke(task.clj:184) ~[storm-core-0.9.1-incubating.jar:0.9.1-incubating]
    at backtype.storm.daemon.executor$mk_executor$fn__3785.invoke(executor.clj:320) ~[na:na]
    at clojure.core$map$fn__4087.invoke(core.clj:2432) ~[clojure-1.4.0.jar:na]
    at clojure.lang.LazySeq.sval(LazySeq.java:42) ~[clojure-1.4.0.jar:na]
    at clojure.lang.LazySeq.seq(LazySeq.java:60) ~[clojure-1.4.0.jar:na]
    at clojure.lang.RT.seq(RT.java:473) ~[clojure-1.4.0.jar:na]
    at clojure.core$seq.invoke(core.clj:133) ~[clojure-1.4.0.jar:na]
    at clojure.core.protocols$seq_reduce.invoke(protocols.clj:30) ~[clojure-1.4.0.jar:na]
    at clojure.core.protocols$fn__5875.invoke(protocols.clj:54) ~[clojure-1.4.0.jar:na]
    at clojure.core.protocols$fn__5828$G__5823__5841.invoke(protocols.clj:13) ~[clojure-1.4.0.jar:na]
    at clojure.core$reduce.invoke(core.clj:6030) ~[clojure-1.4.0.jar:na]
    at clojure.core$into.invoke(core.clj:6077) ~[clojure-1.4.0.jar:na]
    at backtype.storm.daemon.executor$mk_executor.invoke(executor.clj:320) ~[storm-core-0.9.1-incubating.jar:0.9.1-incubating]
    at backtype.storm.daemon.worker$eval4413$exec_fn__1102__auto____4414$iter__4419__4423$fn__4424.invoke(worker.clj:375) ~[na:na]
    at clojure.lang.LazySeq.sval(LazySeq.java:42) ~[clojure-1.4.0.jar:na]
    at clojure.lang.LazySeq.seq(LazySeq.java:60) ~[clojure-1.4.0.jar:na]
    at clojure.lang.RT.seq(RT.java:473) ~[clojure-1.4.0.jar:na]
    at clojure.core$seq.invoke(core.clj:133) ~[clojure-1.4.0.jar:na]
    at clojure.core$dorun.invoke(core.clj:2725) ~[clojure-1.4.0.jar:na]
    at clojure.core$doall.invoke(core.clj:2741) ~[clojure-1.4.0.jar:na]
    at backtype.storm.daemon.worker$eval4413$exec_fn__1102__auto____4414.invoke(worker.clj:375) ~[na:na]
    at clojure.lang.AFn.applyToHelper(AFn.java:185) ~[clojure-1.4.0.jar:na]
    at clojure.lang.AFn.applyTo(AFn.java:151) ~[clojure-1.4.0.jar:na]
    at clojure.core$apply.invoke(core.clj:601) ~[clojure-1.4.0.jar:na]
    at backtype.storm.daemon.worker$eval4413$mk_worker__4469.doInvoke(worker.clj:344) ~[na:na]
    at clojure.lang.RestFn.invoke(RestFn.java:512) ~[clojure-1.4.0.jar:na]
    at backtype.storm.daemon.worker$_main.invoke(worker.clj:454) ~[storm-core-0.9.1-incubating.jar:0.9.1-incubating]
    at clojure.lang.AFn.applyToHelper(AFn.java:172) ~[clojure-1.4.0.jar:na]
    at clojure.lang.AFn.applyTo(AFn.java:151) ~[clojure-1.4.0.jar:na]
    at backtype.storm.daemon.worker.main(Unknown Source) ~[storm-core-0.9.1-incubating.jar:0.9.1-incubating]
Caused by: java.lang.ClassNotFoundException: backtype.storm.contrib.signals.spout.BaseSignalSpout
    at java.net.URLClassLoader$1.run(URLClassLoader.java:217) ~[na:1.6.0_32]
    at java.security.AccessController.doPrivileged(Native Method) ~[na:1.6.0_32]
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205) ~[na:1.6.0_32]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:323) ~[na:1.6.0_32]
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) ~[na:1.6.0_32]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:268) ~[na:1.6.0_32]
    ... 55 common frames omitted
2014-10-26 19:45:19 b.s.util [INFO] Halting process: ("Error on initialization")

气体更新后新错误:

java.lang.RuntimeException: Fail to construct messaging plugin from plugin backtype.storm.messaging.zmq
    at backtype.storm.messaging.TransportFactory.makeContext(TransportFactory.java:53) ~[storm-core-0.9.1-incubating.jar:0.9.1-incubating]
    at backtype.storm.daemon.worker$worker_data$fn__4263.invoke(worker.clj:185) ~[na:na]
    at backtype.storm.util$assoc_apply_self.invoke(util.clj:792) ~[storm-core-0.9.1-incubating.jar:0.9.1-incubating]
    at backtype.storm.daemon.worker$worker_data.invoke(worker.clj:181) ~[storm-core-0.9.1-incubating.jar:0.9.1-incubating]
    at backtype.storm.daemon.worker$eval4413$exec_fn__1102__auto____4414.invoke(worker.clj:353) ~[na:na]
    at clojure.lang.AFn.applyToHelper(AFn.java:185) ~[clojure-1.4.0.jar:na]
    at clojure.lang.AFn.applyTo(AFn.java:151) ~[clojure-1.4.0.jar:na]
    at clojure.core$apply.invoke(core.clj:601) ~[clojure-1.4.0.jar:na]
    at backtype.storm.daemon.worker$eval4413$mk_worker__4469.doInvoke(worker.clj:344) ~[na:na]
    at clojure.lang.RestFn.invoke(RestFn.java:512) ~[clojure-1.4.0.jar:na]
    at backtype.storm.daemon.worker$_main.invoke(worker.clj:454) ~[storm-core-0.9.1-incubating.jar:0.9.1-incubating]
    at clojure.lang.AFn.applyToHelper(AFn.java:172) ~[clojure-1.4.0.jar:na]
    at clojure.lang.AFn.applyTo(AFn.java:151) ~[clojure-1.4.0.jar:na]
    at backtype.storm.daemon.worker.main(Unknown Source) ~[storm-core-0.9.1-incubating.jar:0.9.1-incubating]
Caused by: java.lang.ClassNotFoundException: backtype.storm.messaging.zmq
    at java.net.URLClassLoader$1.run(URLClassLoader.java:217) ~[na:1.6.0_32]
    at java.security.AccessController.doPrivileged(Native Method) ~[na:1.6.0_32]
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205) ~[na:1.6.0_32]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:323) ~[na:1.6.0_32]
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) ~[na:1.6.0_32]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:268) ~[na:1.6.0_32]
    at java.lang.Class.forName0(Native Method) ~[na:1.6.0_32]
    at java.lang.Class.forName(Class.java:190) ~[na:1.6.0_32]
    at backtype.storm.messaging.TransportFactory.makeContext(TransportFactory.java:38) ~[storm-core-0.9.1-incubating.jar:0.9.1-incubating]
    ... 13 common frames omitted
2014-10-27 02:19:06 b.s.util [INFO] Halting process: ("Error on initialization")
uqjltbpv

uqjltbpv1#

我试过你的密码,
问题是您的jar无法加载库,我在maven文件(pom.xml)中添加了以下内容:

<plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>PrimeNumberTopology</mainClass>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
            </plugin>

然后,您可以阅读pom.xml,我从 jar-with-dependencies (部署jar时,必须将storm lib移除到jar中)

<dependency>
            <groupId>storm</groupId>
            <artifactId>storm-lib</artifactId>
            <version>0.9.0</version>
            <scope>provided</scope> <---- added this,that exclude from the jar-with-dependencies
            <!-- keep storm out of the jar-with-dependencies <scope></scope> -->
        </dependency>

这样,您的jar只包含代码和storm信号jar。
我执行了:

storm jar /Projects/StackTest897/target/storm-test-1.0-SNAPSHOT-jar-with-dependencies.jar PrimeNumberTopology

我用0.9.0更新了storm库,因为我使用的是最新版本,您的代码无法在此处编译:

NimbusClient("127.0.0.1",6627);

只是修复它,或者只是使用你的环境,它应该正常工作。
希望有帮助。

编辑**

是的,这是另一种问题,它取决于您运行的storm版本。
请阅读风暴工人没有开始
或者在这里:
http://mail-archives.apache.org/mod_mbox/storm-user/201405.mbox/%3ccanvthewksfrjuzbph74nu8aur7eoeh38r+kpgpwml5gzvoq7_g@mail.gmail.com%3e

相关问题