使用带有simplexml的ormlite的问题

时间:2014-09-17 00:19:47

标签: android classloader ormlite simple-framework

我目前正在使用ormlite和simplexml。当我尝试使用简单的xml将xml文件转换为具有ORMLite LazyForeignCollection对象的对象时,我得到了以下异常。有人可以解释我需要如何处理这个问题。如果您需要任何其他信息,请与我们联系。我以前没有与ormlite有任何问题。

09-16 19:00:22.688: W/System.err(32274): java.lang.ClassNotFoundException: Didn't find class "com.j256.ormlite.dao.LazyForeignCollection" on path: .
09-16 19:00:22.688: W/System.err(32274):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:64)
09-16 19:00:22.688: W/System.err(32274):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
09-16 19:00:22.688: W/System.err(32274):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
09-16 19:00:22.688: W/System.err(3227d4):   at android.app.LoadedApk$WarningContextClassLoader.loadClass(LoadedApk.java:431)
09-16 19:00:22.688: W/System.err(32274):    at org.simpleframework.xml.strategy.Loader.load(Loader.java:50)
09-16 19:00:22.688: W/System.err(32274):    at org.simpleframework.xml.strategy.TreeStrategy.readValue(TreeStrategy.java:163)
09-16 19:00:22.688: W/ActivityThread(32274): ClassLoader.loadClass: The class loader returned by Thread.getContextClassLoader() may fail for processes that host multiple applications. You should explicitly specify a context class loader. For example: Thread.setContextClassLoader(getClass().getClassLoader());
09-16 19:00:22.698: W/System.err(32274):    at org.simpleframework.xml.strategy.TreeStrategy.read(TreeStrategy.java:102)
09-16 19:00:22.698: W/System.err(32274):    at org.simpleframework.xml.core.Source.getOverride(Source.java:360)
09-16 19:00:22.698: W/System.err(32274):    at org.simpleframework.xml.core.Factory.getConversion(Factory.java:207)
09-16 19:00:22.698: W/System.err(32274):    at org.simpleframework.xml.core.Factory.getOverride(Factory.java:139)
09-16 19:00:22.698: W/System.err(32274):    at org.simpleframework.xml.core.CollectionFactory.getInstance(CollectionFactory.java:87)
09-16 19:00:22.698: W/System.err(32274):    at org.simpleframework.xml.core.CompositeList.read(CompositeList.java:116)
09-16 19:00:22.698: W/System.err(32274):    at org.simpleframework.xml.core.Composite.readVariable(Composite.java:623)
09-16 19:00:22.698: W/System.err(32274):    at org.simpleframework.xml.core.Composite.readInstance(Composite.java:573)
09-16 19:00:22.698: W/System.err(32274):    at org.simpleframework.xml.core.Composite.readUnion(Composite.java:549)
09-16 19:00:22.708: W/System.err(32274):    at org.simpleframework.xml.core.Composite.readElement(Composite.java:532)
09-16 19:00:22.708: W/System.err(32274):    at org.simpleframework.xml.core.Composite.readElements(Composite.java:445)
09-16 19:00:22.708: W/System.err(32274):    at org.simpleframework.xml.core.Composite.access$400(Composite.java:59)
09-16 19:00:22.708: W/System.err(32274):    at org.simpleframework.xml.core.Composite$Builder.read(Composite.java:1383)
09-16 19:00:22.708: W/System.err(32274):    at org.simpleframework.xml.core.Composite.read(Composite.java:201)
09-16 19:00:22.708: W/System.err(32274):    at org.simpleframework.xml.core.Composite.read(Composite.java:148)
09-16 19:00:22.708: W/System.err(32274):    at org.simpleframework.xml.core.Traverser.read(Traverser.java:92)
09-16 19:00:22.708: W/System.err(32274):    at org.simpleframework.xml.core.Persister.read(Persister.java:625)
09-16 19:00:22.708: W/System.err(32274):    at org.simpleframework.xml.core.Persister.read(Persister.java:606)
09-16 19:00:22.708: W/System.err(32274):    at org.simpleframework.xml.core.Persister.read(Persister.java:584)
09-16 19:00:22.708: W/System.err(32274):    at org.simpleframework.xml.core.Persister.read(Persister.java:543)
09-16 19:00:22.718: W/System.err(32274):    at org.simpleframework.xml.core.Persister.read(Persister.java:521)
09-16 19:00:22.718: W/System.err(32274):    at org.simpleframework.xml.core.Persister.read(Persister.java:426)
09-16 19:00:22.718: W/System.err(32274):    at com.honeydewit.XMLMarshaller.generateListFromXml(XMLMarshaller.java:37)
09-16 19:00:22.718: W/System.err(32274):    at com.honeydewit.AttachmentProcessor.onCreate(AttachmentProcessor.java:46)
09-16 19:00:22.718: W/System.err(32274):    at android.app.Activity.performCreate(Activity.java:5372)
09-16 19:00:22.718: W/System.err(32274):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
09-16 19:00:22.718: W/System.err(32274):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257)
09-16 19:00:22.718: W/System.err(32274):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
09-16 19:00:22.718: W/System.err(32274):    at android.app.ActivityThread.access$700(ActivityThread.java:159)
09-16 19:00:22.728: W/System.err(32274):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
09-16 19:00:22.728: W/System.err(32274):    at android.os.Handler.dispatchMessage(Handler.java:99)
09-16 19:00:22.728: W/System.err(32274):    at android.os.Looper.loop(Looper.java:137)
09-16 19:00:22.728: W/System.err(32274):    at android.app.ActivityThread.main(ActivityThread.java:5419)
09-16 19:00:22.728: W/System.err(32274):    at java.lang.reflect.Method.invokeNative(Native Method)
09-16 19:00:22.728: W/System.err(32274):    at java.lang.reflect.Method.invoke(Method.java:525)
09-16 19:00:22.738: W/System.err(32274):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
09-16 19:00:22.738: W/System.err(32274):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
09-16 19:00:22.738: W/System.err(32274):    at dalvik.system.NativeStart.main(Native Method)

1 个答案:

答案 0 :(得分:0)

我想出了这个问题。我需要在XMLMarshaller类中手动设置类加载器。

Android: "Class loader may fail for processes that host multiple applications"