Bitcoin Forum

Bitcoin => Project Development => Topic started by: Anonymous on December 13, 2011, 10:15:24 PM



Title: BitcoinJ Simple Error. java.lang.NoClassDefFoundError
Post by: Anonymous on December 13, 2011, 10:15:24 PM


Okay. When running my app that uses the bitcoinj jar file, I run into the following error:
Code:
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at com.google.bitcoin.core.Wallet.<clinit>(Wallet.java:37)
at com.macintosh264.bitcoinproc.BitcoinHandler.openWallet(BitcoinHandler.java:11)
at com.macintosh264.bitcoinproc.Application.loadBitcoin(Application.java:40)
at com.macintosh264.bitcoinproc.Application.launch(Application.java:23)
at com.macintosh264.bitcoinproc.Application.applicationLoop(Application.java:10)
at com.macintosh264.bitcoinproc.BPEMain.main(BPEMain.java:12)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 6 more
And the code I have is this
Code:
package com.macintosh264.bitcoinproc;
import java.io.*;
import com.google.bitcoin.core.Wallet;
import com.google.bitcoin.core.*;
public class BitcoinHandler {
public boolean testnet = false;
public void openWallet(String walletName) {
Wallet wallet;
File walletFile = FileLocationManager.bitcoinFile(walletName, "wallet");
try {
   wallet = Wallet.loadFromFile(walletFile);
} catch (IOException e) {
wallet = new Wallet(this.getParams());
   wallet.keychain.add(new ECKey());
   try {
wallet.saveToFile(walletFile);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}

}
private NetworkParameters getParams() {
return this.testnet ? NetworkParameters.testNet() : NetworkParameters.prodNet();
}
}
And it is called by this
Code:
BitcoinHandler bh = new BitcoinHandler();
bh.testnet = true;
bh.openWallet("wallet");

And one last thing
Code:
File walletFile = FileLocationManager.bitcoinFile(walletName, "wallet");
Is
Code:
return new File("data/bitcoin/" + name + "." + extension);

Thanks,
macintosh264


Title: Re: [1 BTC Bounty] BitcoinJ Simple Error. java.lang.NoClassDefFoundError
Post by: ovidiusoft on December 13, 2011, 10:26:43 PM
You are missing this: http://www.slf4j.org/ . The dependency is documented on the BitcoinJ wiki here: https://code.google.com/p/bitcoinj/wiki/GettingStarted .


Title: Re: [1 BTC Bounty] BitcoinJ Simple Error. java.lang.NoClassDefFoundError
Post by: Anonymous on December 13, 2011, 10:29:18 PM
You are missing this: http://www.slf4j.org/ . The dependency is documented on the BitcoinJ wiki here: https://code.google.com/p/bitcoinj/wiki/GettingStarted .
Thanks! (I didn't even see the wiki  ;D)
What's your address.


Title: Re: [1 BTC Bounty] BitcoinJ Simple Error. java.lang.NoClassDefFoundError
Post by: Anonymous on December 13, 2011, 10:30:56 PM
You are missing this: http://www.slf4j.org/ . The dependency is documented on the BitcoinJ wiki here: https://code.google.com/p/bitcoinj/wiki/GettingStarted .
How do I add this to my eclipse project.


Title: Re: BitcoinJ Simple Error. java.lang.NoClassDefFoundError
Post by: ovidiusoft on December 13, 2011, 10:34:35 PM
PM'ed my address. I am sorry, I don't know Eclipse that well, I think there is a Maven plugin for it, but not much more.


Title: Re: BitcoinJ Simple Error. java.lang.NoClassDefFoundError
Post by: ovidiusoft on December 13, 2011, 10:36:46 PM
I have received the bounty from OP. Thank you!


Title: Re: BitcoinJ Simple Error. java.lang.NoClassDefFoundError
Post by: Anonymous on December 13, 2011, 10:42:01 PM
Okay, now one more problem.

org.bouncycastle.util.encoders.Hex is missing. Where do I get that?


Title: Re: BitcoinJ Simple Error. java.lang.NoClassDefFoundError
Post by: ovidiusoft on December 13, 2011, 10:52:56 PM
I think it's here: http://www.bouncycastle.org/ . But you should probably use Maven to install any other dependencies.