Hi-All,
我正在做一个从Java到Flex的服务器推送。但是,MessageBrokerServlet没有初始化,似乎是在调用来自的方法
flex.messaging.config.LoginCommandSettings.setMatch()
最终,我发现该类中确实不存在此方法(LoginCommandSettings)。我还有什么问题吗?
这就是tomcat日志所说的:
2012-01-24 14:04:57 StandardContext[/mywebapp]StandardWrapper.Throwable
java.lang.NoSuchMethodError: flex.messaging.config.LoginCommandSettings.setMatch(Ljava/lang/String;)V
at flex.messaging.config.ServerConfigurationParser.securitySection(ServerConfigurationParser.java:172)
at flex.messaging.config.ServerConfigurationParser.parseTopLevelConfig(ServerConfigurationParser.java:53)
at flex.messaging.config.AbstractConfigurationParser.parse(AbstractConfigurationParser.java:68)
at flex.messaging.config.FlexConfigurationManager.getMessagingConfiguration(FlexConfigurationManager.java:77)
at flex.messaging.MessageBrokerServlet.init(MessageBrokerServlet.java:101)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1029)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:687)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:144)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:619)
2012-01-24 14:04:57 StandardWrapperValve[MessageBrokerServlet]: Allocate exception for servlet MessageBrokerServlet
javax.servlet.ServletException: Servlet.init() for servlet MessageBrokerServlet threw exception
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1071)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:687)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:144)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:619)
—– Root Cause —–
java.lang.NoSuchMethodError: flex.messaging.config.LoginCommandSettings.setMatch(Ljava/lang/String;)V
at flex.messaging.config.ServerConfigurationParser.securitySection(ServerConfigurationParser.java:172)
at flex.messaging.config.ServerConfigurationParser.parseTopLevelConfig(ServerConfigurationParser.java:53)
at flex.messaging.config.AbstractConfigurationParser.parse(AbstractConfigurationParser.java:68)
at flex.messaging.config.FlexConfigurationManager.getMessagingConfiguration(FlexConfigurationManager.java:77)
at flex.messaging.MessageBrokerServlet.init(MessageBrokerServlet.java:101)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1029)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:687)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:144)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:619)
我是flex编程的新手,并使用tomcat server-jakarta-tomcat-5.0.28部署web应用程序。我已经对消息配置.xml、服务配置.xml进行了所有更改,并编写了一个带有线程的Java类来继续推送数据。
我在java代码中使用了两个库:
火焰-普通-3.0
弹性消息
自从过去两天以来,我一直被这个问题困扰着。。。因此,在这方面的任何帮助都将不胜感激。。。
提前感谢!!
-Adwait
这是我的消息-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<service id="message-service"
class="flex.messaging.services.MessageService">
<adapters>
<adapter-definition id="actionscript" class="flex.messaging.services.messaging.adapters.ActionScriptAdapter" default="true" />
<adapter-definition id="jms" class="flex.messaging.services.messaging.adapters.JMSAdapter"/>
<adapter-definition id="feed" class="packagename.className"/>
</adapters>
<destination id="feed">
<properties>
<network>
<session-timeout>0</session-timeout>
</network>
<server>
<max-cache-size>1000</max-cache-size>
<message-time-to-live>0</message-time-to-live>
<durable>false</durable>
</server>
</properties>
<channels>
<channel ref="my-rtmp"/>
</channels>
</destination>
</service>
这是我的AS文件:
import mx.messaging.Consumer;
import mx.messaging.events.MessageEvent;
import mx.messaging.events.MessageFaultEvent;
import mx.messaging.messages.IMessage;
private var listner: Consumer;
// functio to handle the creationComplete event:
public function ccHandler(): void {
listner = new Consumer();
listner.addEventListener(MessageEvent.MESSAGE, onReceiveMessageFromServer);
listner.addEventListener(MessageFaultEvent.FAULT, onFailedReceiveMessageFromServer);
}
// receive message handler:
private function onReceiveMessageFromServer(message: IMessage): void {
lblMessageReceivedFromServer.text = message.body.toString();
}
// fault message handler:
private function onFailedReceiveMessageFromServer(message: IMessage): void {
lblMessageReceivedFromServer.text = "Error when receiving message from 'feed'";
}
Java类(目的地)定期发送数据:
import flex.messaging.MessageBroker;
import flex.messaging.messages.AsyncMessage;
import flex.messaging.messages.Message;
import flex.messaging.services.ServiceAdapter;
import flex.messaging.util.UUIDUtils;
/**
*
* @author adeshpande
*/
public class ServerPushManager extends ServiceAdapter {
private volatile boolean running;
public static void sendMessageToClients() {
// random no. to send to client:
double dNumber = 0;
// set the message broker
final MessageBroker msgBroker = MessageBroker.getMessageBroker(null);
// set the UUID:
final String clientId = UUIDUtils.createUUID(false);
// create the message to send and set parameters
final AsyncMessage msg = new AsyncMessage();
msg.setDestination("feed");
msg.setClientId(clientId);
msg.setMessageId((UUIDUtils.createUUID(false)));
msg.setTimestamp(System.currentTimeMillis());
dNumber = Math.random()*100;
msg.setBody(dNumber);
System.out.println("n---- Message to send: " +dNumber +" ----n");
// send the message into the message routing system:
msgBroker.routeMessageToService(msg, null);
}
/*
private void sendMessageToClients(Message msg) {
((MessageService) getDestination().getService()).pushMessageToClients(msg, false);
}
*/
@Override // flex.messaging.services.ServiceAdapter ---> start()
public void start(){
super.start();
Thread messageSender = new Thread(){
@Override
public void run(){
running = true;
while(running){
sendMessageToClients();
secondsToSleep(3);
}
}
};
messageSender.start();
}
@Override // flex.messaging.services.ServiceAdapter ---> stop()
public void stop(){
super.stop();
running = false;
}
@Override
public Object invoke(Message message) {
if (message.getBody().equals("stop")) {
running = false;
}
return null;
}
private void secondsToSleep(int seconds) {
try{
Thread.sleep(seconds * 1000);
}
catch(InterruptedException e){
System.out.println("TestServiceAdapter Interrupted while sending messages");
e.printStackTrace();
}
}
}
AFAIK,RTMP和RTMPT协议仅在LiveCycle Data Services(LCDS)中可用,而BlazeDS无法解释错误。
听起来你的blaze设置有问题。找到问题可能很困难。相反,试着重新设计BlazeDS。这里有一个简单的2分钟设置,你可以尝试:
- 在tomcat上安装blazeDS
- 制作一个webapps/blastds的副本,并将该副本重命名为您所称的应用程序
- 现在,将您编码的所有java类添加到webapps/my-application/WEB-INF/classes文件夹中
- 配置WEB-INF/flex/remoting配置和services-config.xml文件
通过这种方式,您将确保所有依赖的库、类和配置文件都包含在您的应用程序中。