1

I have a Dynamic Web Project with Wildfly 10 Final and JSF 2.2.9. I tried to send a message via Message Driven Bean.

But if I try to start the web application on Wildfly I get the following errors:

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);
    }
}

And the class which tries to send the 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");    
  }  
  ....  
}

I started the WildFly server with the standalone-full.xml for JMS-Support and inserted the following line:

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

Can anybody help me? Is there a config error or something similar?

Thanks. Best regards.

DJTrust
  • 23
  • 6
  • That could be just naming issue. I would try to use `lookup` param for queue injection instead of `QueueSenderSessionBean`. Like `@Resource(lookup = "java:/jms/queue/WebSocketDrivenQueue")`. I think that the jms queue names are not mapped to `java:comp/env` space (not sure to be honest, check http://docs.oracle.com/javaee/7/api/javax/annotation/Resource.html#mappedName--) – chalda Nov 02 '16 at 13:45
  • Yes, thanks. That's it. the präfix java:/ was required. I edited my first post. But now I get a NullpointerException in my WebSocket class **MyTestApplication** on **this.senderBean.sendMyText("Hello");** Any ideas, why? – DJTrust Nov 03 '16 at 11:50
  • Isn't there some error in `server.log`? It seems that there is a trouble with injection of `SLSB` bean to the websocket endpoint. As I do not have much experience in this field I did a quick search on net and found out this answer: http://stackoverflow.com/questions/20872300/java-ee-7-how-to-inject-an-ejb-into-a-websocket-serverendpoint I hope it helps. – chalda Nov 03 '16 at 14:02

1 Answers1

0

To DJTust, I found the answer for solving NullPointer after calling jmsContext.createProducer().send(queue, "Hello"). You've to add beans.xml too. See Nikolai Schreier answered at JMSContext NullPointer Exception - wildfly 8.2.0 default queue

Community
  • 1
  • 1
PeterL355
  • 75
  • 1
  • 9