Failed to create session: java.security.AccessControlException

[email protected]
Newsgroups gmane.comp.java.openjms.devel
Message-ID <[email protected]>
Hi,

I have developped a small applet which subscribes to a topic. My openjms server 
is properly running because I am able via a standard java application to 
publish/subscribe to "topic1", receive message using the http configuration 
file...

However from my applet it raises an AccessControlException. Does someone have 
any idea ?

applet source code :
import java.applet.Applet;
import javax.jms.*;
import javax.naming.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;

public class TestJmsApplet extends Applet {
	private TextField subject;
	private TextField data;
	private FlowLayout layout;
	private Button button;
	private InitialContext context;
	private TopicConnectionFactory factory;
	private TopicConnection connection;
	private TopicSession session;
	private Topic topic;
	private TopicSubscriber subscriber;
	private TextMessage message;
	
	/**
	 *
	 **/	
	public void init() {
		
		Hashtable properties = new Hashtable();
		
		try {
			super.init();
		
			properties.put(Context.PROVIDER_URL,"http://127.0.0.1:
8080/openjms/OpenJMSJndi");
			properties.put(Context.INITIAL_CONTEXT_FACTORY,
        						"org.exolab.jms.jndi.http.
HttpJndiInitialContextFactory");
       		properties.put(Context.PROVIDER_URL, "http://127.0.0.1:
8080/openjms/OpenJMSJndi");
       		context = new InitialContext(properties);
       	}
       	catch (Exception e) {
       		e.printStackTrace();
       	}
		
		this.setLayout(new FlowLayout());
		
		subject = new TextField("Enter your subject", 19);
		subject.setVisible(true);
		this.add(subject);
		
		data = new TextField("Data received", 19);
		data.setVisible(true);
		this.add(data);
		
		button = new Button("Subscribe");
		button.setVisible(true);
		button.addMouseListener(new MouseListener() {
			public void mousePressed(MouseEvent e) {
				subscribe();
				start();
				return;		
			}
			
			public void mouseClicked(MouseEvent e) {
			
				return;
			}
			
			public void mouseEntered(MouseEvent e) {
				return;
			}
			
			public void mouseExited(MouseEvent e) {
				return;
			}
			
			public void mouseReleased(MouseEvent e) {
				return;
			}
		});
		
		this.add(button);
		
		this.setVisible(true);
		this.validate();
	}
	
	/**
	 *
	 **/
	public void start() {
		return;	
	}
	
	/**
	 *
	 **/	
	public void paint(Graphics g) {
		return;		
	}
	
	/**
	 *
	 **/	
	public void subscribe() {
		Thread thread;
		String sub = subject.getText();
		subject.setText("Subscribe to " + sub);
		
		try {
			factory 	= (TopicConnectionFactory)context.
lookup("HTTPTopicConnectionFactory");
			connection 	= factory.createTopicConnection();
			connection.start();
			session 	= connection.createTopicSession(false, Session.
AUTO_ACKNOWLEDGE);		
			topic 		= (Topic)context.lookup(sub);	
			subscriber 	= session.createSubscriber(topic);
			thread = new Thread() {
				public void run() {
					try {
						while (true) {
							message = (TextMessage)subscriber.receive();
							data.setText(message.getText());
						}
					}
					catch (Exception e) {
						e.printStackTrace();
					}		
				}
			};
			thread.start();
		}
		catch (Exception e) {
			e.printStackTrace();
		}
		
		
		return;
	}
}

********
Stack trace :
javax.jms.JMSException: Failed to create session: java.security.
AccessControlException: access denied (java.util.PropertyPermission org.exolab.
jms.jndi.http.client.address read)

	at org.exolab.jms.client.http.HttpJmsConnectionStub.
createSession(HttpJmsConnectionStub.java:139)

	at org.exolab.jms.client.JmsSession.<init>(JmsSession.java:225)

	at org.exolab.jms.client.JmsTopicSession.<init>(JmsTopicSession.java:89)

	at org.exolab.jms.client.JmsTopicConnection.
createTopicSession(JmsTopicConnection.java:105)

	at TestJmsApplet.subscribe(TestJmsApplet.java:110)

	at TestJmsApplet$1.mousePressed(TestJmsApplet.java:55)

	at java.awt.Component.processMouseEvent(Component.java:5097)

	at java.awt.Component.processEvent(Component.java:4897)

	at java.awt.Button.processEvent(Button.java:353)

	at java.awt.Component.dispatchEventImpl(Component.java:3615)

	at java.awt.Component.dispatchEvent(Component.java:3477)

	at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)

	at java.awt.EventDispatchThread.
pumpOneEventForHierarchy(EventDispatchThread.java:201)

	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.
java:151)

	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)

	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)

	at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)


Thanks a lot for any help.

Regards

Arnaud ROCHE




-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.