Hi Johan,

I have moved step forward but no thru yet.

I am getting the following error now.

On executing the program, the client side messages are displayed and on the
server side the messages for constructor as well as the ejbCreate() message
is displayed. But the onMessage() method is not invoked. This might mean
that the message is not being sent into the queue. But cannot figure why.

Following is the entire source code and deployment descriptors

Problem Definition : Failure to execute the onMessage() method of theMessage
Driven Bean deployed on BEA Weblogic Server v7.0

Steps taken till now :
�       The Bean class for Message Driven Bean (MDB) and the client coded.
�       The Bean and the client compiled and a JAR file created.
�       The created JAR file deployed on the Web logic Server.
�       On execution of the client, the message to be sent by the client
displayed. On the server side, the constructor of the MDB is called. Also
the ejbCreate() method is called. But the onMessage() method is not called.

Details of Steps taken:
The source of MDB and Client-----
Source of MDB �

package trials;

import javax.ejb.*;
import javax.jms.*;
import javax.naming.*;

public class BPmdbBean implements MessageDrivenBean, MessageListener
{

  MessageDrivenContext messageDrivenContext = null;

  public BPmdbBean ()
  {
    System.out.println("Inside the constructor...");
  }

  public void setMessageDrivenContext(MessageDrivenContext
messageDrivenContext)
  {
    this.messageDrivenContext = messageDrivenContext;
  }

  public void ejbCreate() throws CreateException
  {
    System.out.println("This is ejbCreate()...");
  }

  public void onMessage(Message inMessage)
  {
    TextMessage msg = null;
    try
    {
        if (inMessage instanceof TextMessage)
        {
            msg = (TextMessage) inMessage;
            System.out.println("MESSAGE BEAN: Message received: " +
msg.getText());
        }
        else
            System.out.println("Message of wrong type: " +
inMessage.getClass().getName());
    }
    catch (JMSException e)
    {
        e.printStackTrace();
        messageDrivenContext.setRollbackOnly();
    }
    catch (Throwable te)
    {
        te.printStackTrace();
    }
  }

  public void ejbRemove()
  {
    System.out.println("This is ejbRemove()...");
  }

}


Source of the Client �

package trials;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: </p>
 * @version 1.0
 */

import javax.naming.*;
import javax.jms.*;

public class msgClient
{
  msgClient msgClientObject = new msgClient();

  public static void main (String[] args) throws Exception
  {
    System.out.println("About to run client" ) ;

    String url = "t3://223.255.255.107:7001";

    java.util.Properties properties = System.getProperties();
    properties.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
    properties.put(Context.PROVIDER_URL, url);

    Context ctx = new InitialContext ( properties );
    QueueConnectionFactory factory = null;
    Queue queue = null;

 (QueueConnectionFactory)ctx.lookup("javax.jms.TopicConnectionFactory");

 factory = ( QueueConnectionFactory ) ctx.lookup
("NewQueueConnectionFactory" ) ;

 QueueConnection connection = factory.createQueueConnection();

QueueSession session = connection.createQueueSession(false,
Session.AUTO_ACKNOWLEDGE);


try
{
        queue = ( Queue ) ctx.lookup ( "NewJMSQueue" ) ;
 }
 catch ( NamingException ne )
 {
        queue = session.createQueue("NewJMSQueue");
        ctx.bind("NewJMSQueue", queue);
  }

    QueueSender queueSender = session.createSender(queue);

    TextMessage message = session.createTextMessage();
    for (int i = 0; i < 5; i++)
    {
      message.setText("This is message " + (i + 1));
      System.out.println("Sending message: " + message.getText());
      queueSender.send(message);
      System.out.println("message sent");
    }
  }

