[omniORB] Java & omniORB

José Alberto Pérez de Acha japerez@triger.com.mx
Wed, 21 Jul 1999 21:13:13 -0600


This is a multi-part message in MIME format.

------=_NextPart_000_0106_01BED3BD.D7B8BA40
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi,

I have been trying to connect a Java Client (JDK 1.2) to omniORB 2.7.1 =
on a Windows NT 4.0 Server but it can not seem to work (please see =
source code).

I have already started OMNINAMES (on port 900) and my corba server =
(Validacion). They work fine if I use my C++ client. but I do not know =
why it does not work with my java client (it fails between step 6 and =
7).

Can somebody help me and tell me what I am doing wrong?

Regards from Mexico.

Jose Alberto Perez de Acha
TRIGER, S.C.
Blvd. Manuel Avila Camacho 88-8
Col. Lomas de Chapultepec
11000 Mexico City, Mexico
Tel 5202-7333


Source code:

//Title:             Corba Client
// Version:       1.0
//Copyright:     Copyright (c) 1999
//Author:           Jose Alberto Perez de Acha
//Company:     TRIGER, S.C.
//Description:  Programaci=F3n con CORBA
package Corba;

import Seguridad.*;                       // Package of java classes =
(after compiling Seguridad.idl)
import org.omg.CosNaming.*;
import org.omg.CORBA.*;

public class SeguridadClient {

  public SeguridadClient() {
  }

 public static void main(String args[])    {
  try{
      // create and initialize the ORB
      System.out.println("Step 1") ;
   ORB orb =3D ORB.init(args, null);

   // get the root naming context
      System.out.println("Step 2") ;
      // org.omg.CORBA.Object objRef =3D orb.string_to_object(c_ior);
      org.omg.CORBA.Object objRef =3D =
orb.resolve_initial_references("NameService");
      System.out.println("Step 3") ;
      NamingContext ncRef =3D NamingContextHelper.narrow(objRef);

      // resolve the Object Reference in Naming
      System.out.println("Step 4") ;
      NameComponent nc =3D new NameComponent("Validacion", "Object");
      System.out.println("Step 5 [" + nc.toString() + "]") ;
      NameComponent path[] =3D {nc};
      System.out.println("Step 6 [" + path[0].toString() + "]") ;

      // THE PROGRAM FAILS HERE
      Validacion validacionRef =3D =
ValidacionHelper.narrow(ncRef.resolve(path));
      System.out.println("Step 7") ;

   // call the Validacion server object and print results
   String buffer =3D "SEPARREG|";
   org.omg.CORBA.StringHolder results =3D new StringHolder("");
     int result =3D validacionRef.ParametroCORBA(buffer, results);
   System.out.println(results);
  }
  catch (Exception e) {
   System.out.println("ERROR : " + e) ;
      e.printStackTrace(System.out);
  }
 }
}


------=_NextPart_000_0106_01BED3BD.D7B8BA40
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>

