Android:通过 Android 上的反射实例化 JNDI 工厂,强制 javax
我正在尝试将 Apache Qpid 客户端、JMS 和 JNDI 移植到 Android。在向 Dalvik 传递 --core-library 参数以允许 JMS/JNDI 的 javax 包后运行 ant 调试安装目标时,我能够成功编译/构建 QpidDroid 项目。我希望在考虑使用 jarjar 将 javax 类重新打包/重构到不同的包命名空间中之前执行此操作。
我认为这是合法的,因为我使用的是 Oracle 网站当前提供的旧/第一个单独的 JNDI jar。我在 Qpid 中使用 Apache Geronimo 附带的 JMS jar,..但我认为它也可以从 Oracle 单独下载。我的开发环境使用Android平台2.1和jdk 1.6。
问题是,目前似乎无法实例化我的自定义 jndi 连接工厂:PropertiesFileInitialContextFactory。这是我的 QpidDroid 项目中的 .java 源文件(不是 libs jar 中的 .class)(我从 qpidClient jar 中提取了该类)。
有人知道为什么它不能在这里实例化吗?我想知道 proguard 是否可能会破坏反射,...但我正在使用 debug ant 任务构建它,..所以我认为 proguard 根本不应该运行。当我在模拟器上运行已安装的应用程序时,会发生异常。我在同一台计算机上运行 Apache Qpid 服务,并使用它使用的默认端口。
01-18 18:05:16.966: W/System.err(296): [Root exception is java.lang.ClassNotFoundException: org.apache.qpid.jndi.PropertiesFileInitialContextFactory]javax.naming.NoInitialContextException: Cannot instantiate class: org.apache.qpid.jndi.PropertiesFileInitialContextFactory
01-18 18:05:17.006: W/System.err(296): at javax.naming.spi.NamingManager.getDefaultInitialContextFactory(NamingManager.java:720)
01-18 18:05:17.006: W/System.err(296): at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:768)
01-18 18:05:17.016: W/System.err(296): at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:169)
01-18 18:05:17.016: W/System.err(296): at javax.naming.InitialContext.<init>(InitialContext.java:146)
01-18 18:05:17.016: W/System.err(296): at org.rif.QpidDroid.Hello.runTest(Hello.java:56)
感谢您的任何提示!
I'm trying to port: Apache Qpid Client, JMS and JNDI -- to Android. I'm able to get a successful compile/build of my QpidDroid project when running the ant debug install targets after passing Dalvik the --core-library parameter to allow javax packages for JMS/JNDI. I'm hoping to do this before considering repackaging/refactoring javax classes into a different package namespace using jarjar.
I think this is legally legit because I'm using the old/first seperate JNDI jar currently provided by Oracle's website. I'm using the JMS jar that comes with Apache Geronimo in Qpid,.. but I think it's also available from Oracle as a seperate download. My dev environment uses Android platform 2.1 and jdk 1.6.
The problem is, it seems it currently cannot instantiate my custom jndi connection factory: PropertiesFileInitialContextFactory. This is a .java source file in my QpidDroid project(not a .class in a libs jar) (I extracted the class out of the qpidClient jar).
Would someone have any idea as to why it cannot be instantiated here? I was wondering if proguard might be breaking reflection,... but I'm building it with the debug ant task,.. so I'm thinking proguard shouldn't be running at all. The exception occurs when I run the installed app on the emulator. I have the Apache Qpid service running on the same machine with the default port that it uses.
01-18 18:05:16.966: W/System.err(296): [Root exception is java.lang.ClassNotFoundException: org.apache.qpid.jndi.PropertiesFileInitialContextFactory]javax.naming.NoInitialContextException: Cannot instantiate class: org.apache.qpid.jndi.PropertiesFileInitialContextFactory
01-18 18:05:17.006: W/System.err(296): at javax.naming.spi.NamingManager.getDefaultInitialContextFactory(NamingManager.java:720)
01-18 18:05:17.006: W/System.err(296): at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:768)
01-18 18:05:17.016: W/System.err(296): at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:169)
01-18 18:05:17.016: W/System.err(296): at javax.naming.InitialContext.<init>(InitialContext.java:146)
01-18 18:05:17.016: W/System.err(296): at org.rif.QpidDroid.Hello.runTest(Hello.java:56)
Thanks for any tips!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想我发现了问题 - Android 在 2.3 版本之前的反射中存在错误
http://code.google.com/p/android/issues/detail?id=6636
我将 QpidDroid 项目移植到 Android 2.3,看起来 JNDI 现在已成功创建 InitialContext QPID 连接参数
I think I found the problem -- Android has bugs in it with Reflection prior to version 2.3
http://code.google.com/p/android/issues/detail?id=6636
I ported my QpidDroid project to Android 2.3 and it looks like JNDI is successfully creating the InitialContext now with the QPID connection params