When message-driven Bean is deployed in EJB3.0, The javax. naming. NameNotFoundException exception is thrown,
When deploying the message-driven Bean of EJB, the following error occurs:
ERROR [org. jboss. resource. adapter. jms. inflow. JmsActivation] (WorkManager (2)-2) Unable to reconnect
Org. jboss. resource. adapter. jms. inflow. JmsActivationSpec @ 2705ea (ra = org. jboss. resource. adapter. jms.
JmsResourceAdapter @ 737612 destination = queue/myqueue destinationType = javax. jms. Queue tx = true durable = false
Reconnect = 10 provider = java:/DefaultJMSProvider user = null maxMessages = 1 minSession = 1 maxSession = 15 keepAlive = 60000
UseDLQ = true DLQHandler = org. jboss. resource. adapter. jms. inflow. dlq. GenericDLQHandler DLQJndiName = queue/DLQ
DLQUser = null DLQMaxResent = 5)
Javax. naming. NameNotFoundException: myqueue not bound
Solution 1:
Add the following code to the mail-service.xml file under the JBoss root directory \ server \ default \ deploy:
<mbean code="org.jboss.mq.server.jmx.Queue" name="jboss.org.destination:server=Queue,name=myqueue" > <attribute name="JNDIName" >queue/myqueue</attribute> <depends optional-attribute-name = "DestinationManager" > jboss.mq:service=DestinationManager </depends> </mbean>
Solution 2:
Create a xxx-service.xml file in the Jboss server \ default \ deploy directory, where xxx can take any value, but must be suffixed with-service, for example, MDB-service.xml. This file can be stored in deploy or its subdirectory (which can be a multi-layer subdirectory. The content of this file is as follows:
<?xml version="1.0" encoding="UTF-8"?> <server> <mbean code="org.jboss.mq.server.jmx.Queue" name="jboss.mq.destination:service=Queue,name=myqueue"> <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends> </mbean> </server>
Cause:
The message-driven Bean annotation is as follows:
@MessageDriven( activationConfig = { @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"), @ActivationConfigProperty(propertyName="destination", propertyValue="queue/myqueue") } )
The message-driven Bean must be annotated using @ MessageDriven. Note that the value of the destination attribute is queue/myqueue. JBoss does not create a Queue object by itself. Therefore, you need to manually configure the Queue object.
OK, you can solve this problem by using one of the above solutions. You just need to redeploy the message-driven Bean we have compiled and then run the client, you will find that our message-driven Bean has been successfully called.
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.