Problems with establishing a connection to the TopicConnecti
piotrs Feb 11, 2002 10:45 AMhej,
i'm running a client program which is supposed to publish a message and a mesage-driven bean that is supposed to handle this message.
when i run my client program i get the following exception:
javax.naming.CommunicationException [Root
exception is java.rmi.UnmarshalException: error unmarshalling return;
nested exception is:
java.lang.ClassNotFoundException:
org.jboss.mq.referenceable.ObjectRefAddr (no security manager: RMI
class loader disabled)]
javax.naming.CommunicationException. Root exception is
java.rmi.UnmarshalException: error unmarshalling return; nested
exception is:
java.lang.ClassNotFoundException:
org.jboss.mq.referenceable.ObjectRefAddr (no security manager: RMI
class loader disabled)
java.lang.ClassNotFoundException:
org.jboss.mq.referenceable.ObjectRefAddr (no security manager: RMI
class loader disabled)
at sun.rmi.server.LoaderHandler.loadClass
(LoaderHandler.java:318)
at sun.rmi.server.LoaderHandler.loadClass
(LoaderHandler.java:132)
at sun.rmi.server.MarshalInputStream.resolveClass
(MarshalInputStream.java:143)
at java.io.ObjectInputStream.inputClassDescriptor
(ObjectInputStream.java:918)
at java.io.ObjectInputStream.readObject
(ObjectInputStream.java:366)
at java.io.ObjectInputStream.readObject
(ObjectInputStream.java:236)
at java.io.ObjectInputStream.inputObject
(ObjectInputStream.java:1186)
at java.io.ObjectInputStream.readObject
(ObjectInputStream.java:386)
at java.io.ObjectInputStream.inputArray
(ObjectInputStream.java:1142)
at java.io.ObjectInputStream.readObject
(ObjectInputStream.java:374)
at java.io.ObjectInputStream.inputClassFields
(ObjectInputStream.java:2263)
at java.io.ObjectInputStream.defaultReadObject
(ObjectInputStream.java:519)
at java.io.ObjectInputStream.inputObject
(ObjectInputStream.java:1412)
at java.io.ObjectInputStream.readObject
(ObjectInputStream.java:386)
at java.io.ObjectInputStream.inputClassFields
(ObjectInputStream.java:2263)
at java.io.ObjectInputStream.defaultReadObject
(ObjectInputStream.java:519)
at java.io.ObjectInputStream.inputObject
(ObjectInputStream.java:1412)
at java.io.ObjectInputStream.readObject
(ObjectInputStream.java:386)
at java.io.ObjectInputStream.readObject
(ObjectInputStream.java:236)
at sun.rmi.server.UnicastRef.unmarshalValue
(UnicastRef.java:300)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:134)
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup
(NamingContext.java:349)
at org.jnp.interfaces.NamingContext.lookup
(NamingContext.java:333)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at com.videlity.Client.main(Client.java:28)
Process terminated with exit code 0
My aplication has the following code:
//client program
public class Client {
public static void main(String[] args) throws Exception {
try {
// Populate with needed properties
Hashtable props = new Hashtable();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
props.put(Context.PROVIDER_URL, "localhost:1099");
props.put("java.naming.rmi.security.manager", "yes");
props.put(Context.URL_PKG_PREFIXES,
"org.jboss.naming");
Context ctx = new InitialContext(props);
TopicConnectionFactory factory =
(TopicConnectionFactory)
ctx.lookup("ConnectionFactory");
TopicConnection connection =
factory.createTopicConnection();
TopicSession session =
connection.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
Topic topic =
(Topic) ctx.lookup("testtopic/testTopic");
TopicPublisher publisher =
session.createPublisher(topic);
TextMessage msg = session.createTextMessage();
msg.setText("Hello world!");
publisher.publish(msg);
} catch(Exception e) {
e.printStackTrace();
}
}
}
//message-driven bean
public class EventManager implements MessageDrivenBean,
MessageListener {
protected MessageDrivenContext ctx;
public void setMessageDrivenContext
(MessageDrivenContext ctx) {
this.ctx = ctx;
}
public void onMessage(Message msg) {
if(msg instanceof TextMessage) {
TextMessage tm = (TextMessage) msg;
try {
String text = tm.getText();
System.err.println("Received a message: " + text);
} catch(JMSException e) {
System.out.println("[EventHandler] Could not get
message: " + e);
e.printStackTrace();
}
}
}
public void ejbCreate() {
System.out.println("ejbCreate() called...");
}
public void ejbRemove() {
System.out.println("ejbRemove() called...");
}
}
//ejb-jar.xml
<ejb-jar>
<enterprise-beans>
<message-driven>
<ejb-name>EventManagerEJB</ejb-name>
<ejb-class>com.videlity.jms.EventManager</ejb-class>
<message-selector></message-selector>
<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>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<ejb-name>EventManagerEJB</ejb-name>
<method-name>*</method-name>
<trans-attribute>NotSupported</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
//jboss.xml
<enterprise-beans>
<message-driven>
<ejb-name>EventManagerEJB</ejb-name>
<configuration-name>Standard Message Driven Bean</configuration-
name>
<destination-jndi-name>topic/testTopic</destination-jndi-name>
</message-driven>
</enterprise-beans>
can anybody see what i'm doing wrong
best regards piotr