<META content=3Dtext/html;charset=3Diso-8859-1 =
http-equiv=3DContent-Type>
<META content=3D'"MSHTML 4.72.3110.7"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT color=3D#000000 size=3D2>Hi,</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>I have been trying to connect a Java =
Client (JDK=20
1.2) to omniORB 2.7.1 on a Windows NT 4.0 Server but it can not seem to =
work=20
(please see source code).</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>I have already started OMNINAMES (on =
port 900)=20
and my corba server (Validacion). They work fine if I use my C++ client. =
but I=20
do not know why it does not work with my java client (it fails between =
step 6=20
and 7).</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Can somebody help me and tell me what I am doing=20
wrong?</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>Regards from Mexico.</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>Jose Alberto Perez de =
Acha</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT><FONT size=3D2>TRIGER, =
S.C.</FONT></DIV>
<DIV><FONT size=3D2>Blvd. Manuel Avila Camacho 88-8</FONT></DIV>
<DIV><FONT size=3D2>Col. Lomas de Chapultepec</FONT></DIV>
<DIV><FONT size=3D2>11000 </FONT><FONT size=3D2>Mexico City, =
Mexico</FONT></DIV>
<DIV><FONT size=3D2>Tel 5202-7333</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>Source code:</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2><BR><A=20
href=3D"file://Title:">//Title:</A>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
Corba Client<BR><A href=3D"file:// Version:">//=20
Version:</A>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.0<BR><A=20
href=3D"file://Copyright:">//Copyright:</A>&nbsp;&nbsp;&nbsp;&nbsp; =
Copyright (c)=20
1999<BR><A=20
href=3D"file://Author:">//Author:</A>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;=20
Jose Alberto Perez de Acha<BR><A=20
href=3D"file://Company:">//Company:</A>&nbsp;&nbsp;&nbsp;&nbsp; TRIGER, =
S.C.<BR><A=20
href=3D"file://Description:">//Description:</A>&nbsp; =
Programaci&oacute;n con=20
CORBA<BR>package Corba;</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>import=20
Seguridad.*;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
// Package of java classes (after compiling Seguridad.idl)<BR>import=20
org.omg.CosNaming.*;<BR>import org.omg.CORBA.*;</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>public class SeguridadClient =
{</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>&nbsp; public SeguridadClient() =
{<BR>&nbsp;=20
}</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>&nbsp;public static void main(String =

args[])&nbsp;&nbsp;&nbsp; {<BR>&nbsp; =
try{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //=20
create and initialize the ORB<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
System.out.println(&quot;Step 1&quot;) ;<BR>&nbsp;&nbsp; ORB orb =3D=20
ORB.init(args, null);</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>&nbsp;&nbsp; // get the root naming=20
context<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(&quot;Step =
2&quot;)=20
;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // org.omg.CORBA.Object objRef =3D=20
orb.string_to_object(c_ior);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
org.omg.CORBA.Object objRef =3D=20
orb.resolve_initial_references(&quot;NameService&quot;);<BR>&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;=20
System.out.println(&quot;Step 3&quot;) =
;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
NamingContext ncRef =3D NamingContextHelper.narrow(objRef);</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // =
resolve the=20
Object Reference in Naming<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
System.out.println(&quot;Step 4&quot;) =
;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
NameComponent nc =3D new NameComponent(&quot;Validacion&quot;,=20
&quot;Object&quot;);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
System.out.println(&quot;Step 5 [&quot; + nc.toString() + &quot;]&quot;) =

;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NameComponent path[] =3D=20
{nc};<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(&quot;Step 6 =
[&quot;=20
+ path[0].toString() + &quot;]&quot;) ;</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // =
THE PROGRAM=20
FAILS HERE</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT><FONT color=3D#000000=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Validacion validacionRef =3D=20
ValidacionHelper.narrow(ncRef.resolve(path));<BR>&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;=20
System.out.println(&quot;Step 7&quot;) ;</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>&nbsp;&nbsp; // call the Validacion =
server=20
object and print results<BR>&nbsp;&nbsp; String buffer =3D=20
&quot;SEPARREG|&quot;;<BR>&nbsp;&nbsp; org.omg.CORBA.StringHolder =
results =3D new=20
StringHolder(&quot;&quot;);<BR>&nbsp;&nbsp;&nbsp;&nbsp; int result =3D=20
validacionRef.ParametroCORBA(buffer, results);<BR>&nbsp;&nbsp;=20
System.out.println(results);<BR>&nbsp; }<BR>&nbsp; catch (Exception e)=20
{<BR>&nbsp;&nbsp; System.out.println(&quot;ERROR : &quot; + e)=20
;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
e.printStackTrace(System.out);<BR>&nbsp;=20
}<BR>&nbsp;}<BR>}<BR></FONT></DIV></BODY></HTML>

------=_NextPart_000_0106_01BED3BD.D7B8BA40--