File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Connecting JMS through Applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Connecting JMS through Applet" Watch "Connecting JMS through Applet" New topic
Author

Connecting JMS through Applet

Jithesh Kozhipurath
Ranch Hand

Joined: Aug 27, 2003
Posts: 76
While connecting with JMS through an Applet, the following error is taking place. But when we connected through JAVA application its working fine. The code is attached.
javax.naming.NamingException: Couldn't connect to any host. Root exception is org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 203 completed: No at com.sun.corba.se.internal.iiop.IIOPConnection.writeLock(IIOPConnection.java:562)
at com.sun.corba.se.internal.iiop.BufferManagerWriteGrow.sendMessage(BufferManagerWriteGrow.java:55)
at com.sun.corba.se.internal.iiop.IIOPOutputStream.finishSendingMessage(IIOPOutputStream.java:159)
at com.sun.corba.se.internal.iiop.IIOPOutputStream.invoke(IIOPOutputStream.java:117)
at com.sun.corba.se.internal.iiop.ClientRequestImpl.invoke(ClientRequestImpl.java:76)
at com.sun.corba.se.internal.corba.ClientDelegate.invoke(ClientDelegate.java:229)
at com.sun.corba.se.internal.corba.ClientDelegate.invoke(ClientDelegate.java:271)
at com.sun.corba.se.internal.corba.InitialNamingClient.resolve(InitialNamingClient.java:1016)
at com.sun.corba.se.internal.corba.InitialNamingClient.resolveUsingBootstrapProtocol(InitialNamingClient.java:687)
at com.sun.corba.se.internal.corba.InitialNamingClient.cachedInitialReferences(InitialNamingClient.java:1085)
at com.sun.corba.se.internal.corba.InitialNamingClient.resolve_initial_references(InitialNamingClient.java:978)
at com.sun.corba.se.internal.corba.ORB.resolve_initial_references(ORB.java:2422)
at weblogic.corba.j2ee.naming.ORBHelper.getORBReferenceWithRetry(ORBHelper.java:476)
at weblogic.corba.j2ee.naming.ORBHelper.getORBReference(ORBHelper.java:455)
at weblogic.corba.j2ee.naming.InitialContextFactoryImpl.getInitialContext(InitialContextFactoryImpl.java:97)
at weblogic.corba.j2ee.naming.InitialContextFactoryImpl.getInitialContext(InitialContextFactoryImpl.java:42)
at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:41)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
at javax.naming.InitialContext.init(InitialContext.java:219)
at javax.naming.InitialContext.<init>(InitialContext.java:195)
at AsyncTopicReceiver.initialise(AsyncTopicReceiver.java:35)
at AsyncTopicReceiver.main(AsyncTopicReceiver.java:112)
Caught an unexpected exceptionjavax.naming.NamingException: Couldn't connect to any host [Root exception is org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code : 203 completed: No]

The Code:
AppletEx.java
--------------

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.net.*;
import javax.swing.JTable;
import javax.swing.JScrollPane;
/*
<APPLET code="AppletEx.class" WIDTH="200" HEIGHT="300" >
</APPLET>
*/
public class AppletEx extends Applet {
public void init()
{
}
public void start()
{

AsyncTopicReceiver asyncTopicReceiver = new AsyncTopicReceiver();
System.out.println("AsyncTopicReceiver Started");
asyncTopicReceiver.startEx();
System.out.println("AsyncTopicReceiver Ends");
}
}
------------------------
AsyncTopicReceiver.java
------------------------
import javax.naming.Context;
import javax.naming.InitialContext;

import javax.jms.*;
import javax.jms.TopicConnectionFactory;
import javax.jms.TopicConnection;
import javax.jms.MessageListener;
import javax.jms.TopicSession;
import javax.jms.TopicSubscriber;
import javax.jms.Topic;
import javax.jms.Message;
import javax.jms.TextMessage;
import javax.jms.ObjectMessage;
import javax.jms.JMSException;
import java.util.Properties;
public class AsyncTopicReceiver implements MessageListener
{
TopicConnectionFactory topicConnectionFactory;
TopicConnection topicConnection;
TopicSession topicSession;
TopicSubscriber topicSubscriber;
Topic topic;
boolean finished = false;
String msg;
public void initialise(){
try{

System.out.println("Starting Main");
Properties h = new Properties();
h.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
h.put(Context.PROVIDER_URL, "t3://localhost:7001");
Context initial = new InitialContext(h);
topicConnectionFactory = (TopicConnectionFactory)initial.lookup("TestJMSConnectionFactory");
topicConnection = topicConnectionFactory.createTopicConnection();
topicSession = topicConnection.createTopicSession(false,javax.jms.TopicSession.AUTO_ACKNOWLEDGE);

topic = (Topic)initial.lookup("TestJMSTopic");
topicSubscriber = topicSession.createSubscriber(topic);
topicSubscriber.setMessageListener(this);
topicConnection.start();
}
catch (Exception e){
e.printStackTrace();
System.out.println("Caught an unexpected exception" + e);
}
}
public void onMessage(Message message){

System.out.println("This is onMessage method");
try{
if(message instanceof TextMessage){

TextMessage txtMsg = (TextMessage) message;
System.out.println("Message received : " + txtMsg.getText());
System.in.read();
}
if(message instanceof ObjectMessage){
ObjectMessage objMsg = (ObjectMessage) message;
System.out.println("Message received : " + objMsg.getObject());
msg= objMsg.getObject().toString();
System.in.read();
}
}
catch (Exception e){
e.printStackTrace();
System.out.println("Exception in onMessage" + e);
}
}
public void close() throws JMSException{
try{
topicSubscriber.close();
topicSession.close();
topicConnection.close();
}
catch(Exception e){
System.out.println("Exception " + e);
}
}
public void startEx(){
try{
AsyncTopicReceiver test = new AsyncTopicReceiver();
test.initialise();
System.out.println("ready to receive messages");
synchronized(test){
while (!test.finished){
try{
test.wait();
}
catch(InterruptedException ex){
}
}
test.close();
}
}
catch(JMSException ex){
System.out.println("JMSException : " + ex);
}
}
public static void main(String[] args){
try{
AsyncTopicReceiver test = new AsyncTopicReceiver();
test.initialise();
System.out.println("ready to receive messages");
synchronized(test){
while (!test.finished){
try{
test.wait();
}
catch(InterruptedException ex){
}
}
test.close();
}
}
catch(JMSException ex){
System.out.println("JMSException : " + ex);
}
}
/**
* @return
*/
public String getMsg() {
return msg;
}
/**
* @param string
*/
public void setMsg(String string) {
msg = string;
}
}


Jithesh K
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

sandbox - signed applet problem?


http://home.arcor.de/hirnstrom/bewerbung
Jithesh Kozhipurath
Ranch Hand

Joined: Aug 27, 2003
Posts: 76
I have written a sign certificate for the program and registered.
But still it generates the same exception.
This is what I used to sign the applet
--------------------------------------
jar cvf SignedApplet.jar *.class
keytool -genkey -alias signFiles -keystore susanstore -keypass kpi135 -dname "cn=jones" -storepass ab987c
jarsigner -keystore susanstore -storepass ab987c -keypass kpi135 -signedjar Smapplet.jar SignedApplet.jar signFiles
keytool -export -keystore susanstore -storepass ab987c -alias signFiles -file SusanJones.cer
Thanx in advance.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Connecting JMS through Applet