Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Trying to solve runtime errors so I can run a MediaWiki bot that depends on the Java Wiki Bot Framework (JWBF)

#Goal: be able to do development work on JWBF on my computer.

I'm finishing up my internship project by adding a search feature to JWBF. To do this, I need to be able to do Java development on my computer, and I need to be able to write test bots that depend on JWBF. I have tried to write and run a very basic JWBF-based bot. It compiles, but I get persistent runtime errors when I try to run it with $ java and I have not been able to use the Maven exec plugin for even a HelloWorld program. The JWBF project uses JDK 1.7 and Maven for dependency management, so "don't use Maven" is not an option for me.

##Tools: Maven:

$ mvn -version
Apache Maven 3.0.5
Maven home: /usr/share/maven
Java version: 1.7.0_55, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.16.0-031600rc2-generic", arch: "amd64", family: "unix"

Java:

$ java -version
java version "1.7.0_55"
OpenJDK Runtime Environment (IcedTea 2.4.7) (7u55-2.4.7-1ubuntu1)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)

##Obstacles:

  • Haven't developed anything with Java in ~10 y
  • Never run a Java program on Ubuntu (at least, not from the command line or from a .java file I've compiled
  • Inexperience with Maven (mvn)
  • No experience setting up Java on Ubuntu or getting it to work with Maven
  • Unfamiliar with Maven's local repository (was not sure where it was located, even)

##Plan to address obstacles and learn relevant skills:

  • Start, write, compile, and run HelloWorld.java as a Maven project
  • Get the query-related portions of the sample code on the JWBF README working in another Maven project. (Include JWBF in the <dependencies /> section of pom.xml.)
  • Add login and edit functions to the sample code and test it in the mediawiki.org sandbox page

##Once I can write, compile, and run a simple program that depends on JWBF:

  • Add a search class to JWBF and write programs to test the overall behavior as I go.

##Accomplishments and blockers:

###Step 1, write/compile/run HelloJava.java

  • Successfully wrote HelloJava.java, using a Maven project: mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
  • Compiled using mvn install
  • Looked up how to run a compiled Maven project.
  • Considered using the exec plugin to run it. Followed the instructions here: http://mojo.codehaus.org/exec-maven-plugin/usage.html
  • With the following statement included in pom.xml:
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.3.2</version>
        <executions>
          <execution>
            <goals>
              <goal>exec</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <executable>maven</executable>
        </configuration>
      </plugin>
    </plugins>
  </build>

Ran mvn install; BUILD SUCCESS resulted. Then ran mvn exec:exec with the following result:

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.3.2:exec (default-cli) on project my-app: Command execution failed. Cannot run program "maven" (in directory "/home/fhocutt/Desktop/helloJava/my-app"): error=2, No such file or directory -> [Help 1]

After I changed from maven to mvn in pom.xml:

  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.3.2</version>
        <executions>
          <execution>
            <goals>
              <goal>exec</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <executable>mvn</executable>
        </configuration>
      </plugin>
    </plugins>
  </build>

the result was:

[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
...
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.3.2:exec (default-cli) on project my-app: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]
```.

Searching these errors did not yield obviously useful answers.

*  Instead of using mvn exec:exec, ran with `$ java -cp target/my-app-1.0-SNAPSHOT.jar com.mycompany.app.HelloJava`. Program printed "Hello, Java!" to stdout. 

### Step 2, get the JWBF sample code query running in a Java program

* Copied the sample code to a main class and tried to compile:
```java
public class JavaBot {

/** 
 * Sample bot that retrieves and edits an article. 
 * Sample code from the JWBF README. 
 */
  public static void main(String[] args) {
    System.out.println("Hello JWBF!");
    MediaWikiBot wikiBot = new MediaWikiBot("https://en.wikipedia.org/w/");
    Article article = wikiBot.getArticle("42");
    System.out.println(article.getText().substring(5, 42));
    // HITCHHIKER'S GUIDE TO THE GALAXY FANS
//    applyChangesTo(article);
//    wikiBot.login("user", "***");
//    article.save();
  }
}
  • Added the correct import statements:
import net.sourceforge.jwbf.mediawiki.bots.MediaWikiBot;
import net.sourceforge.jwbf.core.contentRep.Article;

Using wildcards here is tricky, but the complete path works.

With that, mvn install runs successfully. Code is available here: https://github.com/fhocutt/jwbf-test

Current problem: cannot run JavaBot

First, I tried using the exec plugin to enable Maven to run as well as build the program.

With pom.xml containing:

  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.3.2</version>
        <executions>
          <execution>

            <goals>
              <goal>exec</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <executable>mvn</executable>
          <workingDirectory>/home/fhocutt/Desktop/jwbf-test-app/jwbf-test/</workingDirectory>
          <arguments>
            <argument>-X</argument>
            <argument>-classpath</argument>
          </arguments>
        </configuration>
      </plugin>
    </plugins>
  </build>

I run mvn exec:exec and get the following result:

[ERROR] Unknown lifecycle phase "lasspath". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-site, site, post-site, site-deploy, pre-clean, clean, post-clean. -> [Help 1]
org.apache.maven.lifecycle.LifecyclePhaseNotFoundException: Unknown lifecycle phase "lasspath". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-site, site, post-site, site-deploy, pre-clean, clean, post-clean.
	at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateLifecycleMappings(DefaultLifecycleExecutionPlanCalculator.java:222)
	at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateMojoExecutions(DefaultLifecycleExecutionPlanCalculator.java:193)
	at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateExecutionPlan(DefaultLifecycleExecutionPlanCalculator.java:112)
	at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateExecutionPlan(DefaultLifecycleExecutionPlanCalculator.java:129)
	at org.apache.maven.lifecycle.internal.BuilderCommon.resolveBuildPlan(BuilderCommon.java:92)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	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)
