Topic
  • 2 replies
  • Latest Post - ‏2007-04-13T04:44:34Z by pkt
pkt
pkt
2 Posts

Pinned topic JMS Error

‏2007-04-03T04:59:20Z |
Hi All
I am new to JMS. I am trying to write a program that will send messages using JMS. I am using Sun Application Server 9.0 ( deployed on a remote machine). I am using netbeans 5.5 to run the program. I have done the following configurations on the server using admin console
1) created a connection Factory having name jms/test
2) Created a queue having name jms/test.

However when i run the program i get execeptions. The full stacktrace is as follows:
[i]
init:
deps-jar:
Compiling 1 source file to D:\javastudio\workspace-myapp\JMSTest\build\classes
compile-single:
run-single:
Queue name is jms/testdest
Apr 2, 2007 4:59:01 PM com.sun.corba.ee.spi.logging.LogWrapperBase doLog
INFO: "IOP00710299: (INTERNAL) Successfully created IIOP listener on the specified host/port: all interfaces/3266"
Apr 2, 2007 4:59:01 PM com.sun.corba.ee.impl.protocol.giopmsgheaders.MessageBase readGIOPHeader
WARNING: "IOP00710220: (INTERNAL) Error in GIOP magic"
org.omg.CORBA.INTERNAL: vmcid: SUN minor code: 220 completed: Maybe
at com.sun.corba.ee.impl.logging.ORBUtilSystemException.giopMagicError(ORBUtilSystemException.java:4324)
at com.sun.corba.ee.impl.logging.ORBUtilSystemException.giopMagicError(ORBUtilSystemException.java:4338)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.MessageBase.readGIOPHeader(MessageBase.java:163)
at com.sun.corba.ee.impl.transport.CorbaContactInfoBase.createMessageMediator(CorbaContactInfoBase.java:153)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.readBits(SocketOrChannelConnectionImpl.java:325)
JNDI API lookup failed: javax.naming.CommunicationException: Can't find SerialContextProvider Root exception is org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 208 completed: Maybe
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.handleEvent(SocketOrChannelConnectionImpl.java:1171)
at com.sun.corba.ee.impl.transport.SelectorImpl.run(SelectorImpl.java:275)
Java Result: 1
BUILD SUCCESSFUL (total time: 6 seconds)

[/i]

The code is given below

code
package jmstest;
import java.util.Properties;
import javax.jms.*;
import javax.naming.*;
public class Main {
public static void main(String[] args) {
Properties systemSettings = System.getProperties();
systemSettings.setProperty("org.omg.CORBA.ORBInitialHost", "172.17.61.63");
systemSettings.setProperty("org.omg.CORBA.ORBInitialPort", "7676");
/*systemSettings.setProperty("java.naming.provider.url","iiop//172.17.61.63:7676");*/
System.setProperties(systemSettings);

String queueName = "jms/testdest";
Context jndiContext = null;
QueueConnectionFactory queueConnectionFactory = null;
QueueConnection queueConnection = null;
QueueSession queueSession = null;
Queue queue = null;
QueueSender queueSender = null;
TextMessage message = null;
final int NUM_MSGS;

System.out.println("Queue name is " + queueName);
try {
/*Properties prop = new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.cosnaming.CNCtxFactory");
prop.put(Context.PROVIDER_URL, "iiop://172.17.61.63:7676/");*/
jndiContext = new InitialContext();
} catch (NamingException e) {
System.out.println("Could not create JNDI API " + "context: "
+ e.toString());
System.exit(1);
}

try {
queueConnectionFactory =
(QueueConnectionFactory) jndiContext.lookup("jms/test");
queue = (Queue) jndiContext.lookup(queueName);
} catch (NamingException e) {
System.out.println("JNDI API lookup failed: " + e.toString());
System.exit(1);
}
try {
queueConnection = queueConnectionFactory.createQueueConnection();
queueSession = queueConnection.createQueueSession(false,0);
queueSender = queueSession.createSender(queue);
message = queueSession.createTextMessage();
message.setText("This is message " );
System.out.println("Sending message: " + message.getText());
queueSender.send(message);

queueSender.send(queueSession.createMessage());
} catch (JMSException e) {
System.out.println("Exception occurred: " + e.toString());
} finally {
if (queueConnection != null) {
try {
queueConnection.close();
} catch (JMSException e) {}
}
}
}
}

[/code]

Any Pointers will be very helpful
Updated on 2007-04-13T04:44:34Z at 2007-04-13T04:44:34Z by pkt
  • SystemAdmin
    SystemAdmin
    4447 Posts

    Re: JMS Error

    ‏2007-04-13T04:26:44Z  
    The "Cannot find SerialContextProvider" error is usually thrown when the client cannot communicate with the target server. Are you sure the Sun App server is running? See http://java.sun.com/products/jms/tutorial/jms_tutorial_faq.html#SerialContext for details.
  • pkt
    pkt
    2 Posts

    Re: JMS Error

    ‏2007-04-13T04:44:34Z  
    The "Cannot find SerialContextProvider" error is usually thrown when the client cannot communicate with the target server. Are you sure the Sun App server is running? See http://java.sun.com/products/jms/tutorial/jms_tutorial_faq.html#SerialContext for details.
    Hi
    The reason for the error was the jar files version on the server and client where not same and imqjmsra.jar was not in the classpath. I just copied the jar files from server to my machine and included them in the path and the program worked. Thanks a lot for your reply and i am sorry for not posting the solution once the problem was solved.

    Thanks and Regards
    Pankaj Tiwari