bouncycastle Operator Creation Exception in Java
AnsweredI'm working on a simple automated java program and am trying to use json. I've borrowed the first part of the checkstyle sample code from https://github.com/box/box-java-sdk/blob/master/src/example/java/com/box/sdk/example/SearchExamplesAsAppUser.java figuring it should work. When I run it, I get a"java.lang.NoClassDefFoundError: org/bouncycastle/operator/OperatorCreationException" error. The problem seems to be stemming from the statement:
api = BoxDeveloperEditionAPIConnection.getAppUserConnection(USER_ID, boxConfig, accessTokenCache);
The Jars which I am using are:
bcpkix-jdk15on-1.52.jar
bcprov-jdk15on-1.52.jar
box-java-sdk-2.14.1.jar
jose4j-0.4.4.jar
minimal-json-0.9.1.jar
commons-codec-1.9.jar
commons-httpclient-3.1.jar
commons-logging-1.2.jar
The full cod
package boxapitest;
import com.box.sdk.BoxAPIConnection;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.box.sdk.BoxConfig;
import com.box.sdk.BoxDeveloperEditionAPIConnection;
import com.box.sdk.BoxItem;
import com.box.sdk.BoxMetadataFilter;
import com.box.sdk.BoxSearch;
import com.box.sdk.BoxSearchParameters;
import com.box.sdk.BoxUser;
import com.box.sdk.DateRange;
import com.box.sdk.IAccessTokenCache;
import com.box.sdk.InMemoryLRUAccessTokenCache;
import com.box.sdk.PartialCollection;
import com.box.sdk.SizeRange;
public final class BoxAPITest {
private static final String USER_ID = "***email address removed for privacy***";
private static final int MAX_DEPTH = 1;
private static final int MAX_CACHE_ENTRIES = 100;
private static BoxDeveloperEditionAPIConnection api;
/**
* args the command line arguments
* @throws java.io.IOException
*/
public static void main(String[] args) throws IOException {
// Turn off logging to prevent polluting the output.
Logger.getLogger("com.box.sdk").setLevel(Level.SEVERE);
//It is a best practice to use an access token cache to prevent unneeded requests to Box for access tokens.
//For production applications it is recommended to use a distributed cache like Memcached or Redis, and to
//implement IAccessTokenCache to store and retrieve access tokens appropriately for your environment.
IAccessTokenCache accessTokenCache = new InMemoryLRUAccessTokenCache(MAX_CACHE_ENTRIES);
Reader reader;
reader = new FileReader("\\Users\\saulf\\OneDrive\\FreeLance\\LandC\\Dev\\42916875_tuino6dd_config_BoxKeyHomePC.json");
BoxConfig boxConfig = BoxConfig.readFrom(reader);
api = BoxDeveloperEditionAPIConnection.getAppUserConnection(USER_ID, boxConfig, accessTokenCache);
//api = BoxAPIConnection.getAppUserConnection(USER_ID, boxConfig, accessTokenCache);
BoxUser.Info userInfo = BoxUser.getCurrentUser(api).getInfo();
System.out.format("Welcome, %s!\n\n", userInfo.getName());
}
}
e follows, any suggestions would be most appreciated.
-
The "java.lang.NoClassDefFoundError: org/bouncycastle/operator/OperatorCreationException" error may be because your program can't resolve the contents of the BounceCastle jars — this appears to be a runtime exception with trying to load their classes. How are you loading or including them in your project?
-
The code I have was developed in Netbeans. In netbeans, I've added the jars to the list of jars to be included during compilation. I've attached a picture for reference. It seems odd since I have used these jars before to run code with just a developer token. I'm wondering if somehow the real failure is related to the json file, but I'm not sure how to check. I have confirmed that the file is being recognized by changing the actual file name without changing the code (which then prompted an run-time error).
-
Marking this as done. Was able to troubleshoot and determine that one of my jars was corrupt. The good news is that this error was eliminated. The bad news is that I have a new error -- it's not emanating from the same jar. If I can;t figure it out, I'll be posting again.
Thanks all!
-
Facing same issue
java.lang.NoClassDefFoundError: org/bouncycastle/operator/OperatorCreationException
included the dependencies during runtime:
runtime files('./lib/jose4j-0.9.3.jar')
runtime files('./lib/bcprov-jdk15on-1.70.jar')
runtime files('./lib/bcutil-jdk15on-1.70.jar')Let me know if anyone know the solution for this.
Please sign in to leave a comment.
Comments
4 comments