简体   繁体   English

如何将Java对象的AMF(BlazeDS)序列化调试为Actionscript?

[英]How can I debug AMF (BlazeDS) serialization of Java objects to Actionscript?

I'm using BlazeDS to remote some Java objects that I'm consuming in a Flex application. 我正在使用BlazeDS远程访问我在Flex应用程序中使用的一些Java对象。 I'm getting a type coercion error with one of my classes that I can't for the life of me figure out. 我的一个课程出现了类型强制错误,但我无法解决这个问题。 I have other classes that are working fine using the same data types, and I've gone over my mapping a dozen times. 我有其他类使用相同的数据类型工作正常,我已经超过了我的映射十几次。 I'm following all of the necessary conventions for getters and setters as far as I know... 据我所知,我正在遵循吸气剂和制定者的所有必要约定......

Anyhow, my question is: how can I debug this problem? 无论如何,我的问题是:我该如何调试这个问题? Running the Flex app in debug mode spits out some generic errors to the console that don't really help much (TypeError: Error #1034: Type Coercion failed: cannot convert Object@5d1d809 to valueObjects.SomeClass.). 在调试模式下运行Flex应用程序会向控制台发出一些通用错误,这些错误并没有多大帮助(TypeError:错误#1034:类型强制失败:无法将Object @ 5d1d809转换为valueObjects.SomeClass。)。

I'm new to this whole AMF / Flex + Java thing, so any tips would be greatly appreciated. 我是这个整个AMF / Flex + Java的新手,所以任何提示都会非常感激。

These are two of the tools I use when working with BlazeDS, AMF, etc.: 这是我在使用BlazeDS,AMF等时使用的两个工具:

  • Use an HTTP proxy tool that shows the calls between your client and server, like Charles 使用HTTP代理工具显示客户端和服务器之间的调用,如Charles

Charles is an HTTP proxy / HTTP monitor / Reverse Proxy that enables a developer to view all of the HTTP and SSL / HTTPS traffic between their machine and the Internet. Charles是一个HTTP代理/ HTTP监视器/反向代理,使开发人员能够查看其机器和Internet之间的所有HTTP和SSL / HTTPS流量。 This includes requests, responses and the HTTP headers (which contain the cookies and caching information). 这包括请求,响应和HTTP标头(包含cookie和缓存信息)。

  • Turn on the logging for BlazeDS . 打开BlazeDS的日志记录 Within WEB-INF/conf/services-conf.xml , lower the debugging level to ' debug ' like in the below snippit. WEB-INF/conf/services-conf.xml ,将调试级别降低到' debug ',如下面的snippit所示。 The output, which is fairly detailed, will appear in {tomcat-home}/logs/localhost.yyyy-mm-dd.log 输出相当详细,将出现在{tomcat-home}/logs/localhost.yyyy-mm-dd.log

    < target class="flex.messaging.log.ConsoleTarget" level="debug" > < target class="flex.messaging.log.ConsoleTarget" level="debug" >

The easiest way to check on the communication between service-clients AMF messages is to use FireFox, install FireBug extension and add the AMF Explorer . 检查服务客户端AMF消息之间通信的最简单方法是使用FireFox,安装FireBug扩展并添加AMF Explorer You can see the structured requests and responses. 您可以看到结构化请求和响应。

The java class that is being deserialized in the client side must have a reference to an object of the corresponding AS3 class in the application (mxml or as3). 在客户端进行反序列化的java类必须引用应用程序中相应AS3类的对象(mxml或as3)。 Otherwise, the as3 class will not be loaded in the swf file and will result in deserializing the java class to a generic as3 object. 否则,as3类将不会加载到swf文件中,并导致将java类反序列化为泛型as3对象。

updated This will happen despite having the mapping, getters and setters. 更新尽管有映射,getter和setter,但仍会发生这种情况。 Just declare an object of the corresponding AS3 class in script section of your mxml. 只需在mxml的script部分声明相应AS3类的对象即可。

I use Flex Builder and have it set up for both client and server side debugging. 我使用Flex Builder并将其设置为客户端和服务器端调试。 It was a pain to set up at first, but you can Google for step-by-step tutorials. 首先设置起来很痛苦,但是您可以通过Google逐步进行教程。 I find it quite valuable for debugging RPCs. 我觉得调试RPC很有价值。 Last I checked, Flex Builder has a free trial and is free to students and the unemployed. 最后我查了一下,Flex Builder有一个免费试用版,对学生和失业者免费。

It's also worth noting that instrumentation in Java can also cause a loss of information and/or interfere with the serialization process and stream. 值得注意的是,Java中的检测也会导致信息丢失和/或干扰序列化过程和流。

I've experienced this TypeError: Error #1034: Type Coercion failed on a project (Flex<->BlazeDS+Spring) where our data-access layer was implemented with iBatis and had lazy-loading switched on - we turned it off as that measure represented the lesser loss of efficiency (theoretically, at least), as compared to other workarounds we had in place. 我遇到过这种TypeError: Error #1034: Type Coercion failed项目上的TypeError: Error #1034: Type Coercion failed (Flex < - > BlazeDS + Spring)我们的数据访问层是用iBatis实现的,并且启用了延迟加载 - 我们将其关闭了与我们现有的其他变通方法相比,衡量标准表示效率损失较小(理论上至少)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM