United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 6256201 REGRESSION: Applet failed in CORBA stub call with AccesControlException
6256201 : REGRESSION: Applet failed in CORBA stub call with AccesControlException

Details
Type:
Bug
Submit Date:
2005-04-15
Status:
Closed
Updated Date:
2010-04-03
Project Name:
JDK
Resolved Date:
2005-06-07
Component:
deploy
OS:
windows_2000
Sub-Component:
plugin
CPU:
x86
Priority:
P3
Resolution:
Duplicate
Affected Versions:
5.0
Fixed Versions:

Related Reports
Duplicate:

Sub Tasks

Description
FULL PRODUCT VERSION :
Applet is run in
Java Plug-in 1.5.0_02
Using JRE version 1.5.0_02 Java HotSpot(TM) Client VM
---------------------
Source is compiled with JDK 1.4.2_04

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000 [Version 5.00.2195]
Java Plug-in 1.5.0_02
Using JRE version 1.5.0_02 Java HotSpot(TM) Client VM


A DESCRIPTION OF THE PROBLEM :
The applet that was working in 1.4.2 is not working. I got the same stack trace as given in "http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6203567". Please refere to a similar problem filed at http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6203567
Note: running the applet from Appletviewer is not causing this problem.
We are getting this problem only with applets downloaded from a diffrent IP address. My test applet just makes a call that just calls a remote method thru corba object reference and is failing with the following stack ( same as in bug-id 6203567).

Thread [Thread-10] (Suspended (exception java.security.AccessControlException))
	java.security.AccessControlContext.checkPermission(java.security.Permission)
	java.security.AccessController.checkPermission(java.security.Permission)
	sun.plugin.security.ActivatorSecurityManager(java.lang.SecurityManager).checkPermission(java.security.Permission)
	sun.plugin.security.ActivatorSecurityManager(sun.applet.AppletSecurity).checkAccess(java.lang.Thread)
	com.sun.corba.se.impl.transport.SelectorImpl(java.lang.Thread).checkAccess()
	com.sun.corba.se.impl.transport.SelectorImpl(java.lang.Thread).setName(java.lang.String) <<<< Needs Permission.
	com.sun.corba.se.impl.transport.SelectorImpl.run()
	
Stack-2:

Thread [Security] (Suspended)
	java.lang.Object.wait(long) line: not available [native method]
	java.lang.Object.wait()
	com.sun.corba.se.impl.transport.CorbaResponseWaitingRoomImpl.waitForResponse(com.sun.corba.se.pept.protocol.MessageMediator)
	com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.waitForResponse(com.sun.corba.se.pept.protocol.MessageMediator)
	com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.waitForResponse() line:
	com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.marshalingComplete1(com.sun.corba.se.spi.orb.ORB, com.sun.corba.se.spi.protocol.CorbaMessageMediator)
	com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.marshalingComplete(java.lang.Object, com.sun.corba.se.pept.encoding.OutputObject)
	com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.invoke(org.omg.CORBA.Object, org.omg.CORBA.portable.OutputStream)
	NSMwebServerFactory._TheFactoryStub(org.omg.CORBA.portable.ObjectImpl)._invoke(org.omg.CORBA.portable.OutputStream)
	NSMwebServerFactory._TheFactoryStub.GetExpandNodeName()
	Common.ServerManager.getRootObject(javax.swing.JApplet) line: 396
	Common.ServerRecoveryScope.startServer() line: 149
	Common.ServerRecoveryScope.getRootObject() line: 459
	Common.ServerRecoveryScope.logon() line: 274
	Common.Security.run() line: 99
	java.lang.Thread.run()

-------------
The above two stacks are captured  when the applet failed with exception.

Java console showed

Exception in thread "Thread-18" java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThread)
	at java.security.AccessControlContext.checkPermission(Unknown Source)
	at java.security.AccessController.checkPermission(Unknown Source)
	at java.lang.SecurityManager.checkPermission(Unknown Source)
	at sun.applet.AppletSecurity.checkAccess(Unknown Source)
	at java.lang.Thread.checkAccess(Unknown Source)
	at java.lang.Thread.setName(Unknown Source)
	at com.sun.corba.se.impl.transport.SelectorImpl.run(Unknown Source)

SOURCE CODE TO REPRODUCE THE PROBLEM:
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;

import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import org.omg.CORBA.ORB;
import org.omg.CORBA.Object;

import NSMwebServerFactory.TheFactory;
import NSMwebServerFactory.TheFactoryHelper;
public class MuruganApplet extends JApplet {
    // CORBA ORB from plugin.
	private ORB theORB = null;
    private String theIOR = "";
    private TheFactory  theFactoryRef;
    
