未安装Wildfly 10 Final JMS所需服务

时间:2016-10-31 23:22:41

标签: java queue jms wildfly

我有一个使用Wildfly 10 Final和JSF 2.2.9的动态Web项目。我试图通过Message Driven Bean发送消息。

但是如果我尝试在Wildfly上启动Web应用程序,我会收到以下错误:

23:57:53,971 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "MyApplication.war")]) - failure description: {
    "WFLYCTL0412: Required services that are not installed:" => ["jboss.naming.context.java.module.MyApplication.MyApplication.env.jms.queue.WebSocketDrivenQueue"],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.MyApplication.MyApplication.env.\"com.example.QueueSenderSessionBean\".myQueue is missing [jboss.naming.context.java.module.MyApplication.MyApplication.env.jms.queue.WebSocketDrivenQueue]"]
}
23:57:54,270 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 37) WFLYSRV0010: Deployed "MyApplication.war" (runtime-name : "MyApplication.war")
23:57:54,273 INFO  [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Service status report
WFLYCTL0184:    New missing/unsatisfied dependencies:
      service jboss.naming.context.java.module.MyApplication.MyApplication.env.jms.queue.WebSocketDrivenQueue (missing) dependents: [service jboss.naming.context.java.module.MyApplication.MyApplication.env."com.example.QueueSenderSessionBean".myQueue] 

WebSocketDrivenBean

@MessageDriven(
    activationConfig = { @ActivationConfigProperty(
            propertyName = "destination", propertyValue = "java:/jms/queue/WebSocketDrivenQueue"), @ActivationConfigProperty(
            propertyName = "destinationType", propertyValue = "javax.jms.Queue")
    }, 
    mappedName = "java:/jms/queue/WebSocketDrivenQueue")
   @Named
   public class WebSocketDriven implements MessageListener {
    @Inject
    @WSJMSMessage
    Event<Message> jmsEvent; 

    public WebSocketDriven() {
    }

    public void onMessage(Message message) {
        jmsEvent.fire(message);
    }
}

QueueSenderSessionBean

@Stateless
public class QueueSenderSessionBean {

    @Resource(mappedName = "java:/jms/queue/WebSocketDrivenQueue")
    private Queue myQueue;
    @Inject
    private JMSContext jmsContext; 

    public void sendMyText(String message){
        jmsContext.createProducer().send(myQueue, message);
    }
}

尝试发送消息的类:

@Named  
@ClientEndpoint(encoders={JsonEncoder.class}, decoders={JsonDecoder.class})  
public class MyTestApplication implements Serializable{  
  private static final long serialVersionUID = 1L;  
  Session userSession = null;  

  @Inject  
  private QueueSenderSessionBean senderBean;  

   ....  

  @OnMessage  
  public void onMessage(WebSocketMessage message) {  
      this.senderBean.sendMyText("Hello");    
  }  
  ....  
}

我使用Standalone-full.xml为JMS-Support启动了WildFly服务器并插入了以下行:

<jms-queue name="WebSocketDrivenQueue" entries="java:/jms/queue/WebSocketDrivenQueue />

任何人都可以帮助我吗?是配置错误还是类似的?

感谢。 最好的问候。

1 个答案:

答案 0 :(得分:0)

对于DJTust,我在调用jmsContext.createProducer()。send(queue,“Hello”)之后找到了解决NullPointer的答案。你也要添加beans.xml。见Nikolai Schreier在JMSContext NullPointer Exception - wildfly 8.2.0 default queue

回答