problem retrieving Topic from JNDI
wansbrough Feb 17, 2004 2:27 PMI am trying to get a Topic to use with a MB.
I am getting a ClassCastException, I have already noticed that others have got this problem too, but the the responses did not help my problem. And I have even bought a JBoss Administration book incase there was something I missed but all to no avail. Below I list the output,code,and xml that may help to find problem.
OUTPUT
Starting Client . . .
Looking up the JMS destination(Topic) via JNDI.
java.lang.ClassCastException
java.lang.ClassCastException
at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:293)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:134)
at day14.Client.main(Client.java:24)
I am simply trying to get a topic using jndi.
This is how I am running it:
java -classpath C:\jboss-3.2.2\server\default\lib\jnpserver.jar;C:\jboss-3.2.2\lib\jboss-common.jar;C:\jboss-3.2.2\server\default\lib\jboss-j2ee.jar;C:\JavaStuff\EJB\day05\build day14.Client
Should I being using the server jars for running the client? Are there client equivs somewhere?
Below is my code:
###############################Client.java########
package day14;
import javax.jms.*;
import javax.naming.*;
import javax.ejb.*;
import java.util.*;
import day11.OrderHome;
import day11.Order;
public class Client {
public static void main(String[] args)
{
print("Starting Client . . .");
try
{
String orderVerifierJndiName = "topic/OrderVerifierTopic";
//String orderVerifierJndiName = "testTopic";
print("Looking up the JMS destination(Topic) via JNDI.");
Context context = new InitialContext();
//Topic topic = (javax.jms.Topic) context.lookup
(OrderVerifierJndiName);
Object o = context.lookup(orderVerifierJndiName);
Topic topic = (Topic) javax.rmi.PortableRemoteObject.narrow
(o,Topic.class);
}
catch(Exception ex) {
System.err.println(ex);
ex.printStackTrace();
}
}
static void print(String s) {
System.out.println(s);
}
}##############################jboss.xml
........
<message-driven>
<ejb-name>OrderVerifierMDB</ejb-name>
<destination-jndi-name>topic/OrderVerifierTopic</destination-jndi-name>
<jndi-name>day14/OrderVerifierMDB</jndi-name>
</message-driven>.
............
################################ejb-jar.xml
............
<message-driven>
<ejb-name>OrderVerifierMDB</ejb-name>
<ejb-class>day14.OrderVerifierMDB</ejb-class>
<transaction-type>Container</transaction-type>
<message-driven-destination>
<destination-type>javax.jms.Topic</destination-type>
<subscription-durability>NonDurable</subscription-durability>
</message-driven-destination>
</message-driven>..........
###############################jbossmq-destinations-service.xml
.........................
<depends optional-attribute-name = "DestinationManager">
jboss.mq:service=DestinationManager
...................................
#################################
.