  private void showExpandNodeName()
  {
  	theORB = ORB.init((String []) null,null);
  	theIOR = getIOR();
  	Object obj= theORB.string_to_object(theIOR);
  	
  	if (obj == null)
  	{
  	   System.out.println("Not a valid IOR string");
  	}
  	else
  	{
  	   theFactoryRef = TheFactoryHelper.narrow(obj);
  	   if (obj == null)
  	   {
  	   	 System.out.println("narrow(factoryobj) failed.");
  	   }
  	   else
  	   {
  	   	String s=theFactoryRef.GetExpandNodeName();
  	    txtAreaOutput.append("ExpandNodeName:"+s+'\n');
  	   	System.out.println("Expand Node Name:"+s);
  	   }
  	}
  
  }
  public void init()
  {
  	init_gui();
  }
  
  public void start()
  {
  	System.out.println("Start()");
  }
  public void stop()
  {
  	System.out.println("Stop()");
  }
  
  private String getIOR()
  {
  	String anIOR;
  	try
	{
  		URL u = new URL("http","16.150.222.24",-1,"/gan15/Common/FactoryIORs/FactoryIOR016150222024.txt");
  		InputStream is = u.openStream();
  		InputStreamReader isr = new InputStreamReader(is);
        
        BufferedReader br = new BufferedReader(isr);
        
        anIOR = br.readLine();
        
        is.close();
        return anIOR;
    }
    catch (IOException e)
    {
        e.printStackTrace();
        System.out.println("Could not read the IOR file"+getDocumentBase());
    }
  	return null;
  }
  private String getIOR(String s)
  {
    return null;
  }
  
  
 /************************************************************/
	// GUI components to do some work.
 /************************************************************/
	Container appContentPane;
	JButton btnChangeCase;
	JButton btnClear;
	JButton btnHostName;
	JTextField txtInputStr;
	JTextArea txtAreaOutput;
	
  private void init_gui()
  {
  	setSize(new Dimension(500,400));
  	appContentPane = getContentPane();
  	Panel p = new Panel(new BorderLayout());
  	p.add(new JLabel("Enter a String:"),BorderLayout.WEST);
  	txtInputStr = new JTextField("Enter String here.",160);
  	p.add(txtInputStr,BorderLayout.CENTER);
  	appContentPane.add(p,BorderLayout.NORTH);
  	
  	p = new Panel(new FlowLayout());
  	btnChangeCase = new JButton("Change Case");
  	btnClear = new JButton("Clear");
  	btnHostName = new JButton("Get HostName");
  	p.add(btnChangeCase);
  	p.add(btnClear);
  	p.add(btnHostName);
  	appContentPane.add(p,BorderLayout.SOUTH);
  	
  	txtAreaOutput= new JTextArea(20,60);
  	JScrollPane scrollPane =
  	    new JScrollPane(txtAreaOutput,
  	                    JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
  	                    JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
  	
  	//txtAreaOutput.setEditable(false);


  	appContentPane.add(scrollPane,BorderLayout.CENTER);
  	
  	getRootPane().setDefaultButton(btnChangeCase);
  	
  	txtInputStr.addActionListener(new ActionListener() {
  		public void actionPerformed(ActionEvent e) {
  	       txtAreaOutput.append(txtInputStr.getText()+'\n');
  		}
  	});
  	
  	btnClear.addActionListener(new ActionListener() {
  		public void actionPerformed(ActionEvent e)
  		{
  		  txtAreaOutput.setText("");
  		}
  	});
  	
  	btnChangeCase.addActionListener(new ActionListener() {
  		public void actionPerformed(ActionEvent e) {
  			showExpandNodeName();
  		}
  	});
  	
  	btnHostName.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			showExpandNodeName();
			}
	});

  }

}
/* END of APPLET */

Even this applet produced the same error stack.

My test applet just makes a call that just calls a remote method thru corba object reference. So any IDL with an interface with a method is enough to reproduce this.

I have used the following IDL for reproducing this problem.
// NSMwebServerFactory.idl

module NSMwebServerFactory
{


///////////////////////////////////////////////////////////////////////////////
//
//  Interface - TheFactory
//
///////////////////////////////////////////////////////////////////////////////

	interface TheFactory
	{

		string GetExpandNodeName();

	};

};


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
  To reproduce write a small applet which makes remote a remote call thru CORBA ORBECT reference, Note the Applet should be run in a browser ( java plugin 1.5) and should be downloaded from ( from a web-server) a machine with diffrent IP address than the machine running the applet.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
EXPECTED
No Exceptions.

ACTUAL -
Gives AccessControlException.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "Thread-18" java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThread)

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;

import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import org.omg.CORBA.ORB;
import org.omg.CORBA.Object;

import NSMwebServerFactory.TheFactory;
import NSMwebServerFactory.TheFactoryHelper;
public class MuruganApplet extends JApplet {
    // CORBA ORB from plugin.
	private ORB theORB = null;
    private String theIOR = "";
    private TheFactory  theFactoryRef;
    
