Numenta - htm.java-examples - Ubuntu - Eclipse - NetworkAPIDemo - NoClassDefFoundError:no / uib / cipr / matrix / sparse / FlexCompRowMatrix

时间:2017-05-23 10:39:55

标签: eclipse maven nupic

我在尝试参考htm.java-examples尝试运行NetworkAPIDemo示例时遇到问题 如果我尝试运行代码,我会收到错误:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.lang.NoClassDefFoundError: no/uib/cipr/matrix/sparse/FlexCompRowMatrix
    at org.numenta.nupic.algorithms.SDRClassifier.<init>(SDRClassifier.java:180)
    at org.numenta.nupic.algorithms.SDRClassifier.<init>(SDRClassifier.java:159)
    at org.numenta.nupic.network.Layer.makeClassifiers(Layer.java:1947)
    at org.numenta.nupic.network.Layer.close(Layer.java:504)
    at org.numenta.nupic.network.Region.close(Region.java:199)
    at org.numenta.nupic.network.Region.observe(Region.java:315)
    at org.numenta.nupic.network.Network.observe(Network.java:535)
    at Intro2.NetworkAPIDemo.<init>(NetworkAPIDemo.java:66)
    at Intro2.NetworkAPIDemo.main(NetworkAPIDemo.java:242)
Caused by: java.lang.ClassNotFoundException: no.uib.cipr.matrix.sparse.FlexCompRowMatrix
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 9 more

如果我将依赖项添加到POM文件:

com.googlecode.matrix-toolkits-java.mtj.1.0.2

我收到错误:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "Sensor Layer [Region 1:Layer 5] Thread" java.lang.NoSuchMethodError: no.uib.cipr.matrix.sparse.FlexCompRowMatrix.addCol([D)V
    at org.numenta.nupic.algorithms.SDRClassifier.compute(SDRClassifier.java:280)
    at org.numenta.nupic.network.Layer$FunctionFactory$3.call(Layer.java:2372)
    at org.numenta.nupic.network.Layer$FunctionFactory$3.call(Layer.java:2345)
    at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:55)
    at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:55)
    at rx.internal.operators.OperatorFilter$1.onNext(OperatorFilter.java:54)
    at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:55)
    at rx.internal.operators.OperatorCast$1.onNext(OperatorCast.java:50)
    at rx.internal.operators.OperatorFilter$1.onNext(OperatorFilter.java:54)
    at rx.subjects.SubjectSubscriptionManager$SubjectObserver.onNext(SubjectSubscriptionManager.java:224)
    at rx.subjects.PublishSubject.onNext(PublishSubject.java:114)
    at org.numenta.nupic.network.Layer.compute(Layer.java:956)
    at org.numenta.nupic.network.Region$2.onNext(Region.java:653)
    at org.numenta.nupic.network.Region$2.onNext(Region.java:646)
    at org.numenta.nupic.network.Layer$3.onNext(Layer.java:1863)
    at org.numenta.nupic.network.Layer$3.onNext(Layer.java:1843)
    at rx.Observable$33.onNext(Observable.java:7480)
    at rx.observers.SafeSubscriber.onNext(SafeSubscriber.java:130)
    at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:55)
    at rx.internal.operators.OperatorFilter$1.onNext(OperatorFilter.java:54)
    at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:55)
    at rx.internal.operators.OperatorCast$1.onNext(OperatorCast.java:50)
    at rx.internal.operators.OperatorFilter$1.onNext(OperatorFilter.java:54)
    at rx.subjects.SubjectSubscriptionManager$SubjectObserver.onNext(SubjectSubscriptionManager.java:224)
    at rx.subjects.PublishSubject.onNext(PublishSubject.java:114)
    at org.numenta.nupic.network.Layer.compute(Layer.java:956)
    at org.numenta.nupic.network.Region$2.onNext(Region.java:653)
    at org.numenta.nupic.network.Region$2.onNext(Region.java:646)
    at org.numenta.nupic.network.Layer$3.onNext(Layer.java:1863)
    at org.numenta.nupic.network.Layer$3.onNext(Layer.java:1843)
    at rx.Observable$33.onNext(Observable.java:7480)
    at rx.observers.SafeSubscriber.onNext(SafeSubscriber.java:130)
    at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:55)
    at rx.internal.operators.OperatorFilter$1.onNext(OperatorFilter.java:54)
    at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:55)
    at rx.internal.operators.OperatorCast$1.onNext(OperatorCast.java:50)
    at rx.internal.operators.OperatorFilter$1.onNext(OperatorFilter.java:54)
    at rx.subjects.SubjectSubscriptionManager$SubjectObserver.onNext(SubjectSubscriptionManager.java:224)
    at rx.subjects.PublishSubject.onNext(PublishSubject.java:114)
    at org.numenta.nupic.network.Layer.compute(Layer.java:956)
    at org.numenta.nupic.network.Layer$5.lambda$run$1(Layer.java:2039)
    at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
    at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
    at java.util.Iterator.forEachRemaining(Iterator.java:116)
    at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
    at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
    at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
    at org.numenta.nupic.network.Layer$5.run(Layer.java:2036)