  public msgClient()
  {
    try
    {
      jbInit();
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }
  private void jbInit() throws Exception
  {
  }
}



The configurations on the Weblogic Server:
For the Connection Factory:
Name : NewQueueConnectionFactory
JNDI Name : NewQueueConnectionFactory
Client Id :
Default Priority : 4
Default Time To Live : 0
Default Time To Deliver : 0
Default Delivery Mode  : Persistent
Defualt ReDelivery Delay : 0
Messages Maximum : 10
Overrun Policy : Keep Old
(Not Checked) Allow Close In On Message
Acknowledge Policy: All
(Checked) Load Balancing Enabled
(Checked ) Server Affinity Enabled

The target server specified

Stores
Name : NewJDBCStore
Connection Pool : SamplePool


Servers
Name : NewJMSServer
Store : NewJDBCStore
Paging Store : none
Temporary template : none

Target server specified

Destinations
Name : NewJMSQueue
JNDI Name : NewJMSQueue
Enable Store: default
Template: none
Destination Keys : none

(The properties not mentioned all set to default values)

The properties set in JBuilder for creating the JAR file are as follows:

Message Driven Bean

Transaction Type : Container
Connection Factory Name : NewQueueConnectionFactory
Destination Name :  NewJMSQueue
Destination Type :  javax.jms.Queue

Initial Pool Size : 1
Maximum Pool Size :  10
Wait Time Out : 0


Message Drive Bean : Resource References

Name : NewQueueConnectionFactory
Type : javax.jms.QueueConnectionFactory
Authentication :  Container
Sharing Scope : Shareable
JNDI Name : NewQueueConnectionFactory

Message Driven Bean : Resource Env Refs

Resource Environment Ref Name : NewJMSQueue
Type :  javax.jms.Queue
JNDI Name: NewJMSQueue

The deployment descriptors are as follows :

ejb-jar.xml

<ejb-jar>
    <enterprise-beans>
        <message-driven>
            <display-name>BPmdbBean</display-name>
            <ejb-name>BPmdbBean</ejb-name>
            <ejb-class>trials.BPmdbBean</ejb-class>
            <transaction-type>Container</transaction-type>
            <message-driven-destination>
                <destination-type>javax.jms.Queue</destination-type>
            </message-driven-destination>
            <resource-ref>
                <description />
                <res-ref-name>NewQueueConnectionFactory</res-ref-name>
                <res-type>javax.jms.QueueConnectionFactory</res-type>
                <res-auth>Container</res-auth>
            </resource-ref>
            <resource-env-ref>
                <description />
                <resource-env-ref-name>NewJMSQueue</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>
            <method>
                <ejb-name>BPmdbBean</ejb-name>
                <method-name>*</method-name>
            </method>
            <trans-attribute>Required</trans-attribute>
        </container-transaction>
    </assembly-descriptor>
    <ejb-client-jar>msgclient.jar</ejb-client-jar>
</ejb-jar>


weblogic-ejb-jar.xml

<weblogic-ejb-jar>
    <weblogic-enterprise-bean>
        <ejb-name>BPmdbBean</ejb-name>
        <message-driven-descriptor>
            <pool>
                <max-beans-in-free-pool>10</max-beans-in-free-pool>
                <initial-beans-in-free-pool>1</initial-beans-in-free-pool>
            </pool>
            <destination-jndi-name>NewJMSQueue</destination-jndi-name>

<connection-factory-jndi-name>NewQueueConnectionFactory</connection-factory-
jndi-name>
        </message-driven-descriptor>
        <reference-descriptor>
            <resource-description>
                <res-ref-name>NewQueueConnectionFactory</res-ref-name>
                <jndi-name>NewQueueConnectionFactory</jndi-name>
            </resource-description>
            <resource-env-description>
                <res-env-ref-name>NewJMSQueue</res-env-ref-name>
                <jndi-name>NewJMSQueue</jndi-name>
            </resource-env-description>
        </reference-descriptor>
    </weblogic-enterprise-bean>
</weblogic-ejb-jar>

Any help will be appreciated.

Regards
Rohit

-----Original Message-----
From: Johan Eltes [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 27, 2003 11:11 PM
To: Rohit Parik
Subject: Re: MDB invocation error


You can only use the java:comp/env context within a j2ee container. Your
client code seem to execute as a plain java main class. If your main is not
started within an application client container, you should change
"java:comp/env/jms/NewQueueConnectionFactory" and
"java:comp/env/jms/NewJMSQueue" to the external jndi names, to which you
have bound the logical names.

/Johan

Den 2003-01-27 18.07, skrev "Rohit Parik" <[EMAIL PROTECTED]>:

> Hi All,
>
> Need some help with invoking an MDB on WLS. We setup everything by the
book.
> Cant understand what we are doing wrong.
>
> Problem Definition : Failure to execute the Message Driven Bean deployed
on
> BEA Weblogic Server v7.0
>
> Source code for the MDB
> Source of MDB �
>
> import javax.ejb.*;
> import javax.jms.*;
> import javax.naming.*;
>
> public class BPmdbBean implements MessageDrivenBean, MessageListener
> {
>
> MessageDrivenContext messageDrivenContext = null;
> public BPmdbBean ()
> {
>   System.out.println("Inside the constructor...");
> }
>
> public void setMessageDrivenContext(MessageDrivenContext
> messageDrivenContext)
> {
>   this.messageDrivenContext = messageDrivenContext;
> }
>
> public void ejbCreate() throws CreateException
> {
>   System.out.println("This is ejbCreate()...");
> }
>
> public void onMessage(Message inMessage)
> {
>   TextMessage msg = null;
>   try
>   {
>       if (inMessage instanceof TextMessage)
>       {
>           msg = (TextMessage) inMessage;
>           System.out.println("MESSAGE BEAN: Message received: " +
> msg.getText());
>       }
>       else
>           System.out.println("Message of wrong type: " +
> inMessage.getClass().getName());
>   }
>   catch (JMSException e)
>   {
>       e.printStackTrace();
>       messageDrivenContext.setRollbackOnly();
>   }
>   catch (Throwable te)
>   {
>       te.printStackTrace();
>   }
> }
>
> public void ejbRemove()
> {
>   System.out.println("This is ejbRemove()...");
> }
> }
>
> Source of the Client �
> import javax.naming.*;
> import javax.jms.*;
>
> public class msgClient
> {
> msgClient msgClientObject = new msgClient();
> public static void main (String[] args) throws Exception
> {
>   System.out.println("About to run client" ) ;
>
>   String url = "t3://223.255.255.194:7001";
>
>   java.util.Properties properties = System.getProperties();
>   properties.put(Context.INITIAL_CONTEXT_FACTORY,
> "weblogic.jndi.WLInitialContextFactory");
>   properties.put(Context.PROVIDER_URL, url);
>
>   Context ctx = new InitialContext ( properties );
>   QueueConnectionFactory factory = null;
>   Queue queue = null;
>
>    try
>   {
>     factory = (QueueConnectionFactory ) ctx.lookup
> ("java:comp/env/jms/NewQueueConnectionFactory");
>
>     queue = ( Queue ) ctx.lookup ( "java:comp/env/jms/NewJMSQueue" ) ;
>   }
>   catch (NamingException e)
>   {
>     System.out.println("JNDI lookup failed.. " + e.toString());
>     System.exit(1);
>   }
>
>   QueueConnection connection = factory.createQueueConnection();
>
>   QueueSession session = connection.createQueueSession(false,
> Session.AUTO_ACKNOWLEDGE);
>
>   QueueSender queueSender = session.createSender(queue);
>
>   TextMessage message = session.createTextMessage();
>   for (int i = 0; i < 5; i++)
>   {
>     message.setText("This is message " + (i + 1));
>     System.out.println("Sending message: " + message.getText());
>     queueSender.send(message);
>   }
> }
>
> public msgClient()
> {
>   try
>   {
>     jbInit();
>   }
>   catch(Exception e)
>   {
>     e.printStackTrace();
>   }
> }
> private void jbInit() throws Exception
> {
> }
> }
>
> The configurations on the Weblogic Server:
> For the Connection Factory:
> Name : NewQueueConnectionFactory
> JNDI Name : NewQueueConnectionFactory
> Client Id :
> Default Priority : 4
> Default Time To Live : 0
> Default Time To Deliver : 0
> Default Delivery Mode  : Persistent
> Defualt ReDelivery Delay : 0
> Messages Maximum : 10
> Overrun Policy : Keep Old
> (Not Checked) Allow Close In On Message
> Acknowledge Policy: All
> (Checked) Load Balancing Enabled
> (Checked ) Server Affinity Enabled
>
> The target server specified
>
> Stores
> Name : NewJDBCStore
> Connection Pool : SamplePool
>
>
> Servers
> Name : NewJMSServer
> Store : NewJDBCStore
> Paging Store : none
> Temporary template : none
>
> Target server specified
>
> Destinations
> Name : NewJMSQueue
> JNDI Name : NewJMSQueue
> Enable Store: default
> Template: none
> Destination Keys : none
>
> (The properties not mentioned all set to default values)
>
> On execution of the client program error occurs.
> The error is : Naming Exception
>
> The class name should be specified in the environment properties file or
in
> applet parameter
> This error occurs on reaching the code for lookup in the client code.
>
> Any help is welcome.
>
> Regards
> Rohit
>
>
===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff EJB-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to