You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by Fredrik Jonson <fr...@myrealbox.com> on 2008/10/21 19:23:49 UTC

Accessing corba from geronimo

Hi,

I'm trying to port a non-jee app to a EAR and get it running in
Geronimo (2.1.3). It has been a lot of fun, although I'm very much
a JEE-newbie, so it's a lot to grasp all at once... ;)

Now, I have one component that needs to make a remote corba
request to a non-jee corba service. In my legacy code, I did
it like this:

  Properties properties = new Properties();
  properties.put("org.omg.CORBA.ORBInitRef.NameService",
          "corbaloc::10.11.12.13:4003/NameService");
  orb = ORB.init(new String[0], properties);
  org.omg.CORBA.Object ns =
  orb.resolve_initial_references("NameService");
  NamingContextExt namingContext =
    NamingContextExtHelper.narrow(ns);
  org.omg.CORBA.Object obj = namingContext.resolve_str(
         "org/example/FooService");
  communicator = CommunicationHelper.narrow(obj);
  // use the communicator here...

When I try to use the same code in a MDB in Geronimo I get a
exception with the following stacktrace:

  Caused by: org.omg.CORBA.ORBPackage.InvalidName:
  IDL:omg.org/CORBA/ORB/InvalidName:1.0
    at org.apache.yoko.orb.OB.InitialServiceManager
     .resolveInitialReferences(InitialServiceManager.java:191)
    at org.apache.yoko.orb.OBCORBA.ORB_impl
     .resolve_initial_references(ORB_impl.java:1090)
    at org.example.MyClient.initiate(MyClient.java:249)

I've tried to find examples of how to call legacy (non-ejb) corba
services from a jee environment, but sofar I've come up short. I'd
be greatful for some hints on how to approach this.

-- 
Fredrik Jonson


Re: Accessing corba from geronimo

Posted by Juergen Weber <we...@gmail.com>.
Using information from
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.express.doc/info/exp/ae/tnam_develop_naming.html
I tried the code below, both ways to get the Orb work, probably the second
one is better in an EJB.

Juergen



	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException,
		IOException
	{
		NamingContextExt nc = null, ncn = null;
		ORB orb2 = null;
		
		try
		{
			org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init();
			org.omg.CORBA.Object obj = null;
			
			nc =
NamingContextExtHelper.narrow(orb.resolve_initial_references("NameService"));
			
			
			Context initialContext = new InitialContext(); 
			orb2 = (ORB) initialContext.lookup("java:comp/ORB");

		}
		catch (Exception e)
		{
			throw new ServletException(e);
		}
		
		PrintWriter writer = resp.getWriter();
		writer.write("doGet done. nc = " + nc + " orb2=" + orb2);

---

output:
doGet done. nc =
org.omg.CosNaming._NamingContextExtStub:org.apache.yoko.orb.CORBA.Delegate@117420e
orb2=org.apache.yoko.orb.CORBA.ORB@1f1dc0f

-- 
View this message in context: http://www.nabble.com/Accessing-corba-from-geronimo-tp20095314s134p20112889.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Re: Accessing corba from geronimo

Posted by Fredrik Jonson <fr...@myrealbox.com>.
In <20...@talk.nabble.com> Juergen Weber wrote:
 
> > I must admit that it's still a bit magic to me, I mean why that
> > change made a difference in the first place.
> 
>  Wait, this is only a start, basically you hard-wired the server
>  address now.

Yes, I read[0] that the server host and port is included in the IOR.
One thing at a time, eh? ;)

[0] http://www.javaworld.com/javaworld/jw-02-1999/jw-02-enterprise.html

>  The nameservice variant is much better, but you have to find out,
>  how the Geronimo naming service works. You might try this:
>
>  http://www.ibm.com/developerworks/library/os-ag-corba1/index.html

I've skimmed that article before, but it references Geronimo M5 (pre
1.0!) and it does not seem to cover my specific case, a ejb that
needs to reference a remote non-managed (non ejb) corba service.

The closest think that I've found is figure 6 in that article. Still,
the documentation is severely lacking in this area - no wonder, I guess
it is a pretty obscure use case) - I haven't found any documentation
of the ns-corbaloc element, and how/if it is applicable to any corba
object.

-- 
Fredrik Jonson


Re: Accessing corba from geronimo [SOLVED]

Posted by Juergen Weber <we...@gmail.com>.


Fredrik Jonson-3 wrote:
> 
> Juergen Weber wrote:
> 
>>  Try to use an IOR first(object_to_string() and friends)
> 
> Thank you! I now have working code!
> 
> I used the legacy code - that uses the default sun ORB - to
> retrieve the IOR of the object I needed. After that it was as
> simple as replacing:
> 
>> >  org.omg.CORBA.Object ns =
>> >  orb.resolve_initial_references("NameService");
>> >  NamingContextExt namingContext =
>> >    NamingContextExtHelper.narrow(ns);
>> >  org.omg.CORBA.Object obj = namingContext.resolve_str(
>> >         "org/example/FooService");
> 
> Whith these two lines:
> 
> 	String ior = "IOR:000000000000003f4..."
>         org.omg.CORBA.Object obj = orb.string_to_object(ior);
> 
> And now everything works in Geronimo too... Yay!
> 
> I must admit that it's still a bit magic to me, I mean why that
> change made a difference in the first place. A bit of browsing
> on the web suggests that using IOR is a more ORB-independent
> way of getting hold of a service, but I'm not sure that's the 
> whole story?
> 
> 

