3

i'm trying to define a message driven bean with annotations and deployment descriptors on wildfly 8.2.0-Final . I want to declare the static parts of the configuration with annotations, variable parts with xml deployment descriptors. When deploying the following mdb, i'm getting an exception.

Here's the content of the .failed-File:

{"JBAS014671: Failed services" => {"jboss.deployment.unit.\"MdbWithAnnotationsAndDescritors.jar\".component.NewMessageBean.START" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"MdbWithAnnotationsAndDescritors.jar\".component.NewMessageBean.START: java.lang.RuntimeException: javax.resource.spi.InvalidPropertyException: Destination is mandatory Caused by: java.lang.RuntimeException: javax.resource.spi.InvalidPropertyException: Destination is mandatory Caused by: javax.resource.spi.InvalidPropertyException: Destination is mandatory"}}

The mdb is

package test;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.JMSDestinationDefinition;
import javax.jms.Message;
import javax.jms.MessageListener;
@JMSDestinationDefinition(name = "testQueue", interfaceName = "javax.jms.Queue", resourceAdapter = "jmsra", destinationName = "testQueue")
@MessageDriven(activationConfig = {
    @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
})
public class NewMessageBean implements MessageListener {
    public NewMessageBean() {
    }
    @Override
    public void onMessage(Message message) {
    }
}

and the jboss.xml deployment descriptor:

<jboss xsi:schemaLocation="http://java.sun.com/xml/ns/javaee                             http://www.jboss.org/j2ee/schema/jboss_5_0.xsd" version="3.0">
    <security-domain>tutorial-default</security-domain>
    <enterprise-beans>
        <message-driven>
            <ejb-name>testQueue</ejb-name>
            <destination-jndi-name>testQueue</destination-jndi-name>
        </message-driven>    
    </enterprise-beans>
</jboss>

the ejb-jar.xml is empty:

<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns="http://xmlns.jcp.org/xml/ns/javaee"
        version="3.2"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/ejb-jar_3_2.xsd">

</ejb-jar>
user2706510
  • 141
  • 1
  • 9

2 Answers2

2

Got it, i added the destination ActivationConfigProperty to the mdb class to get rid of the exception:

package test;

import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.JMSDestinationDefinition;
import javax.jms.Message;
import javax.jms.MessageListener;

/**
 *
 * @author rainer
 */
@MessageDriven(activationConfig = {
    @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
    @ActivationConfigProperty(propertyName = "destination", propertyValue = "willBeOverwrittenInDeploymentDescriptor")
})
public class NewMessageBean implements MessageListener {

    public NewMessageBean() {
    }

    @Override
    public void onMessage(Message message) {
    }

}

I removed the JMSDestinationDefinition because its not needed, i created the queue with the management console. To overwrite the destination jndi name, i created the following ejb-jar.xml

<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd">
    <enterprise-beans>
        <message-driven>
            <ejb-name>NewMessageBean</ejb-name>
            <ejb-class>test.NewMessageBean</ejb-class>

            <activation-config>
                <activation-config-property>
                    <activation-config-property-name>destination</activation-config-property-name>
                    <activation-config-property-value>/jms/testClientQueue</activation-config-property-value>
                </activation-config-property>
            </activation-config>
        </message-driven>
    </enterprise-beans>
</ejb-jar>

Now the mdb gets deployed and listens to the queue jms/testClientQueue

user2706510
  • 141
  • 1
  • 9
0

You need to define in ejb-jar.xml not jboss.xml

You might however prefer to use annotation substitution where the values are pulled from system properties or in jboss.properties in newer versions of wildfly or EAP 6.4

Will Tatam
  • 566
  • 3
  • 10