[omniORB] Applet connection problem
Christian Dyczek
christian.dyczek@gmx.at
Tue, 29 Jan 2002 15:47:03 +0100
I try to connect my Java JDK1.3 applet with a omniORB server
Therefor i have three code examples but only one works:
//----------------- First solution
---------------------------------------//
try //Create and initialize the ORB
{
String myargs[] = new String[4];
myargs[0] = "-ORBInitialHost"; //Option to define the host
myargs[1] = "213.47.133.192"; //IP of the omniname server
myargs[2] = "-ORBInitialPort"; //Option to define the port
myargs[3] = "1050"; //Port of the omniname server
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(myargs, null);
//Get the root naming context
org.omg.CORBA.Object objRef=
orb.resolve_initial_references("NameService");
org.omg.CosNaming.NamingContext ncRef =
org.omg.CosNaming.NamingContextHelper.narrow(objRef);
//Resolve the object reference in naming
org.omg.CosNaming.NameComponent nc0 = new
org.omg.CosNaming.NameComponent("test","my_context");
org.omg.CosNaming.NameComponent nc1 = new
org.omg.CosNaming.NameComponent("Echo","Object");
org.omg.CosNaming.NameComponent path[] = {nc0,nc1};
server = EchoHelper.narrow(ncRef.resolve(path));
} catch (Exception e)
{
System.out.println("Cannot connect to WebTestServer");
e.printStackTrace();
System.exit(1);
}
*/
//----------------- Second solution
--------------------------------------//
/*
try //Create and initialize the ORB
{
org.omg.CORBA.ORB orb =
org.omg.CORBA.ORB.init((String[])null,null);
org.omg.CORBA.Object obj =
orb.string_to_object("IOR:010000002b00000049444c3a6f6d672e6f72672f436f73
4e616d696e672f4e616d696e67436f6e746578744578743a312e30000001000000000000
002b000000010100000f0000003231332e34372e3133332e31393200001a0400000b0000
004e616d6553657276696365");
server = EchoHelper.narrow(obj);
} catch (Exception e)
{
System.out.println("Cannot connect to WebTestServer");
e.printStackTrace();
System.exit(1);
}
*/
In the first two examples I get this failure message:
java.security.AccessControlException: access denied
(java.io.FilePermission C:\Dokumente und
Einstellungen\Administrator\Desktop\orb.properties read)
at java.security.AccessControlContext.checkPermission(Unknown
Source)
at java.security.AccessController.checkPermission(Unknown
Source) ....
java.security.AccessControlException: access denied
(java.lang.RuntimePermission exitVM)
at java.security.AccessControlContext.checkPermission(Unknown
Source)
at java.security.AccessController.checkPermission(Unknown
Source)
//----------------- Third solution
---------------------------------------//
try
{
orb = org.omg.CORBA.ORB.init(this, null);
}
catch (org.omg.CORBA.INITIALIZE ex)
{
System.err.println ("ORB.init failed" + ex);
}
String nsior = getParameter("NSIOR"); // aus HTML-File
System.out.println("resolving Naming Service");
org.omg.CORBA.Object anObj = null;
anObj = orb.string_to_object(nsior);
System.out.println("Naming Service resolved");
if(anObj == null)
{
System.out.println("Name Service is a nil object reference");
System.exit(2);
}
NamingContext nc = NamingContextHelper.narrow(anObj);
System.out.println("Naming Service resolved and narrowed");
if(nc == null)
{
System.out.println("Name Service is not a NamingContext object
reference");
System.exit(3);
}
System.out.println(orb.object_to_string(nc));
try
{
NameComponent[] aName = new NameComponent[2];
aName[0] = new NameComponent();
aName[0].id = "test";
aName[0].kind = "my_context";
aName[1] = new NameComponent();
aName[1].id = "Echo";
aName[1].kind = "Object";
System.out.println("resolving Echo server");
anObj = nc.resolve(aName);
server = EchoHelper.narrow(anObj);
if(server == null)
throw new RuntimeException();
System.out.println("Resolved 'omniORB server'");
}
catch(NotFound ex)
{
System.out.print("NotFound exception: (");
switch(ex.why.value())
{
case NotFoundReason._missing_node:
System.out.print("missing node exception");
break;
case NotFoundReason._not_context:
System.out.print("not context exception");
break;
case NotFoundReason._not_object:
System.out.print("not object exception");
break;
}
System.out.println(")");
ex.printStackTrace();
System.exit(1);
}
catch(CannotProceed ex)
{
System.out.println("CannotProceed exception");
ex.printStackTrace();
System.exit(1);
}
catch(InvalidName ex)
{
System.out.println("InvalidName exception");
ex.printStackTrace();
System.exit(1);
}
This method works but only if the client is on a different machine ast
he server. I heard that this is a bug from JDK1.3. But other people tell
me that they connect without problems on only one PC, and my code should
be alright they say.
I don't know what to do ????????????
My HTML file is:
<HTML>
<HEAD>
<TITLE>JavaIDL Echo-Applet Example</TITLE>
</HEAD>
<BODY>
<H1>ECHO SERVER</H1>
<!--"CONVERTED_APPLET"-->
<!-- HTML CONVERTER -->
<SCRIPT LANGUAGE="JavaScript"><!--
var _info = navigator.userAgent; var _ns = false; var _ns6 = false;
var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 &&
_info.indexOf("Windows 3.1") < 0);
//--></SCRIPT>
<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!--
var _ns = (navigator.appName.indexOf("Netscape") >= 0 &&
((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 &&
java.lang.System.getProperty("os.version").indexOf("3.5") < 0) ||
(_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0) ||
(_info.indexOf("AIX") > 0) || (_info.indexOf("OS/2") > 0)));
var _ns6 = ((_ns == true) && (_info.indexOf("Mozilla/5") >= 0));
//--></SCRIPT></COMMENT>
<SCRIPT LANGUAGE="JavaScript"><!--
if (_ie == true) document.writeln('<OBJECT
classid="clsid:CAFEEFAC-0013-0001-0000-ABCDEFFEDCBA" WIDTH = 175 HEIGHT
= 240
codebase="http://java.sun.com/products/plugin/1.3.1/jinstall-131-win32.c
ab#Version=1,3,1,0"><NOEMBED><XMP>');
else if (_ns == true && _ns6 == false) document.writeln('<EMBED
type="application/x-java-applet;jpi-version=1.3.1" CODE =
"WebTestClient.class" CODEBASE = "./corbademo" WIDTH = 175 HEIGHT = 240
NSIOR =
"IOR:010000002b00000049444c3a6f6d672e6f72672f436f734e616d696e672f4e616d6
96e67436f6e746578744578743a312e30000001000000000000002b000000010100000f0
000003231332e34372e3133332e31393200001a0400000b0000004e616d6553657276696
365" scriptable=false
pluginspage="http://java.sun.com/products/plugin/1.3.1/plugin-install.ht
ml"><NOEMBED><XMP>');
//--></SCRIPT>
<APPLET CODE = "WebTestClient.class" CODEBASE = "./" WIDTH = 175 HEIGHT
= 240></XMP>
<PARAM NAME = CODE VALUE = "WebTestClient" >
<PARAM NAME = CODEBASE VALUE = "./" >
<PARAM NAME = "type" VALUE =
"application/x-java-applet;jpi-version=1.3.1">
<PARAM NAME = "scriptable" VALUE = "false">
<PARAM NAME = "NSIOR" VALUE =
"IOR:010000002b00000049444c3a6f6d672e6f72672f436f734e616d696e672f4e616d6
96e67436f6e746578744578743a312e30000001000000000000002b000000010100000f0
000003231332e34372e3133332e31393200001a0400000b0000004e616d6553657276696
365">
<!--<PARAM NAME = "NSIOR" VALUE =
"IOR:000000000000002849444c3a6f6d672e6f72672f436f734e616d696e672f4e616d6
96e67436f6e746578743a312e300000000001000000000000005c000101000000000f323
1332e34372e3133332e31393200000cc6000000000019afabcaff0000000278306896000
000080000000000000000010000000000000100000001000000140000000000010020000
000000001010000000000">
-->
</APPLET>
</NOEMBED></EMBED></OBJECT>
<!--
<APPLET CODE = "WebTestClient.class" CODEBASE = "./corbademo" WIDTH =
175 HEIGHT = 240>
<PARAM NAME = "NSIOR" VALUE =
"IOR:010000002b00000049444c3a6f6d672e6f72672f436f734e616d696e672f4e616d6
96e67436f6e746578744578743a312e30000001000000000000002b000000010100000f0
000003231332e34372e3133332e31393200001a0400000b0000004e616d6553657276696
365">
</APPLET>
-->
<!--"END_CONVERTED_APPLET"-->
<p><a href="WebTest.html">The class of the java applet</a></p>
</BODY>
</HTML>