connect to queue or topic from inside an applet?
hustenbolschen Jul 14, 2004 10:35 AMHello,
I´m trying to send a message to a queue and subscribe to a topic by an applet.
I tried both secure an non secure applets, and it doesn`t work.
Is there a possibilty to do this?
I know I´m only allowed to create an network-connection to the host i load the applet from.
It works all fine when I start the applet with the eclipse applet loader, but inside the browser it fails to connect to the queue. Without Queue connection it works alright.
Here is my applet-code and the Error Messages from the VM.
At first set up context
public void setupContext() throws JMSException, NamingException{ Properties properties = new Properties(); String myServer = lat.getMyServer(); System.out.println("Server: "+myServer.toString()); properties.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory" ) ; properties.setProperty("java.naming.provider.url", "jnp://"+myServer+":1099" ) ; properties.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces" ); InitialContext iniCtx = new InitialContext(properties); Object tmp = iniCtx.lookup("HTTPConnectionFactory"); QueueConnectionFactory qcf = (QueueConnectionFactory) tmp; TopicConnectionFactory tcf = (TopicConnectionFactory) tmp; qConn = qcf.createQueueConnection(); tConn = tcf.createTopicConnection(); queA = (Queue) iniCtx.lookup("queue/A"); queB = (Queue) iniCtx.lookup("queue/B"); topicA = (Topic) iniCtx.lookup("topic/testTopic"); qSession = qConn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE); tSession = tConn.createTopicSession(false,TopicSession.AUTO_ACKNOWLEDGE); }
Then try to send a MapMessage
public void sendMapMessage(){ try { qConn.start(); System.out.println("Begin sendRecvAsync"); // Send a few text msgs to queB QueueSender send = qSession.createSender(queB); Long Time = new Long(System.currentTimeMillis()); String strMessageId = Time.toString(); -->Here it fails? MapMessage mm = qSession.createMapMessage(); mm.setStringProperty("Typ","Firma"); mm.setIntProperty("Id",0); mm.setStringProperty("Action","Create"); mm.setStringProperty("Ort","Gifhorn"); mm.setStringProperty("ServerId","12342345"); mm.setJMSReplyTo(queA); send.send(mm); qConn.stop(); } catch (JMSException e) { // TODO Auto-generated catch block lat.setStatusMsg("MDBComm - Error while sending: "+e.toString()); } System.out.println("End sendRecvAsync"); }
AND the error message:
Begin sendRecvAsync Verbindung http://xx.xxx.xxx.xxx:8080/jbossmq-httpil/HTTPServerILServlet ohne Proxy java.lang.ExceptionInInitializerError at org.jboss.util.property.Property.get(Property.java:87) at org.jboss.util.platform.Constants.<clinit>(Constants.java:23) at org.jboss.util.Strings.<clinit>(Strings.java:31) at org.jboss.mq.SpyMessage.checkProperty(SpyMessage.java:413) at org.jboss.mq.SpyMessage.setStringProperty(SpyMessage.java:516) at liato.web.applet.MDBCommunicator.sendMapMessage(MDBCommunicator.java:89) at liato.web.applet.Liato_Applet.init(Liato_Applet.java:102) at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.security.AccessControlException: access denied (java.util.PropertyPermission java.naming.provider.url read) at java.security.AccessControlContext.checkPermission(Unknown Source) at java.security.AccessController.checkPermission(Unknown Source) at java.lang.SecurityManager.checkPermission(Unknown Source) at java.lang.SecurityManager.checkPropertyAccess(Unknown Source) at java.lang.System.getProperty(Unknown Source) at org.jboss.util.property.PropertyMap.init(PropertyMap.java:93) at org.jboss.util.property.PropertyMap.<init>(PropertyMap.java:73) at org.jboss.util.property.PropertyMap.<init>(PropertyMap.java:81) at org.jboss.util.property.PropertyManager.<clinit>(PropertyManager.java:57) ... 9 more
Thanks for help