Thank you for your responses. I realised my mistake. Thank you
Sidharth, you actually showed me where I was going wrong. The third
parameter is the object that is being requested for, and I was passing
a non-existent object. The corresponding Java code is
<code>
byte[] managerId = "BankManager".getBytes();
Bank.AccountManager manager = Bank.AccountManagerHelper.bind(orb,
"/bank_agent_poa", managerId);
</code>
I missed the most important step (duh me !!!)
This is the code that works (for anyone who makes a blunder like I did
to look !)
<code>
import jarray
from java.lang import String
from org.omg.CORBA import ORB
from java.lang import Exception
from java.util import ArrayList
ob1 = ORB.init(jarray.zeros(1,String),None)
id="BankManager"
name="Jack Welch"
from Bank import AccountManager
from Bank import AccountManagerHelper
m1=AccountManagerHelper.bind(ob1,"/bank_agent_poa",id)
from Bank import Account
print dir(m1.__class__)
o=m1.open(name)
b=o.balance()
print b
</code>
The name that is being passed doesn't matter, it is just passed for
the server to display. Thank you all, and sorry for wasting your
time.
On 11/16/06, Charlie Groves <charlie.groves@...> wrote:
> I thought OBJECT_NOT_EXIST indicated that the object you requested
> isn't available on the remote end. Is there a 'Jack B. Quick' account
> in the server? What happens if you use 'Jack Welch' like in the Java
> snippet?
>
> Charlie
>
> On 11/16/06, Gangadhar NPK <npk.gangadhar@...> wrote:
> > All,
> > I am trying to use Jython to talk to a CORBA server. The ORB I am
> > using is Visibroker. I am trying to use the bank_agent example in the
> > Visibroker installation (for those of you who have it). The idl looks
> > like this:
> > <code>
> > module Bank
> > {
> > interface Account
> > {
> > float balance();
> > };
> > interface AccountManager
> > {
> > Account open(in string name);
> > };
> > };
> > </code>
> > So, the accountmanager is used to open an account and the account is
> > used to find the balance.
> > I was able to import the Client.class (the client.java is the one
> > which talks to the server) into jython and it works fine.
> > But when I am trying to write the same code as the Client in python,
> > an exception occurs.
> > The code I am trying to use is:
> > <code>
> > import jarray
> > from java.lang import String
> > from org.omg.CORBA import ORB
> > from java.lang import Exception
> > ob1 = ORB.init(jarray.zeros(1,String),None)
> > id=range(1024)
> > name="Jack B. Quick"
> > from Bank import AccountManager
> > from Bank import AccountManagerHelper
> > m1=AccountManagerHelper.bind(ob1,"/bank_agent_poa",id)
> > from Bank import Account
> > print dir(m1.__class__)
> > account=m1.open(name)
> > </code>
> >
> >
> > The m1.open fails and the stack-trace displayed is (sorry for the
> > large stacktrace):
> > <code>
> > File "client.py", line 13, in ?
> > org.omg.CORBA.OBJECT_NOT_EXIST: vmcid: OMG minor code: 2 completed: No
> > at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> >
> > at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
> > orAccessorImpl.java:39)
> > at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
> > at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
> > at java.lang.Class.newInstance0(Class.java:350)
> > at java.lang.Class.newInstance(Class.java:303)
> > at com.inprise.vbroker.orb.SE.read(SE.java:28)
> > at com.inprise.vbroker.orb.DelegateImpl.handleReply(DelegateImpl.java:851)
> > at com.inprise.vbroker.orb.DelegateImpl.invoke(DelegateImpl.java:738)
> > at org.omg.CORBA.portable.ObjectImpl._invoke(ObjectImpl.java:457)
> > at Bank._AccountManagerStub.open(_AccountManagerStub.java:42)
> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
> > java:39)
> > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
> > sorImpl.java:25)
> > at java.lang.reflect.Method.invoke(Method.java:585)
> > at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java
> > )
> > at org.python.core.PyMethod.__call__(PyMethod.java)
> > at org.python.core.PyObject.__call__(PyObject.java)
> > at org.python.core.PyInstance.invoke(PyInstance.java)
> > at org.python.pycode._pyx0.f$0(client.py:13)
> > at org.python.pycode._pyx0.call_function(client.py)
> > at org.python.core.PyTableCode.call(PyTableCode.java)
> > at org.python.core.PyCode.call(PyCode.java)
> > at org.python.core.Py.runCode(Py.java)
> > at org.python.core.__builtin__.execfile_flags(__builtin__.java)
> > at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java)
> > at org.python.util.jython.main(jython.java)
> >
> > org.omg.CORBA.OBJECT_NOT_EXIST: org.omg.CORBA.OBJECT_NOT_EXIST: vmcid: OMG mi
> > nor code: 2 completed: No
> > <code>
> > >From the stack-trace I am assuming that some object was not getting
> > created. But the line 42 in the _AccountManagerStub.java looks like
> > this:
> > <code>
> > try {
> > 40: _output = this._request("open", true);
> > 41: _output.write_string((java.lang.String)name);
> > 42: _input = this._invoke(_output);
> > 43: _result = Bank.AccountHelper.read(_input);
> > 44: return _result;
> > }
> > </code>
> > The _invoke is failing for some reason. The corresponding code in the
> > Client.java is:
> > <code>
> > Bank.AccountManager manager = Bank.AccountManagerHelper.bind(orb,
> > "/bank_agent_poa", managerId);
> > String name = "Jack Welch";
> > Bank.Account account = manager.open(name);
> > float balance = account.balance();
> > </code>
> > Is there something in the python code that I wrote that is wrong ? I
> > tried this example with Jython 2.1 and jythonRelease_2_2alpha1, but no
> > success with either.
> > I also had to modify the jython.bat to ensure that the ORB classes are
> > defined for Visibroker. The required jars are also added to the
> > classpath (I know this because, I was able to successfully run the
> > client.class with the jars in the classpath).
> >
> > Is there something wrong in the way the python code was written ? Was
> > the object that was returned by the _bind call invalid ? And hence the
> > open call on it failed ? Any clues or hints will be very helpful. I
> > have been battling this for a while, and searching didn't find me any
> > hints.
> >
> > Thank You
> > Gangadhar
> >
> > -------------------------------------------------------------------------
> > Take Surveys. Earn Cash. Influence the Future of IT
> > Join SourceForge.net's Techsay panel and you'll get the chance to share your
> > opinions on IT & business topics through brief surveys - and earn cash
> > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> > _______________________________________________
> > Jython-users mailing list
> > Jython-users@...
> > https://lists.sourceforge.net/lists/listinfo/jython-users
> >
>
|