Sign in to follow this  
Followers 0
jndinet

missing "org.garret.perst.impl.ClassDescriptorLoadFactory"

13 posts in this topic

hi all,

i'm running perst 2.3.7.

i have an application which is running under android v 2.3.4 on an htc. i'm trying to move it to android v 5.0.2 on a samsung tablet. when i debug it i get a class not found error with the class "org.garret.perst.impl.ClassDescriptorLoadFactory". the class "StorageFactory" is found.

does anyone know where this class is and why it's not a problem under the older android version.

john

Share this post


Link to post
Share on other sites

There is no org.garret.perst.impl.ClassDescriptorLoadFactory class in Perst.
Perst has the org.garret.perst.impl.LoadFactory class which is used in ClassDescriptor class.
Can you send a precise error message and if possible an exception stack trace.

Share this post


Link to post
Share on other sites

hi,

ignore last post. trace apparently is too big.

this is the messaage from the debugger.

Didn't find class "org.garret.perst.impl.ClassDescriptorLoadFactory" on path: DexPathList[[zip file "/data/app/com.soundsoftware.androidinventoryloadodb-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]

john

Share this post


Link to post
Share on other sites

here is the code that causes the error.

public void create(String pPath, JCModelODB pRoot) {
initialize();
try{
db.open(pPath); <==== exception here works fine in earlier android ver
db.setRoot(pRoot);
modelRoot = pRoot;
} catch (Exception e) {
Log.e(JCBaseConstants.TAG, " set root exception ");
}
Log.e(JCBaseConstants.TAG, " ************* ");
}
public void initialize() {
db = StorageFactory.getInstance().createStorage();
}

Share this post


Link to post
Share on other sites

as part of the open in StorageImpl a ClassDescriptor is created and ClassDescriptor.loadClass(String) has the bad string so the ClassforName fails.

Share this post


Link to post
Share on other sites

Sorry for the delay. Please understand that support via this forum is on an "as available" basis (i.e. when our workload for customers with support agreements permits). For priority (email) support, please contact us via team@mcobject.com.

Perst tries to load class with name XXXLoadFactory to support custom loaders.

When loading class XXX, Perst first looks for the class with name XXXLoadFactory. If a class with such a name is found, then Perst expects that it implements the LoadFactory interface and uses this class to construct instances of this class.

The code looks like this:

private void locateConstructor() {

try {

Class c = loadClass(cls.getName() + "LoadFactory");

factory = (LoadFactory)c.newInstance();

} catch (Exception x1) {

try {

loadConstructor = cls.getDeclaredConstructor(perstConstructorProfile);

constructorParams = new Object[]{this};

} catch (NoSuchMethodException x2) {

try {

loadConstructor = getReflectionProvider().getDefaultConstructor(cls);

constructorParams = null;

} catch (Exception x3) {

throw new StorageError(StorageError.DESCRIPTOR_FAILURE, cls, x3);

}

}

try {

loadConstructor.setAccessible(true);

} catch (Exception x) {}

}

}

So, lack of a class with this name is normal.

Class.forName should throw java.lang.ClassNotFoundException

which should be caught and handled by Perst.

But there is bug in Android 5.0: https://github.com/pardom/ActiveAndroid/issues/283

Looks like it throws java.lang.NoClassDefFoundError instead of java.lang.ClassNotFoundException

The problem can be fixed by replacing in Perst catch (Exception x1) with catch (Throwable x1):

private void locateConstructor() {

try {

Class c = loadClass(cls.getName() + "LoadFactory");

factory = (LoadFactory)c.newInstance();

} catch (Throwable x1) {

Sorry for the inconvenience, but it is not a Perst bug - it is an Android bug.

Share this post


Link to post
Share on other sites

hi,

after a lot of thought i'm going to try and patch perst.

couple of questions: 1) what pkg/class is this method in? i've tried to find but it's a big search. 2) i develop in eclipse. assuming i make the change, how do i rebuild perst (i.e. do i import all into eclipse, do you have a build script,....)?

john

Share this post


Link to post
Share on other sites

The location of this line is perst/src/org/garret/perst/impl/ClassDescriptor.java:323
The easiest way to build perst is just to do "make" in the perst root directory. Alternatively, you can run compile.sh or compile.bat in the perst/src directory.
In both cases it assumes that you have the Java SDK installed so the javac compiler is available.
You may need to add the path to the SDK to the PATH environment variable.


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0