[ERROR] 
[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/LifecyclePhaseNotFoundException
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.021s
[INFO] Finished at: Wed Aug 13 17:41:59 PDT 2014
[INFO] Final Memory: 8M/213M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.3.2:exec (default-cli) on project jwbf-test: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]

Without <argument>-classpath</argument> in pom.xml, the result is:

[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-site, site, post-site, site-deploy, pre-clean, clean, post-clean. -> [Help 1]
org.apache.maven.lifecycle.NoGoalSpecifiedException: No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-site, site, post-site, site-deploy, pre-clean, clean, post-clean.
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:104)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	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)
[ERROR] 
[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/NoGoalSpecifiedException
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.784s
[INFO] Finished at: Wed Aug 13 17:50:19 PDT 2014
[INFO] Final Memory: 7M/150M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.3.2:exec (default-cli) on project jwbf-test: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]

There is clearly something odd going on with Maven wanting a lifecycle phase, but when I try mvn exec:exec install I get the following:

[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-site, site, post-site, site-deploy, pre-clean, clean, post-clean. -> [Help 1]
org.apache.maven.lifecycle.NoGoalSpecifiedException: No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-site, site, post-site, site-deploy, pre-clean, clean, post-clean.
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:104)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	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)
[ERROR] 
[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/NoGoalSpecifiedException
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.566s
[INFO] Finished at: Wed Aug 13 17:51:30 PDT 2014
[INFO] Final Memory: 7M/150M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.3.2:exec (default-cli) on project jwbf-test: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]

When I try mvn install exec:exec, this results:

[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-site, site, post-site, site-deploy, pre-clean, clean, post-clean. -> [Help 1]
org.apache.maven.lifecycle.NoGoalSpecifiedException: No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-site, site, post-site, site-deploy, pre-clean, clean, post-clean.
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:104)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	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)
[ERROR] 
[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/NoGoalSpecifiedException
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.325s
[INFO] Finished at: Wed Aug 13 17:53:11 PDT 2014
[INFO] Final Memory: 10M/216M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.3.2:exec (default-cli) on project jwbf-test: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]

I also tried running JavaBot with $ java -cp [classpaths] [target] as I had for HelloJava previously (after mvn install). This was more complicated because of the JWBF dependency and its internal dependencies.

