ejb@glassfish.java.net

Cannot deploy EJB in glassfish

From: Rajesh S <rajeshs_at_suntecgroup.com>
Date: Fri, 26 Sep 2008 09:58:08 +0530

 
Hi Experts,
 
I tried one EJB 2 MDB to deploy in glassfish server.But It showing an error like
 
Deploying application in domain failed; Error loading deployment descriptors for module [EJBGlassfish] -- Referencing error: this bundle has no bean of name: MyBean

Here is I am attaching MDB and configuration files. Please help me to deploy
 
MDB
 
package com.sun.inout;
import java.io.Serializable;
import java.rmi.RemoteException;
import javax.ejb.EJBException;
import javax.ejb.MessageDrivenBean;
import javax.ejb.MessageDrivenContext;
import javax.ejb.CreateException;
import javax.naming.*;
import javax.jms.*;
public class TestBean implements MessageDrivenBean,
    MessageListener {
    private transient MessageDrivenContext mdc = null;
    private Context context;
 Queue queue = null;
    QueueConnectionFactory queueConnectionFactory = null;

    /**
     * Default constructor. Creates a bean. Required by EJB spec.
     */
    public TestBean() {
        System.out.println("In TestBean.TestBean()");
    }
    /**
     * Sets the context for the bean.
     * @param mdc the message-driven-bean context.
     */
    public void setMessageDrivenContext(MessageDrivenContext mdc) {
        System.out.println("In "
            + "TestBean.setMessageDrivenContext()");
 this.mdc = mdc;
    }
    /**
     * Creates a bean. Required by EJB spec.
     */
    public void ejbCreate() {
 System.out.println("In TestBean.ejbCreate()");
    try {
 Context jndiContext = new InitialContext();
    queueConnectionFactory = (QueueConnectionFactory)
    jndiContext.lookup("java:comp/env/jms/MyQueueConnectionFactory");
    queue = (Queue)jndiContext.lookup("java:comp/env/jms/OutQueue");
    } catch (Exception e) {
 System.out.println("MESSAGEBEAN.ejbcreate() got Exception "+ e.getMessage());
    e.printStackTrace();
    }
    
    }
    
    public void onMessage(Message inMessage) {
        QueueConnection qconn = null;
        try {
            if (inMessage instanceof TextMessage) {
                TextMessage txtmsg = (TextMessage)inMessage;
               
             System.out.println("MESSAGE BEAN: Message received: index="+txtmsg.getText());
                qconn = queueConnectionFactory.createQueueConnection();
                QueueSession qss = qconn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
                QueueSender sender = qss.createSender(queue);
                TextMessage msg = qss.createTextMessage();
                msg.setText(txtmsg.getText());
                sender.send(msg);
                qconn.close();
            } else {
                System.out.println("WRONG MESSAGE TYPE received: " + inMessage.getClass().getName());
            }
        } catch (Throwable t) {
            t.printStackTrace();
            mdc.setRollbackOnly();
            
            try {
                if (qconn != null) qconn.close();
                System.out.println("MESSAGE BEAN: Rollback: index="+((TextMessage)inMessage).getText());
            } catch (Exception e) {
                System.out.println("MESSAGE BEAN: Unable to get index property because:"+e.getMessage());
                e.printStackTrace();
                
            }
            throw new RuntimeException(t.getMessage());
        }
        
    } // onMessage
    /**
     * Removes the bean. Required by EJB spec.
     */
    public void ejbRemove() {
        System.out.println("TestBean.remove()");
    }
} // class
 
 
sun-ejb-jar.xml
 
 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 EJB 3.0//EN" "http://www.sun.com/software/appserver/dtds/sun-ejb-jar_3_0-0.dtd <http://www.sun.com/software/appserver/dtds/sun-ejb-jar_3_0-0.dtd> ">
<sun-ejb-jar>
  <enterprise-beans>
    <ejb>
      <ejb-name>TestBeanMDB</ejb-name>
      <jndi-name>TestBeanMDB</jndi-name>
      <resource-ref>
        <res-ref-name>jms/MyQueueConnectionFactory</res-ref-name>
        <jndi-name>jms/MyQCF</jndi-name>
      </resource-ref>
      <resource-env-ref>
    <resource-env-ref-name>jms/OutQueue</resource-env-ref-name>
    <jndi-name>jms/OutQueue</jndi-name>
      </resource-env-ref>
      <bean-pool>
        <steady-pool-size>10</steady-pool-size>
        <resize-quantity>2</resize-quantity>
        <max-pool-size>30</max-pool-size>
        <pool-idle-timeout-in-seconds>60</pool-idle-timeout-in-seconds>
      </bean-pool>
      <mdb-resource-adapter>
        <resource-adapter-mid>genericra</resource-adapter-mid>
        <activation-config>
          <activation-config-property>
            <activation-config-property-name>DestinationType</activation-config-property-name>
            <activation-config-property-value>javax.jms.Queue</activation-config-property-value>
          </activation-config-property>
          <activation-config-property>
            <activation-config-property-name>MaxPoolSize</activation-config-property-name>
            <activation-config-property-value>30</activation-config-property-value>
          </activation-config-property>
          <activation-config-property>
            <activation-config-property-name>RedeliveryAttempts</activation-config-property-name>
            <activation-config-property-value>3</activation-config-property-value>
          </activation-config-property>
          <activation-config-property>
            <activation-config-property-name>RedeliveryInterval</activation-config-property-name>
            <activation-config-property-value>1</activation-config-property-value>
          </activation-config-property>
          <activation-config-property>
            <activation-config-property-name>ReconnectAttempts</activation-config-property-name>
            <activation-config-property-value>1000</activation-config-property-value>
          </activation-config-property>
          <activation-config-property>
            <activation-config-property-name>ReconnectInterval</activation-config-property-name>
            <activation-config-property-value>1</activation-config-property-value>
          </activation-config-property>
          <activation-config-property>
            <activation-config-property-name>DestinationJndiName</activation-config-property-name>
            <activation-config-property-value>/queue/A</activation-config-property-value>
          </activation-config-property>
          <activation-config-property>
            <activation-config-property-name>ConnectionFactoryJndiName</activation-config-property-name>
            <activation-config-property-value>java:/XAConnectionFactory</activation-config-property-value>
          </activation-config-property>
        </activation-config>
      </mdb-resource-adapter>
    </ejb>
  </enterprise-beans>
</sun-ejb-jar>
 
 
ejb-jar.xml
 
 
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee <http://java.sun.com/xml/ns/j2ee> " xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance <http://www.w3.org/2001/XMLSchema-instance> " xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee <http://java.sun.com/xml/ns/j2ee> http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd <http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd> ">
  <display-name>queue2queue</display-name>
 <enterprise-beans>
 <message-driven>
<ejb-name>TestBeanMDB</ejb-name>
<ejb-class>com.sun.inout.TestBean</ejb-class>
<transaction-type>Container</transaction-type>
<message-destination-type>javax.jms.Queue</message-destination-type>
<message-destination-link>java:/XAConnectionFactory</message-destination-link>
 <resource-ref>
<description>Queue Connection factory where the message will be placed having been consumed.</description>
<res-ref-name>jms/MyQueueConnectionFactory</res-ref-name>
<res-type>javax.jms.QueueConnectionFactory</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
 <resource-env-ref>
<description>The actual queue on the broker that the message is placed onto.</description>
<resource-env-ref-name>jms/OutQueue</resource-env-ref-name>
<resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
</resource-env-ref>
</message-driven>
</enterprise-beans>
 <assembly-descriptor>
 <container-transaction>
<description>This value was set as a default by Sun ONE Studio.</description>
 <method>
<ejb-name>MyBean</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
 <message-destination>
<display-name>Destination for QueueConsumer</display-name>
<message-destination-name>java:/XAConnectionFactory</message-destination-name>
</message-destination>
</assembly-descriptor>
</ejb-jar>

 
 
 
 
 
 
Thanks & Regards ,
 
Rajesh S
Software Engineer



This electronic mail (including any attachment thereto) may be confidential and privileged and is intended only for the individual or entity named above. Any unauthorized use, printing, copying, disclosure or dissemination of this communication may be subject to legal restriction or sanction. Accordingly, if you are not the intended recipient, please notify the sender by replying to this email immediately and delete this email (and any attachment thereto) from your computer system...Thank You