[omniORB] Client in Java (Jacorb) and Server in C++ (OmniOrb)
Valter Henrique
valter.bcc at gmail.com
Thu Nov 25 00:11:02 GMT 2010
Okay,
i take echo.idl and compile in jacOrb :
idlj echo.idl
Then i take all the files generated and put in a folder, then paste my java
client :
EchoClient.java
-------------------------------------------
import org.omg.CosNaming.*;
import org.omg.CORBA.*;
public class EchoClient {
public static void main(String args[]) {
try {
String SetInfo, ReturnInfo, ref;
org.omg.CORBA.Object objRef;
Echo EchoRef;
ORB orb = ORB.init(args, null);
objRef = orb.resolve_initial_references("NameService");
NamingContext ncRef = NamingContextHelper.narrow(objRef);
// locate the service
NameComponent nc = new NameComponent("test", "my_context");
NameComponent nc2 = new NameComponent("Echo", "Object");
NameComponent path[] = { nc,nc2 };
EchoRef = EchoHelper.narrow(ncRef.resolve(path));
if (args.length > 1) {
SetInfo = args[1];
} else {
}
System.out.println("Client Process Begin: ");
ReturnInfo = EchoRef.echoString("my corba test");
System.out.println(ReturnInfo);
} catch (Exception e) {
System.out.println("ERROR : " + e);
}
}
}
-------------------------------------------
Compile all the java files :
javac *.java
One important thing, change the value of supportBootstrapAgent = 0 to
supportBootstrapAgent = 1 in omniORB.cfg, to enable the interoperability
between jacOrb and omniOrb, okay ?
Then type 'make' in echo example folder, placed in the 'build' folder (when
installing omniOrb in Linux)
Initialize the omni names service :
omniNames -start
Start the server :
./eg3_impl
Now start the client :
java EchoClient -ORBIntialPort 2809
Okay ?
That's all.
Thank you for your attention.
Best regards,
Valter Henrique.
2010/11/25 Thomas Lockhart <lockhart at fourpalms.org>
> On 11/24/2010 05:57 PM, Valter Henrique wrote:
>
> IT WORKS!
>
>
> Great. What did you change?
>
> - Tom
>
>
>
> Thank you so much guys!
>
>
> Atenciosamente,
> Valter Henrique.
> Ciência da Computação
> UFSCar Sorocaba
> (15)9122-1822
> (16)9187-7706
>
> Quem sou:
> http://flavors.me/valterhenrique <http://flavors.me/valterhenrique#_>
> http://valterhenrique.mp/
>
>
> 2010/11/24 Thomas Lockhart <lockhart at fourpalms.org>
>
>> There are explicit examples in C++ in the omniORB source tree. If you
>> mirror that code in Java you should have some success.
>>
>> But as something is failing in your Java code you should debug that. I'll
>> suggest that you confirm that you can retrieve valid NameComponent pieces
>> from the naming service for each level of the name you have registered and
>> are trying to retrieve. And unnest the call to resolve() so you can see what
>> the result of that is. But first, you could use a naming service listing
>> utility to examine how the naming service is being used by your server.
>>
>> If you are new to CORBA, you will find it very useful to have a reference
>> book and tutorial. I have found that, no matter which language you are
>> using, the Advanced CORBA Programming with C++ by Henning and Vinoski is the
>> book worth having.
>>
>> Oh, you *are* using JacORB, right? The ORB shipped with Java is deficient
>> (or at least used to be and I haven't heard that it has gotten better).
>>
>> hth
>>
>> - Tom
>>
>> i'm trying, but i don't know where is my mistake here is my client in
>> Java:
>>
>> EchoClient.java
>> ----------------------
>> import org.omg.CosNaming.*;
>> import org.omg.CORBA.*;
>>
>> public class EchoClient {
>>
>> public static void main(String args[]) {
>> try {
>> String SetInfo, ReturnInfo, ref;
>> org.omg.CORBA.Object objRef;
>> Echo EchoRef;
>> ORB orb = ORB.init(args, null);
>>
>> objRef = orb.resolve_initial_references("NameService");
>> NamingContext ncRef = NamingContextHelper.narrow(objRef);
>>
>> // locate the service
>> NameComponent nc = new NameComponent("test", "my_context");
>> NameComponent nc2 = new NameComponent("Echo", "Object");
>>
>> NameComponent path[] = { nc,nc2 };
>> EchoRef = EchoHelper.narrow(ncRef.resolve(path));
>>
>> if (args.length > 1) {
>> SetInfo = args[1];
>> } else {
>>
>> }
>> System.out.println("Client Process Begin: ");
>> ReturnInfo = EchoRef.echoString("my corba test");
>> System.out.println(ReturnInfo);
>> */
>> } catch (Exception e) {
>> System.out.println("ERROR : " + e);
>> }
>> }
>> }
>> -------------------------------
>>
>> When run the client :
>>
>> java EchoClient -ORBInitialPort 2809
>>
>> gives this error :
>> ERROR : org.omg.CosNaming.NamingContextPackage.NotFound: IDL:
>> omg.org/CosNaming/NamingContext/NotFound:1.0
>>
>> Can anyone help me please?
>>
>> Thanks for your attention.
>>
>> Best regards,
>> Valter Henrique.
>>
>> 2010/11/24 Valter Henrique <valter.bcc at gmail.com>
>>
>>> Sorry Duncan, but i don't understand what you say, i'm new in CORBA.
>>> Could you give me an example, please ?
>>>
>>> Thanks.
>>>
>>>
>>> 2010/11/24 Duncan Grisby <duncan at grisby.org>
>>>
>>> On Wed, 2010-11-24 at 05:55 -0800, Valter Henrique wrote:
>>>>
>>>> > i'm tryng do build a simple application using 'echo' example.
>>>> >
>>>> > I have my client in Java:
>>>>
>>>> [...]
>>>> > // locate the service
>>>> > NameComponent nc = new NameComponent("Echo",
>>>> "");
>>>> > NameComponent path[] = { nc };
>>>> > EchoRef =
>>>> EchoHelper.narrow(ncRef.resolve(path));
>>>>
>>>> [...]
>>>> > java EchoClient -ORBInitialPort 2809
>>>> > ERROR : org.omg.CosNaming.NamingContextPackage.NotFound:
>>>> > IDL:omg.org/CosNaming/NamingContext/NotFound:1.0
>>>>
>>>> As the exception says, the name you have looked up is not found. The
>>>> eg3
>>>> example uses the name test.my_context/Echo.Object . You need to either
>>>> create the two NameComponents separately, or use the
>>>> NamingContextExt::resolve_str method that will take the string form.
>>>>
>>>> Cheers,
>>>>
>>>> Duncan.
>>>>
>>>> --
>>>> -- Duncan Grisby --
>>>> -- duncan at grisby.org --
>>>> -- http://www.grisby.org --
>>>>
>>>>
>>>>
>>>
>>
>> _______________________________________________
>> omniORB-list mailing list
>> omniORB-list at omniorb-support.comhttp://www.omniorb-support.com/mailman/listinfo/omniorb-list
>>
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20101125/c9cdd6d7/attachment-0001.htm
More information about the omniORB-list
mailing list