If the classpath does not lead precisely to the .jar of the JWBF dependency, the following runtime error will occur:

Exception in thread "main" java.lang.NoClassDefFoundError: net/sourceforge/jwbf/mediawiki/bots/MediaWikiBot
	at opw.jwbf.app.JavaBot.main(JavaBot.java:14)
Caused by: java.lang.ClassNotFoundException: net.sourceforge.jwbf.mediawiki.bots.MediaWikiBot
	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

This command includes the correct classpath for JWBF:

$ java -cp "target/jwbf-test-1.0-SNAPSHOT.jar:/home/fhocutt/.m2/repository/net/sourceforge/jwbf/3.0.0-SNAPSHOT/jwbf-3.0.0-SNAPSHOT.jar" opw.jwbf.app.JavaBot

The resulting error is now:

Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
	at net.sourceforge.jwbf.mediawiki.bots.MediaWikiBot.<clinit>(MediaWikiBot.java:54)
	at opw.jwbf.app.JavaBot.main(JavaBot.java:14)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	... 2 more

Relevant parts of the output of the above with -verbose added:

[Loaded net.sourceforge.jwbf.core.bots.WikiBot from file:/home/fhocutt/.m2/repository/net/sourceforge/jwbf/3.0.0-SNAPSHOT/jwbf-3.0.0-SNAPSHOT.jar]
[Loaded net.sourceforge.jwbf.mediawiki.bots.MediaWikiBot from file:/home/fhocutt/.m2/repository/net/sourceforge/jwbf/3.0.0-SNAPSHOT/jwbf-3.0.0-SNAPSHOT.jar]
[Loaded net.sourceforge.jwbf.core.actions.ReturningTextProcessor from file:/home/fhocutt/.m2/repository/net/sourceforge/jwbf/3.0.0-SNAPSHOT/jwbf-3.0.0-SNAPSHOT.jar]
[Loaded net.sourceforge.jwbf.core.actions.ContentProcessable from file:/home/fhocutt/.m2/repository/net/sourceforge/jwbf/3.0.0-SNAPSHOT/jwbf-3.0.0-SNAPSHOT.jar]
[Loaded java.lang.IllegalStateException from /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rt.jar]
[Loaded net.sourceforge.jwbf.core.bots.util.JwbfException from file:/home/fhocutt/.m2/repository/net/sourceforge/jwbf/3.0.0-SNAPSHOT/jwbf-3.0.0-SNAPSHOT.jar]
[Loaded net.sourceforge.jwbf.core.actions.util.ActionException from file:/home/fhocutt/.m2/repository/net/sourceforge/jwbf/3.0.0-SNAPSHOT/jwbf-3.0.0-SNAPSHOT.jar]
[Loaded java.lang.InstantiationException from /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rt.jar]
[Loaded java.lang.IllegalAccessException from /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rt.jar]
Exception in thread "main" [Loaded java.lang.Throwable$PrintStreamOrWriter from /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rt.jar]
[Loaded java.lang.Throwable$WrappedPrintStream from /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rt.jar]
[Loaded java.util.IdentityHashMap from /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rt.jar]
[Loaded java.util.IdentityHashMap$KeySet from /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rt.jar]
java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
	at net.sourceforge.jwbf.mediawiki.bots.MediaWikiBot.<clinit>(MediaWikiBot.java:54)
	at opw.jwbf.app.JavaBot.main(JavaBot.java:14)
[Loaded java.util.Objects from /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rt.jar]
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	... 2 more

Because it is looking for org/slf4j/LoggerFactory, I looked in the Maven repository. There are several subfolders in the slf4j/ folder and no LoggerFactory:

me@me:~/.m2/repository$ ls org/slf4j/
jcl-over-slf4j  slf4j-api  slf4j-jdk14  slf4j-parent

I'm stumped with this method too.

###Other suggestions I have received include:

You are close. Definitely there's a simpler way, but try with

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.7.7</version>
        </dependency>

added to the dependencies. I'm new to Java too.
Also, Loki added clues how to do it right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment