Forum Stats

  • 3,757,818 Users
  • 2,251,272 Discussions
  • 7,869,925 Comments

Discussions

Cannot find symbol for some jms methods

886634
886634 Member Posts: 14
edited Sep 6, 2011 7:24PM in Java Message Service (JMS)
Hi, I'm new to JMS and am having trouble compiling the HelloWorld example. I am able to create a connection but for some reason I cannot create a session from the same connection. I am however able to call some of the other methods such as getClientID, start, and close. Below is a copy of what i have compiled so far (which is basically a copy of the example code), the error message I get, and what I have CLASSPATH set to. If my CLASSPATH is not set correctly, I would assume none of the code would compile which is very confusing. Any help is appreciated, thanks!


//Step 1:
//Import the JMS API classes.
import javax.jms.ConnectionFactory;
import javax.jms.Connection;
import javax.jms.Session;
import javax.jms.MessageProducer;
import javax.jms.MessageConsumer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.Message;
import javax.jms.TextMessage;
import javax.jms.*;
//Import the classes to use JNDI.
import javax.naming.*;
import java.util.*;



public class HelloWorldMessage
{
public static void main(String[] args){
System.out.println("Hello World!");
try{

Queue myQueue;

// Instantiate a Oracle GlassFish(tm) Server Message Queue ConnectionFactory administered object
com.sun.messaging.ConnectionFactory myConnFactory = new com.sun.messaging.ConnectionFactory();



// Create a connection to the Oracle GlassFish(tm) Server Message Queue Message Service.
Connection myConn = myConnFactory.createConnection();
myConn.getClientID();

// Create a session within the connection.
Session mySess = myConn.createSession(false, Session.AUTO_ACKNOWLEDGE);


myQueue = new com.sun.messaging.Queue("world");

myConn.close();

}
catch(Exception jmse){
System.out.println("Exception occurred : " + jmse.toString());
jmse.printStackTrace();
}
}
}

# javac HelloWorldMessage.java
HelloWorldMessage.java:39: cannot find symbol
symbol : method createSession(boolean,int)
location: interface javax.jms.Connection
Session mySess = myConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
^
1 error




# echo $CLASSPATH
.:/usr/java/default/j2sdkee1.3/lib/j2ee.jar:/usr/java/default/j2sdkee1.3/lib/:/root/MessageQueue/mq/lib/fscontext.jar:/usr/lib/jvm-exports/java-1.6.0-openjdk-1.6.0.0.x86_64/jndi.jar:/root/MessageQueue/mq/lib/jms.jar:/root/MessageQueue/mq/lib/imq.jar:/root/MessageQueue/mq/lib/jaxm-api.jar:/root/MessageQueue/mq/lib/imqxm.jar:/root/MessageQueue/mq/lib/imqservlet.jar

Edited by: 883631 on Sep 6, 2011 4:03 PM

Answers

This discussion has been closed.