Caused by: rx.exceptions.OnErrorThrowable$OnNextValue: OnError while emitting onNext value: org.numenta.nupic.network.ManualInput.class
    at rx.exceptions.OnErrorThrowable.addValueAsLastCause(OnErrorThrowable.java:101)
    at rx.internal.operators.OperatorFilter$1.onNext(OperatorFilter.java:60)
    ... 46 more
Caused by: rx.exceptions.OnErrorThrowable$OnNextValue: OnError while emitting onNext value: [I.class
    at rx.exceptions.OnErrorThrowable.addValueAsLastCause(OnErrorThrowable.java:101)
    at rx.internal.operators.OperatorCast$1.onNext(OperatorCast.java:52)
    ... 16 more

我也遇到了openjdk1.8和oracle_jdk1.8的问题。

com.googlecode.matrix-toolkits-java.mtj.1.0.2可以在.m2文件夹中找到(我使用Maven和Eclipse)。

我尝试在两台计算机上运行它,它与其中一台计算机一起使用,但是相同的代码不适用于另一台计算机。我没有使用Cortico示例,因此外部库不应该导致任何问题。在POM文件中,我只指定依赖项

org.numenta.htm.java.0.6.13

如果我添加外部库(可以在 libs 文件夹中找到),我会收到错误:

Exception in thread "main" java.lang.NoSuchMethodError: org.numenta.nupic.Parameters.set(Lorg/numenta/nupic/Parameters$KEY;Ljava/lang/Object;)V
    at Intro2.NetworkDemoHarness.getParameters(NetworkDemoHarness.java:211)
    at Intro2.NetworkAPIDemo.createMultiLayerNetwork(NetworkAPIDemo.java:105)
    at Intro2.NetworkAPIDemo.<init>(NetworkAPIDemo.java:62)
    at Intro2.NetworkAPIDemo.main(NetworkAPIDemo.java:242)

我没有从源代码构建项目,我只在POM.xml文件中指定了依赖项。 org.numenta.htm.java.0.6.12可以在.m2文件夹中找到。我尝试使用0.6.13版本的htm.java,但遇到了同样的问题。

POM.xml包括:

  • 将maven编译器指定为java 1.8

  • 指定htm.java依赖

我正在使用Ubuntu 16.04和Java:

java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

运行:

mvn clean install

成功,有两个警告和一个错误:

[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[ERROR] error reading /home/szi/.m2/repository/algorithmfoundry/algorithmfoundry-shade-culled/1.3/algorithmfoundry-shade-culled-1.3.jar; invalid LOC header (bad signature)
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!

运行:

mvn -e exec:java -Dexec.mainClass="/home/szi/Documents/Eclipse/Java/HTM/src/main/java/Intro2/NetworkAPIDemo.java"

给出错误:

[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building HTM.Intro 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- exec-maven-plugin:1.6.0:java (default-cli) @ HTM.Intro ---
[WARNING] 
java.lang.ClassNotFoundException: /home/szi/Documents/Eclipse/Java/HTM/src/main/java/Intro2/NetworkAPIDemo.java
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:270)
    at java.lang.Thread.run(Thread.java:748)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.990 s
[INFO] Finished at: 2017-05-23T12:03:37+02:00
[INFO] Final Memory: 12M/303M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default-cli) on project HTM.Intro: An exception occured while executing the Java class. /home/szi/Documents/Eclipse/Java/HTM/src/main/java/Intro2/NetworkAPIDemo.java -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default-cli) on project HTM.Intro: An exception occured while executing the Java class. /home/szi/Documents/Eclipse/Java/HTM/src/main/java/Intro2/NetworkAPIDemo.java
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: An exception occured while executing the Java class. /home/szi/Documents/Eclipse/Java/HTM/src/main/java/Intro2/NetworkAPIDemo.java
    at org.codehaus.mojo.exec.ExecJavaMojo.execute(ExecJavaMojo.java:339)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    ... 20 more
Caused by: java.lang.ClassNotFoundException: /home/szi/Documents/Eclipse/Java/HTM/src/main/java/Intro2/NetworkAPIDemo.java
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:270)
    at java.lang.Thread.run(Thread.java:748)
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

有人可以就可能出现的问题向我提出建议吗?我在没有修改的情况下从github存储库中复制粘贴代码。

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

问题解决了!

如果有人遇到同样的问题,您应该将库algorithmfoundry-shade-culled-1.3.jar添加到您的项目中。