Hi Johan, Thanks for the inputs. It works.
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".
