Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Eclipse - java.lang.NoClassDefFoundError: com/sleepycat/je/DatabaseException




On Sep 28, 2008, at 5:57 AM, Guillermo Acilu wrote:

Hello guys,

I am having a problem testing an small Java code to be used with Berkeley DB Java Edition. I have created a Java Project, then I've created a package and inside of this package I've created a class with the following code:

package com.x2iq.iqSearchDB;

import com.sleepycat.je.DatabaseException;
import com.sleepycat.je.Environment;
import com.sleepycat.je.EnvironmentConfig;
import java.io.File;

public class SentencesDB {

	private Environment myDbEnvironment;
	private String db_Base;
	private String sentence;
	private String root;
	private int times;
	private int total_level;
	private int min_level;
	private int max_level;
	private int last_level;
	private int bottom_node;
	
	public SentencesDB() {
		
		myDbEnvironment = null;
		db_Base = "/usr/local/";
	}

public void openDB() {
try {
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setAllowCreate(true);
myDbEnvironment = new Environment(new File("/usr/local/ iq_data"), envConfig);
} catch (DatabaseException dbe) {
// Exception handling goes here
}
}

public void closeDB() {
try {
if (myDbEnvironment != null) {
myDbEnvironment.close();
}
} catch (DatabaseException dbe) {
// Exception handling goes here
}
}
}


Then I try to test it in the scrapbook with the following code:


SentencesDB db = new SentencesDB(); db

And I get this error:

java.lang.NoClassDefFoundError: com/sleepycat/je/DatabaseException
	
...

I do not understand why. The BerkeleyDB jar files are placed already in /System/Library/Java/Extensions and the class compiles correctly. Any idea on why it is not running? What am I forgetting?

I'm not familiar with BerkeleyDB or your appication, or Eclipse even for a complete list of what I'm not familiar with here.
However, is the class not being found yours or BerkelyDB? If yours, then it doesn't matter if the BerkeleyDB jars are in a extension directory.
Has somebody overridden ext directories? I think you can change the setting of the java.ext.dirs property.
Is there any tricky ClassLoad'ing involved that would somehow not honor the system classpath?
The invocation appears to involve reflection. It might mean a different classpath than compiling. Is it possible there is a different version of the jars somewhere in classpath when running that might confuse matters?


Those would be about the only things I can think of that would cause a failure to get something in an extension directory.
Extension directories overridden
Very non-standard classloading
Extension directory conflict with other jars in classpath confusing normal classloading. One other way I think this can also be a problem that I ran into once is if code in an extension directory tries to load code that isn't.


Maybe others more familiar with the concerned code can indicate other explanations.

Mike Hall        hallmike at att dot net
http://www.geocities.com/mik3hall
http://sourceforge.net/projects/macnative



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >Eclipse - java.lang.NoClassDefFoundError: com/sleepycat/je/DatabaseException (From: Guillermo Acilu <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.