-
1. Re: MDB in wildfly not working when there is a constructor
mnovak Oct 6, 2016 9:04 AM (in response to rohanemmanuel)Hi Rohan,
could you provide the bad MDB code? By activemq do you think ActiveMQ 5.x or ActiveMQ Artemis? Could you share your configuration?
Thanks,
Mirek
-
2. Re: MDB in wildfly not working when there is a constructor
rohanemmanuel Oct 7, 2016 1:56 AM (in response to mnovak)Miroslav Novak wrote:
Hi Rohan,
could you provide the bad MDB code? By activemq do you think ActiveMQ 5.x or ActiveMQ Artemis? Could you share your configuration?
Thanks,
Mirek
Hi Miroslav,
Thanks for responding ,
i was using active MQ 5.9.1.Final.
I was able to reproduce this by using the wildfly 10.x quicktstart named "helloworld-mdb" , i added an empty constructor and it doesnt get the message,if i remove this, it works fine.
Is this something to do with the TCCL ?
providing the code below for your reference.
/*
* JBoss, Home of Professional Open Source
* Copyright 2015, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.as.quickstarts.mdb;
import java.util.logging.Logger;
import javax.annotation.Resource;
import javax.ejb.MessageDriven;
import javax.ejb.ActivationConfigProperty;
import javax.jms.Connection;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.Session;
import javax.jms.TextMessage;
/**
* <p>
* A simple Message Driven Bean that asynchronously receives and processes the messages that are sent to the queue.
* </p>
*
* @author Serge Pagop (spagop@redhat.com)
*
*/
@MessageDriven(name = "HelloWorldQueueMDB", activationConfig = {
// @ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "queue/HELLOWORLDMDBQueue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "QUEUE.OUTBOUND"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge") })
public class HelloWorldQueueMDB implements MessageListener {
HelloWorldQueueMDB(){
}
private final static Logger LOGGER = Logger.getLogger(HelloWorldQueueMDB.class.toString());
/**
* @see MessageListener#onMessage(Message)
*/
public void onMessage(Message rcvMessage) {
TextMessage msg = null;
try {
if (rcvMessage instanceof TextMessage) {
msg = (TextMessage) rcvMessage;
System.out.println("Received Message from queue: " + msg.getText());
System.out.println("receiveing..weird stuff rite here");
} else {
System.out.println("Message of wrong type: " + rcvMessage.getClass().getName());
}
} catch (JMSException e) {
throw new RuntimeException(e);
}
}
}
Without having the empty constructor i see the following the in the logs:
Server:server-one] 11:04:15,149 INFO [stdout] (default-threads - 6) Received Message from queue: msg
When i add an empty constructor to the MDB, i see that the message will not be received.
Thanks,
Rohan Emmanuel
-
3. Re: MDB in wildfly not working when there is a constructor
mnovak Oct 7, 2016 2:49 AM (in response to rohanemmanuel)I can see that you're using domain mode. Do you think you could try it in standalone? There is probably problem with MDB activation just in domain.
-
4. Re: MDB in wildfly not working when there is a constructor
jaikiran Oct 7, 2016 3:01 AM (in response to rohanemmanuel)2 of 2 people found this helpfulpublic class HelloWorldQueueMDB implements MessageListener {
HelloWorldQueueMDB(){
}
Actually, that violates the EJB 3 spec which mandates:
The class must have a public constructor that takes no arguments. The container uses this constructor to create instances of the message-driven bean class.
That's what causes the MDB to fail deployment. I expect the deployment to fail or at least have a message in the logs stating this issue. Isn't it logged in your server logs?
-
5. Re: MDB in wildfly not working when there is a constructor
rohanemmanuel Oct 7, 2016 4:15 AM (in response to jaikiran)Hi Jaikiran,
Thanks for your reply,
The class must have a public constructor that takes no arguments. The container uses this constructor to create instances of the message-driven bean class.
Thanks for pointing out the spec details, I understand that it violates it, i stumbled upon it. I was using this old MDB which had the empty default constructor and it was working fine in JBoss7.1.2.Final. Realised this when i migrated to wildfly10.0.0.Final.
That's what causes the MDB to fail deployment. I expect the deployment to fail or at least have a message in the logs stating this issue. Isn't it logged in your server logs?
No, the deployment doesn't fail. Everything goes through fine, only that the MDB doesn't receive the messages.
2016-10-07 13:14:52,951 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) WFLYSRV0027: Starting deployment of "JustMDNOT.jar" (runtime-name: "JustMDNOT.jar")
2016-10-07 13:14:53,030 INFO [org.jboss.as.ejb3] (MSC service thread 1-1) WFLYEJB0042: Started message driven bean 'HelloWorldQueuNEW' with '<RAR_FILE>' resource adapter
2016-10-07 13:14:53,032 INFO [org.jboss.as.ejb3] (MSC service thread 1-1) WFLYEJB0042: Started message driven bean 'HelloWorldQueueMDB' with '<RAR_FILE>' resource adapter
2016-10-07 13:14:53,036 INFO [org.apache.activemq.ra.ActiveMQEndpointWorker] (ServerService Thread Pool -- 171) Starting
2016-10-07 13:14:53,160 INFO [org.apache.activemq.ra.ActiveMQEndpointWorker] (ServerService Thread Pool -- 170) Starting
2016-10-07 13:14:53,210 INFO [org.apache.activemq.ra.ActiveMQEndpointWorker] (default-threads - 22) Establishing connection to broker [tcp://<IP>:<PORT>]
2016-10-07 13:14:53,211 INFO [org.apache.activemq.ra.ActiveMQEndpointWorker] (default-threads - 23) Establishing connection to broker [tcp://<IP>:<PORT>]
-
6. Re: MDB in wildfly not working when there is a constructor
mnovak Oct 7, 2016 6:12 AM (in response to rohanemmanuel)Jaikiran ha better eyes than me:-) If Artemis resource adapter is used than there server logs warning/errors during deploy. This seems to be ActiveMQ 5.x resource adapter related.
For Artemis resource adapter server logs:
12:08:38,908 INFO [org.jboss.as.ejb3] (MSC service thread 1-2) WFLYEJB0042: Started message driven bean 'SimpleMdb' with 'activemq-ra.rar' resource adapter 12:08:39,307 WARN [org.apache.activemq.artemis.ra] (default-threads - 1) AMQ152005: Failure in broker activation org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec(ra=org.apache.activemq.artemis.ra.ActiveMQResourceAdapter@78712571 destination=Q1 destinationType=javax.jms.Queue ack=Auto-acknowledge durable=false clientID=null user=null maxSession=15): java.lang.RuntimeException: java.lang.InstantiationException: SimpleMdb$$$endpoint1 at org.jboss.as.ejb3.inflow.JBossMessageEndpointFactory.createEndpoint(JBossMessageEndpointFactory.java:77) at org.jboss.as.ejb3.inflow.JBossMessageEndpointFactory.createEndpoint(JBossMessageEndpointFactory.java:63) at org.apache.activemq.artemis.ra.inflow.ActiveMQMessageHandler.setup(ActiveMQMessageHandler.java:187) at org.apache.activemq.artemis.ra.inflow.ActiveMQActivation.setup(ActiveMQActivation.java:318) at org.apache.activemq.artemis.ra.inflow.ActiveMQActivation$SetupActivation.run(ActiveMQActivation.java:719) at org.jboss.jca.core.workmanager.WorkWrapper.run(WorkWrapper.java:223) at org.jboss.threads.SimpleDirectExecutor.execute(SimpleDirectExecutor.java:33) at org.jboss.threads.QueueExecutor.runTask(QueueExecutor.java:808) at org.jboss.threads.QueueExecutor.access$100(QueueExecutor.java:45) at org.jboss.threads.QueueExecutor$Worker.run(QueueExecutor.java:828) at java.lang.Thread.run(Thread.java:745) at org.jboss.threads.JBossThread.run(JBossThread.java:320) Caused by: java.lang.InstantiationException: SimpleMdb$$$endpoint1 at java.lang.Class.newInstance(Class.java:427) at org.jboss.invocation.proxy.AbstractClassFactory.newInstance(AbstractClassFactory.java:225) at org.jboss.invocation.proxy.ProxyFactory.newInstance(ProxyFactory.java:272) at org.jboss.as.ejb3.inflow.JBossMessageEndpointFactory.createEndpoint(JBossMessageEndpointFactory.java:75) ... 11 more Caused by: java.lang.NoSuchMethodException: SimpleMdb$$$endpoint1.<init>() at java.lang.Class.getConstructor0(Class.java:3082) at java.lang.Class.newInstance(Class.java:412) ... 14 more 12:08:40,319 INFO [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 77) Initializing Mojarra 2.2.12-jbossorg-2 for context '/jmsServlet' 12:08:41,074 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 77) WFLYUT0021: Registered web context: /jmsServlet 12:08:41,170 INFO [org.jboss.as.server] (ServerService Thread Pool -- 40) WFLYSRV0010: Deployed "mdb-activemq-1.0-SNAPSHOT.jar" (runtime-name : "mdb-activemq-1.0-SNAPSHOT.jar") 12:08:41,170 INFO [org.jboss.as.server] (ServerService Thread Pool -- 40) WFLYSRV0010: Deployed "amq-ra.rar" (runtime-name : "amq-ra.rar") 12:08:41,171 INFO [org.jboss.as.server] (ServerService Thread Pool -- 40) WFLYSRV0010: Deployed "jmsServlet.war" (runtime-name : "jmsServlet.war") 12:08:41,316 INFO [org.apache.activemq.artemis.ra] (default-threads - 1) AMQ151001: Attempting to reconnect org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec(ra=org.apache.activemq.artemis.ra.ActiveMQResourceAdapter@78712571 destination=Q1 destinationType=javax.jms.Queue ack=Auto-acknowledge durable=false clientID=null user=null maxSession=15) 12:08:41,523 ERROR [org.apache.activemq.artemis.ra] (default-threads - 1) AMQ154003: Unable to reconnect org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec(ra=org.apache.activemq.artemis.ra.ActiveMQResourceAdapter@78712571 destination=Q1 destinationType=javax.jms.Queue ack=Auto-acknowledge durable=false clientID=null user=null maxSession=15): java.lang.RuntimeException: java.lang.InstantiationException: SimpleMdb$$$endpoint1 at org.jboss.as.ejb3.inflow.JBossMessageEndpointFactory.createEndpoint(JBossMessageEndpointFactory.java:77) at org.jboss.as.ejb3.inflow.JBossMessageEndpointFactory.createEndpoint(JBossMessageEndpointFactory.java:63) at org.apache.activemq.artemis.ra.inflow.ActiveMQMessageHandler.setup(ActiveMQMessageHandler.java:187) at org.apache.activemq.artemis.ra.inflow.ActiveMQActivation.setup(ActiveMQActivation.java:318) at org.apache.activemq.artemis.ra.inflow.ActiveMQActivation.reconnect(ActiveMQActivation.java:678) at org.apache.activemq.artemis.ra.inflow.ActiveMQActivation$SetupActivation.run(ActiveMQActivation.java:722) at org.jboss.jca.core.workmanager.WorkWrapper.run(WorkWrapper.java:223) at org.jboss.threads.SimpleDirectExecutor.execute(SimpleDirectExecutor.java:33) at org.jboss.threads.QueueExecutor.runTask(QueueExecutor.java:808) at org.jboss.threads.QueueExecutor.access$100(QueueExecutor.java:45) at org.jboss.threads.QueueExecutor$Worker.run(QueueExecutor.java:828) at java.lang.Thread.run(Thread.java:745) at org.jboss.threads.JBossThread.run(JBossThread.java:320) Caused by: java.lang.InstantiationException: SimpleMdb$$$endpoint1 at java.lang.Class.newInstance(Class.java:427) at org.jboss.invocation.proxy.AbstractClassFactory.newInstance(AbstractClassFactory.java:225) at org.jboss.invocation.proxy.ProxyFactory.newInstance(ProxyFactory.java:272) at org.jboss.as.ejb3.inflow.JBossMessageEndpointFactory.createEndpoint(JBossMessageEndpointFactory.java:75) ... 12 more Caused by: java.lang.NoSuchMethodException: SimpleMdb$$$endpoint1.<init>() at java.lang.Class.getConstructor0(Class.java:3082) at java.lang.Class.newInstance(Class.java:412) ... 15 more