  private void showExpandNodeName()
  {
  	theORB = ORB.init((String []) null,null);
  	theIOR = getIOR();
  	Object obj= theORB.string_to_object(theIOR);
  	
  	if (obj == null)
  	{
  	   System.out.println("Not a valid IOR string");
  	}
  	else
  	{
  	   theFactoryRef = TheFactoryHelper.narrow(obj);
  	   if (obj == null)
  	   {
  	   	 System.out.println("narrow(factoryobj) failed.");
  	   }
  	   else
  	   {
  	   	String s=theFactoryRef.GetExpandNodeName();
  	    txtAreaOutput.append("ExpandNodeName:"+s+'\n');
  	   	System.out.println("Expand Node Name:"+s);
  	   }
  	}
  
  }
  public void init()
  {
  	init_gui();
  }
  
  public void start()
  {
  	System.out.println("Start()");
  }
  public void stop()
  {
  	System.out.println("Stop()");
  }
  
  private String getIOR()
  {
  	String anIOR;
  	try
	{
  		URL u = new URL("http","16.150.222.24",-1,"/gan15/Common/FactoryIORs/FactoryIOR016150222024.txt");
  		InputStream is = u.openStream();
  		InputStreamReader isr = new InputStreamReader(is);
        
        BufferedReader br = new BufferedReader(isr);
        
        anIOR = br.readLine();
        
        is.close();
        return anIOR;
    }
    catch (IOException e)
    {
        e.printStackTrace();
        System.out.println("Could not read the IOR file"+getDocumentBase());
    }
  	return null;
  }
  private String getIOR(String s)
  {
    return null;
  }
  
  
 /************************************************************/
	// GUI components to do some work.
 /************************************************************/
	Container appContentPane;
	JButton btnChangeCase;
	JButton btnClear;
	JButton btnHostName;
	JTextField txtInputStr;
	JTextArea txtAreaOutput;
	
  private void init_gui()
  {
  	setSize(new Dimension(500,400));
  	appContentPane = getContentPane();
  	Panel p = new Panel(new BorderLayout());
  	p.add(new JLabel("Enter a String:"),BorderLayout.WEST);
  	txtInputStr = new JTextField("Enter String here.",160);
  	p.add(txtInputStr,BorderLayout.CENTER);
  	appContentPane.add(p,BorderLayout.NORTH);
  	
  	p = new Panel(new FlowLayout());
  	btnChangeCase = new JButton("Change Case");
  	btnClear = new JButton("Clear");
  	btnHostName = new JButton("Get HostName");
  	p.add(btnChangeCase);
  	p.add(btnClear);
  	p.add(btnHostName);
  	appContentPane.add(p,BorderLayout.SOUTH);
  	
  	txtAreaOutput= new JTextArea(20,60);
  	JScrollPane scrollPane =
  	    new JScrollPane(txtAreaOutput,
  	                    JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
  	                    JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
  	
  	//txtAreaOutput.setEditable(false);


  	appContentPane.add(scrollPane,BorderLayout.CENTER);
  	
  	getRootPane().setDefaultButton(btnChangeCase);
  	
  	txtInputStr.addActionListener(new ActionListener() {
  		public void actionPerformed(ActionEvent e) {
  	       txtAreaOutput.append(txtInputStr.getText()+'\n');
  		}
  	});
  	
  	btnClear.addActionListener(new ActionListener() {
  		public void actionPerformed(ActionEvent e)
  		{
  		  txtAreaOutput.setText("");
  		}
  	});
  	
  	btnChangeCase.addActionListener(new ActionListener() {
  		public void actionPerformed(ActionEvent e) {
  			showExpandNodeName();
  		}
  	});
  	
  	btnHostName.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			showExpandNodeName();
			}
	});

  }

}
--------------
// NSMwebServerFactory.idl

module NSMwebServerFactory
{


///////////////////////////////////////////////////////////////////////////////
//
//  Interface - TheFactory
//
///////////////////////////////////////////////////////////////////////////////

	interface TheFactory
	{

		string GetExpandNodeName();

	};

};

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Giving allpermissions will make this problem disappear.

Release Regression From : 1.4.2
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.
###@###.### 2005-04-15 22:19:42 GMT

                                    

Comments
EVALUATION

This bug is due to the SelectorImpl.run method calls Thread.setName which requires the "modifyThread" permission. This permission is not included in the default applet's sandbox. A fix is to enclose the Thread.setName by a doPrivileged() block.
This bug is a duplicate of 6203567.
###@###.### 2005-06-07 02:23:38 GMT
                                     
2005-06-07
WORK AROUND

If the applet is signed, this problem shoudn't happen.
###@###.### 2005-06-07 02:23:39 GMT
                                     
2005-06-07



Hardware and Software, Engineered to Work Together