When message-driven Bean is deployed in EJB3.0, The javax. naming. NameNotFoundException exception is thrown,

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.