quickml icon indicating copy to clipboard operation
quickml copied to clipboard

java.lang.NoClassDefFoundError: com/twitter/common/util/Random$Util

Open ymahdad opened this issue 9 years ago • 4 comments

I've tried building and trying it in different ways but always I face this error: Exception in thread "main" java.lang.NoClassDefFoundError: com/twitter/common/util/Random$Util at quickml.supervised.classifier.decisionTree.TreeBuilder.(TreeBuilder.java:52) at quickml.supervised.classifier.decisionTree.TreeBuilder.(TreeBuilder.java:69)

The line giving me error is this one: TreeBuilder treeBuilder = new TreeBuilder();

Can I ask to make the built version (jar with all dependencies) available. I have all the dependencies in the path but still get the same error on Mac Yomesite with Java 1.8.

ymahdad avatar Mar 23 '15 17:03 ymahdad

Hi, are you using Maven or Gradle for dependency management? If not I would recommend it.

Otherwise, you should be able to use Maven to build a jar including all dependencies with: "mvn assembly:assembly".

sanity avatar Mar 23 '15 22:03 sanity

Thanks. The problem was in Java 8. Basically in Java 8, by default DocLint is activated and checks for many things including @param and @return and will give error and will not build successfully. The solution will be adding this to the maven-javadoc-plugin:

                    <configuration>
                    <additionalparam>-Xdoclint:none</additionalparam>
                </configuration>

This will remove those checks and build successfully.

ymahdad avatar Mar 23 '15 23:03 ymahdad

Hi,

I'm working with Java 1.7 and I'm getting the same problem even including "-Xdoclint:none" configuration to the pom.xml file. I've created a .jar file with all dependencies of quikml and when I execute this command RandomDecisionForest randomForestModel = randomForestBuilder .buildPredictiveModel(instances); I obtain the error "java.lang.NoClassDefFoundError: com/twitter/common/util/Random$Utils "

Maven command to obtain quickml-0.10.9-jar-with-dependencies.jar: mvn clean compile assembly:assembly

pom.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
     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>quickml</groupId>
<artifactId>quickml</artifactId>

1)  Use Semantic Versioning - MAJOR.MINOR.PATCH. Note that versions starting 
    with 0.x.x are considered pre-release, ie. 0.MAJOR.MINOR.

    MAJOR: A breaking (ie. backwards-incompatible) change to the public API of the library
           eg. Removing or modifying a public or protected method in a class
    MINOR: A backwards-compatible change to the public API
           eg. Adding a new method to a class, or adding a new class
    PATCH: An improvement that doesn't affect the public API
           eg. A refactor, performance improvement, or bugfix

    We won't go to 1.x.x until we have a high degree of confidence that
    future backwards-compatible changes to the API will be rare.

    Please read http://semver.org/ if you haven't already.

2)  When you increase the version you must create a new Github release for this
    version.  This will trigger an automatic regeneration of the Maven repository
    using the http://jitpack.io/ service.

3)  Note that the index.html page on http://quickml.org/ should update the version
    automatically when a new release is created.

4)  *ANY* change to the master branch (ie. when a feature branch is merged) must
    be accompanied by a bump in version number, regardless of how minor the change.


<version> 0.10.9</version>

<properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <additionalparam>-Xdoclint:none</additionalparam>
</properties>
<repositories>
    <repository>
        <id>sanity-maven-repo</id>
        <name>Sanity's Maven repository on GitHub</name>
        <url>http://sanity.github.com/maven-repo/repository/</url>
    </repository>
    <repository>
        <id>twitter</id>
        <name>twitter</name>
        <url>http://maven.twttr.com</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>net.sf.supercsv</groupId>
        <artifactId>super-csv</artifactId>
        <version>2.2.0</version>
    </dependency>
    <dependency>
        <groupId>net.sf.opencsv</groupId>
        <artifactId>opencsv</artifactId>
        <version>2.3</version>
    </dependency>
    <dependency>
        <groupId>it.unimi.dsi</groupId>
        <artifactId>fastutil</artifactId>
        <version>7.0.7</version>
    </dependency>
    <dependency>
        <groupId>jfree</groupId>
        <artifactId>jfreechart</artifactId>
        <version>1.0.12</version>
    </dependency>
    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk</artifactId>
        <version>1.0.002</version>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-math3</artifactId>
        <version>3.3</version>
    </dependency>
    <dependency>
        <groupId>com.twitter.common</groupId>
        <artifactId>stats-util</artifactId>
        <version>0.0.15</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.6</version>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-core</artifactId>
        <version>1.1.1</version>
    </dependency>
    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-all</artifactId>
        <version>1.9.5</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.1.1</version>
    </dependency>
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>15.0</version>
    </dependency>
    <dependency>
        <groupId>org.javatuples</groupId>
        <artifactId>javatuples</artifactId>
        <version>1.2</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.8.7</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.googlecode.json-simple</groupId>
        <artifactId>json-simple</artifactId>
        <version>1.1.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.3</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
        <version>2.7</version>
    </dependency>
    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-library</artifactId>
        <version>1.3</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.hamcrest</groupId>
                <artifactId>hamcrest-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.16</version>
            <configuration>
                <argLine>-Xmx256M</argLine>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <executions>
                <execution>
                    <id>attach-sources</id>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <executions>
                <execution>
                    <id>attach-javadocs</id>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>cobertura-maven-plugin</artifactId>
              <version>2.7</version>
              <configuration>
                      <format>xml</format>
                      <maxmem>256m</maxmem>
                      <!-- aggregated reports for multi-module projects -->
                      <aggregate>true</aggregate>
              </configuration>
        </plugin>
        <plugin>
              <groupId>org.eluder.coveralls</groupId>
                  <artifactId>coveralls-maven-plugin</artifactId>
                  <version>4.1.0</version>
        </plugin>
    </plugins>
</build>
`

NachoPF avatar Apr 14 '16 11:04 NachoPF

I ran assemble and the required library doesn't appear to exist on either maven central or jitpack anymore: screen shot 2016-06-04 at 4 23 25 pm

brian-murphy avatar Jun 04 '16 20:06 brian-murphy