gpt4 book ai didi

java - MessageBrokerServlet 初始化问题——将数据从 java 推送到 Flex 应用程序

转载 作者:行者123 更新时间:2023-11-28 23:06:17 24 4
gpt4 key购买 nike

大家好,

我正在处理从 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 部署网络应用程序的新手。我已经对 messaging-config.xmlservices-config.xml 进行了所有更改,并编写了一个带有线程的 Java 类来继续推送数据。

我在我的 java 代码中使用了 2 个库:

  1. blazeds-common-3.0

  2. 弹性消息传递

自从过去 2 天以来,我一直坚持这个...因此,在这方面的任何帮助将不胜感激......

提前致谢!!

-等待

这是我的 messaging-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();
}
}
}

最佳答案

据我所知,RTMP 和 RTMPT 协议(protocol)仅在 LiveCycle Data Services (LCDS) 中可用,在 BlazeDS 中不可用,这解释了错误。

关于java - MessageBrokerServlet 初始化问题——将数据从 java 推送到 Flex 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8999556/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com