Ubuntu - Eclipse - NetworkAPIDemo - NoClassDefFoundError: no/uib/cipr/matrix/sparse/FlexCompRowMatrix

question
nupic-wiki
#1

Dear All,
I am facing problems, while trying to run the NetworkAPIDemo example with reference to the htm.java-examples
If I try to run the code, I get the error:

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

If I add the dependency to the POM file:

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

I get the error:

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

I encountered the problem with both openjdk1.8 and oracle_jdk1.8 as well.

com.googlecode.matrix-toolkits-java.mtj.1.0.2 can be found in the .m2 folder (I’m using Maven with Eclipse).

I tried running it on two computers, it worked with one of the computers, but the same code did not work with another computer. I did not bother with the Cortico examples, so external libraries should not cause any problem. In the POM file, I specify only the dependency org.numenta.htm.java.0.6.13

If I add the external libraries (which can be found in the libs folder), I get the error:

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)

I did not build the project from source, I only specified the dependencies in the POM.xml File. org.numenta.htm.java.0.6.12 can be found in the .m2 folder. I tried using 0.6.13 version of htm.java, but encountered the same problem.
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>HTM.Intro</groupId>
  <artifactId>HTM.Intro</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  
<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
 </properties>

 <dependencies>
  <dependency>
    <groupId>org.numenta</groupId>
    <artifactId>htm.java</artifactId>
    <version>0.6.12</version>
  </dependency>
 </dependencies>
 
</project>

I am using Ubuntu 16.04 with 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)

Can someone please give me an advice on what can be wrong? I copy-pasted the code from the github repository without modification.

Thank you for any help!

1 Like

#2
mvn clean install

is successful with two warnings and 1 error:

[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!
0 Likes

#3

Running:

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

Gives the error:

[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

0 Likes

#4

Hi @szingerpeter,

I’ve seen your issues in the GitHub repos, I’m sorry I haven’t responded - I’m in the middle of a software release and I’ve been in extreme, have-my-head-down mode! :slight_smile:

First, I don’t really have the familiarity to support Maven, and while the configuration is supplied, it’s really not supported in the project because of this… Though Maven is a black hole that is almost impossible to escape (we use it to execute the Coverage Analysis and a couple of other inescapable features).

Anyway, I’ll do my best though usage of Gradle is recommended.

There’s a couple of things going on here. One, is that there’s an “enhanced” MTJ library that is used for the project and it is served by my server in a custom repo (seen by the pom directive below)

    <repositories>
		<repository>
			<id>repo</id>
			<name>htm.java</name>
			<url>http://metaware.us/maven3</url>  <-- HERE
		</repository>
	</repositories>

It’s possible that on your computer(s), you have something in settings.xml that is preventing that repository from being recognized?

Secondly as mentioned, the dependency: com.googlecode.matrix-toolkits-java.mtj.1.0.2 will not work because it doesn’t contain our library enhancements for adding and removing sparse columns and rows. Anyway, instead of that library, try adding the jar from the “libs” directory: algorithmfoundry-shade-culled-1.3.jar.

That should work for you…

Let me know how it works out?

Cheers,
David

2 Likes

#5

David, I appreciate you taking time out of your schedule to answer questions. :blush:

1 Like

#6

As always, it’s a labor of love. I just can’t respond as promptly as I would like at the moment…

0 Likes

#7

Thank you very much for your help!

I did not know which forum is the more active one, so I just tried to reach as many people on as many channels as possible, maybe someone has encountered the same problem.
You were right, adding the library: algorithmfoundry-shade-culled-1.3.jar solved all my problem.

Appreciate all your effort all the team is putting into this project.

Good luck,
Péter

2 Likes