找不到 /messagebroker/amf 文件

昨天晚上我想要学习Flex Data Service,没想到却碰到了一个难缠的问题。我在MXML文件中声明了一个RemoteObject,然后尝试向FDS发出异步请求,但是却怎么也发送不出去。因为我设置了如果失败就弹出event.fault.faultString,所以它一直弹出“Send fail”的提示,而JRUN控制台则提示 "Requested resource /messagebroker/amf file not found"。我就去查帮助,然后检查自己的配置文件是否正确。然而我搞了一晚上也没有弄出个所以然来,依然提示“Send Fail”。我的destination设置和其他设置是完全没有错误的,都和FDS自带的例子一样,但是为什么我写的东西就出错呢?排除了人品问题之后,我就去flexcoders的邮件档案去找,那里可真是个好地方,里面有很多前辈提出的问题和解答。因为我不太可能那么幸运,这种问题只有我自己碰到,在我郁闷之前一定有人比我先郁闷过了。我搜索了一下,并仔细查找,终于被我找到了解决方法。原邮件:http://www.mail-archive.com/flexcoders@yahoogroups.com/msg23215.html 原来,"Requested resource /messagebroker/amf file not found" 是因为 编译的时候{context.root} 不会在Eclipse中被设定,如果你要使用Flex Builder在本地编译的话,就需要吧 {context.root} 替换成你的程序的根路径,一般来说就是WEB-INF文件夹的父文件夹。

原本在 flex-config.xml中是有这么一项的:
<context-root>/flex</context-root>

但是Eclipse既然不识别,只好在service-config.xml中做如下更改:
原配置中有这么一段:

<channel-definition id=&#34;my-amf&#34; class=&#34;mx.messaging.channels.AMFChannel&#34;>
<endpoint uri=&#34;http://{server.name}:{server.port}/{context.root}/messagebroker/amf&#34; class=&#34;flex.messaging.endpoints.AMFEndpoint&#34;/>
<properties>
<polling-enabled>false</polling-enabled>
</properties>
</channel-definition>

<channel-definition id=&#34;my-secure-amf&#34; class=&#34;mx.messaging.channels.SecureAMFChannel&#34;>
<endpoint uri=&#34;https://{server.name}:9100/{context.root}/messagebroker/amfsecure&#34; class=&#34;flex.messaging.endpoints.SecureAMFEndpoint&#34;/>
</channel-definition>

<channel-definition id=&#34;my-polling-amf&#34; class=&#34;mx.messaging.channels.AMFChannel&#34;>
<endpoint uri=&#34;http://{server.name}:{server.port}/{context.root}/messagebroker/amfpolling&#34; class=&#34;flex.messaging.endpoints.AMFEndpoint&#34;/>
<properties>
<polling-enabled>true</polling-enabled>
<polling-interval-seconds>8</polling-interval-seconds>
</properties>
</channel-definition>

大家注意红色部分的 {context.root}, 你只要把它改为你的程序根路径就可以了,你可以更改所有的channel,也可以只更改需要用到的channel。比如,我用的是RemoteObject,而RemoteObject使用的是 my-amf channel,我的程序根路径为flex。所以我就做了以下更改:

<channel-definition id=&#34;my-amf&#34; class=&#34;mx.messaging.channels.AMFChannel&#34;>
<endpoint uri=&#34;http://{server.name}:{server.port}/flex/messagebroker/amf&#34; class=&#34;flex.messaging.endpoints.AMFEndpoint&#34;/>
<properties>
<polling-enabled>false</polling-enabled>
</properties>
</channel-definition>
………………

更改之后就成功送出了~~哈哈~~~心旷神怡!!不过这里还有一个问题,虽然我没有“Send Fail”,但是又出现了一个错误提示: “Unsupported major.minor version 49.0”。这个错误是怎么出现的呢?很明显不再是配置的原因了,肯定是JAVA对象的问题。请教了别人后才知道,是由于JDK版本的缘故。记住:

FDS自带的JRUN是不支持最新的JDK1.5编译的Class文件的,如果你想要使用JAVA 对象连接后台数据的话,必须实用JDK1.4来编译你的JAVA文件!!! 好像也可以为JRUN打补丁,不过这个我就不太清楚了。

现在我终于可以从后台取得数据了,接下来再写几个小例子,继续探索FDS。



本文链接: http://www.zhuoqun.net/html/y2006/199.html 转载请注明出处,谢谢。

TrackBack引用地址:http://www.zhuoqun.net/html/y2006/199.html/trackback

相关日志


Posted in 技术.

没有评论

(Required)
(Required, will not be published)