Wait, this is only a start, basically you hard-wired the server address now.
The nameservice variant is much better, but you have to find out, how the
Geronimo naming service works.
You might try (I haven't) if this works:
http://www.ibm.com/developerworks/library/os-ag-corba1/index.html

Good luck,
Juergen

-- 
View this message in context: http://www.nabble.com/Accessing-corba-from-geronimo-tp20095314s134p20110713.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Re: Accessing corba from geronimo [SOLVED]

Posted by Fredrik Jonson <fr...@myrealbox.com>.
Hello,

I poked around a bit more after Rick and Juergen's followups, and
looked in the yoko source, especially the InitialServiceManager, to
see what it did. Now, I have returned to my original code, but with a
subtle difference, I replaced the property:

  org.omg.CORBA.ORBInitRef.NameService

with 

  yoko.orb.service.NameService

My code now looks like this:

  Properties properties = new Properties();
  properties.put("yoko.orb.service.NameService",
          "corbaloc::10.11.12.13:4003/NameService");
  orb = ORB.init(new String[0], properties);
  org.omg.CORBA.Object ns =
  orb.resolve_initial_references("NameService");
  NamingContextExt namingContext =
    NamingContextExtHelper.narrow(ns);
  org.omg.CORBA.Object obj = namingContext.resolve_str(
         "org/example/FooService");
  communicator = CommunicationHelper.narrow(obj);
  // use the communicator here...

That works in Geronimo, and it sure is a lot more manageable than the
raw IOR lookup string, so I'm happy again. Btw, the yoko documentation
mentions the yoko.orb.service.* property in passing here:

http://cwiki.apache.org/YOKO/orb-properties.html

-- 
Fredrik Jonson


Re: Accessing corba from geronimo [SOLVED]

Posted by Rick McGuire <ri...@gmail.com>.
A better approach would be to use corbaname: URL format to look up the 
object.  This tells the ORB the location of the naming service providing 
the object reference and which one you want.  I believe the following 
would give you want you want:

    corbaname:10.11.12.13:4003/NameService#org/example/FooService

would do the lookup in on shot.  It appears that the original error is 
caused by Yoko not liking the format of the corbaloc: URL you gave it.  
You might try explicitly specifying the iiop level in the URL:

   corbaloc:iiop:1.2@10.11.12.13:4003/NameService

Rick


Fredrik Jonson wrote:
> Juergen Weber wrote:
>
>   
>>  Try to use an IOR first(object_to_string() and friends)
>>     
>
> Thank you! I now have working code!
>
> I used the legacy code - that uses the default sun ORB - to
> retrieve the IOR of the object I needed. After that it was as
> simple as replacing:
>
>   
>>>  org.omg.CORBA.Object ns =
>>>  orb.resolve_initial_references("NameService");
>>>  NamingContextExt namingContext =
>>>    NamingContextExtHelper.narrow(ns);
>>>  org.omg.CORBA.Object obj = namingContext.resolve_str(
>>>         "org/example/FooService");
>>>       
>
> Whith these two lines:
>
> 	String ior = "IOR:000000000000003f4..."
>         org.omg.CORBA.Object obj = orb.string_to_object(ior);
>
> And now everything works in Geronimo too... Yay!
>
> I must admit that it's still a bit magic to me, I mean why that
> change made a difference in the first place. A bit of browsing
> on the web suggests that using IOR is a more ORB-independent
> way of getting hold of a service, but I'm not sure that's the 
> whole story?
>
> Anyway, thanks again Juergen!
>
>   


Re: Accessing corba from geronimo [SOLVED]

Posted by Fredrik Jonson <fr...@myrealbox.com>.
Juergen Weber wrote:

>  Try to use an IOR first(object_to_string() and friends)

Thank you! I now have working code!

I used the legacy code - that uses the default sun ORB - to
retrieve the IOR of the object I needed. After that it was as
simple as replacing:

> >  org.omg.CORBA.Object ns =
> >  orb.resolve_initial_references("NameService");
> >  NamingContextExt namingContext =
> >    NamingContextExtHelper.narrow(ns);
> >  org.omg.CORBA.Object obj = namingContext.resolve_str(
> >         "org/example/FooService");

Whith these two lines:

	String ior = "IOR:000000000000003f4..."
        org.omg.CORBA.Object obj = orb.string_to_object(ior);

And now everything works in Geronimo too... Yay!

I must admit that it's still a bit magic to me, I mean why that
change made a difference in the first place. A bit of browsing
on the web suggests that using IOR is a more ORB-independent
way of getting hold of a service, but I'm not sure that's the 
whole story?

Anyway, thanks again Juergen!

-- 
Fredrik Jonson


Re: Accessing corba from geronimo

Posted by Juergen Weber <we...@gmail.com>.
No solution, but hints:

- try to use an IOR first (object_to_string() and friends)

- try to use JacORB from within Geronimo (but then JacORB threads are
not under control of Geronimo), this should work with Geronimo, too:
http://developers.sun.com/appserver/reference/techart/orb.html

On Tue, Oct 21, 2008 at 7:23 PM, Fredrik Jonson <fr...@myrealbox.com> wrote:
> Hi,
>
> I'm trying to port a non-jee app to a EAR and get it running in
> Geronimo (2.1.3). It has been a lot of fun, although I'm very much
> a JEE-newbie, so it's a lot to grasp all at once... ;)
>
> Now, I have one component that needs to make a remote corba
> request to a non-jee corba service. In my legacy code, I did
> it like this:
>
>  Properties properties = new Properties();
>  properties.put("org.omg.CORBA.ORBInitRef.NameService",
>          "corbaloc::10.11.12.13:4003/NameService");
>  orb = ORB.init(new String[0], properties);
>  org.omg.CORBA.Object ns =
>  orb.resolve_initial_references("NameService");
>  NamingContextExt namingContext =
>    NamingContextExtHelper.narrow(ns);
>  org.omg.CORBA.Object obj = namingContext.resolve_str(
>         "org/example/FooService");
>  communicator = CommunicationHelper.narrow(obj);
>  // use the communicator here...
>
> When I try to use the same code in a MDB in Geronimo I get a
> exception with the following stacktrace:
>
>  Caused by: org.omg.CORBA.ORBPackage.InvalidName:
>  IDL:omg.org/CORBA/ORB/InvalidName:1.0
>    at org.apache.yoko.orb.OB.InitialServiceManager
>     .resolveInitialReferences(InitialServiceManager.java:191)
>    at org.apache.yoko.orb.OBCORBA.ORB_impl
>     .resolve_initial_references(ORB_impl.java:1090)
>    at org.example.MyClient.initiate(MyClient.java:249)
>
> I've tried to find examples of how to call legacy (non-ejb) corba
> services from a jee environment, but sofar I've come up short. I'd
> be greatful for some hints on how to approach this.
>
> --
> Fredrik Jonson
>
>