Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Can't get POA to work correctly ?

3 views
Skip to first unread message

Mark Lyttle

unread,
Nov 22, 2001, 11:37:51 AM11/22/01
to
I have been playing with the POA stuff with the latest beta of J2SE 1.4.
The application is a simple demo which I have converted from the 1.3 BOA
stuff. However I can't seem to get it to work correctly. Any ideas
anybody ??

The following client code gives an Exception, see below.

---- CLIENT ---------
import SimpleBank.* ;
import org.omg.CosNaming.* ;
import org.omg.CosNaming.NamingContextPackage.* ;

import org.omg.CORBA.*;

public class BankClient {

static Bank bankImpl ;

public static void main( String args[] )
{
try {
ORB orb = ORB.init( args, null ) ;

org.omg.CORBA.Object objRef = orb.resolve_initial_references(
"NameService" ) ;
NamingContextExt ncRef = NamingContextExtHelper.narrow( objRef )
;

String name = "FirstRemoteBank" ;
bankImpl = BankHelper.narrow( ncRef.resolve_str( name ) ) ;

System.out.println( "Obtained a handle on server object: " +
bankImpl.name() ) ;
System.out.println( orb.object_to_string( bankImpl ) ) ;

Account account = bankImpl.openAccount( "00001", "Mark",
AccountType.DEPOSIT ) ;
}
catch ( Exception e ) {
System.out.println( "ERROR : " + e ) ;
e.printStackTrace( System.out ) ;
}
}
}

ERROR : org.omg.CORBA.BAD_INV_ORDER: vmcid: 0x0 minor code: 0
completed: No
org.omg.CORBA.BAD_INV_ORDER: vmcid: 0x0 minor code: 0 completed: No
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:42)

at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:30)

at
java.lang.reflect.Constructor.newInstance(Constructor.java:277)
at java.lang.Class.newInstance0(Class.java:301)
at java.lang.Class.newInstance(Class.java:254)
at
com.sun.corba.se.internal.iiop.messages.ReplyMessage_1_2.getSystemException(ReplyMessage_1_2.java:93)

at
com.sun.corba.se.internal.iiop.ClientResponseImpl.getSystemException(ClientResponseImpl.java:108)

at
com.sun.corba.se.internal.POA.GenericPOAClientSC.invoke(GenericPOAClientSC.java:136)

at
org.omg.CORBA.portable.ObjectImpl._invoke(ObjectImpl.java:460)
at SimpleBank._BankStub.openAccount(_BankStub.java:41)
at BankClient.main(BankClient.java:26)

---- SERVER
import org.omg.CosNaming.* ;
import org.omg.CosNaming.NamingContextPackage.* ;

import org.omg.CORBA.* ;
import org.omg.PortableServer.* ;
import org.omg.PortableServer.POA ;

import java.util.Properties ;
import java.io.* ;

import SimpleBank.* ;

public class POABankServer {

public static void main( String args[] )
{
try {
Properties props = System.getProperties() ;
props.put( "org.omg.CORBA.ORBClass",
"com.sun.corba.se.internal.POA.POAORB" ) ;

ORB orb = ORB.init( args, props ) ;

POA rootPOA = ( POA )orb.resolve_initial_references( "RootPOA" )
;
POAManager poaManager = rootPOA.the_POAManager() ;

String bankName = "FirstRemoteBank" ;
BankImpl bankImpl = new BankImpl( bankName ) ;

POA poa = rootPOA ;

poa.activate_object_with_id( bankName.getBytes(), bankImpl ) ;

org.omg.CORBA.Object namingRef = orb.resolve_initial_references(
"NameService" ) ;
NamingContextExt naming = NamingContextExtHelper.narrow(
namingRef ) ;

NameComponent name[] = naming.to_name( bankName ) ;
naming.rebind( name, poa.servant_to_reference( bankImpl ) ) ;

poaManager.activate() ;
System.out.println( "Bank " + bankName + " is now open." ) ;

orb.run( ) ;
}
catch ( SystemException sExcept ) {
System.err.println( "Remote Bank Server CORBA System Exception:
" + sExcept ) ;
sExcept.printStackTrace( System.err ) ;
}
catch ( Exception except ) {
System.err.println( "Remote Bank Server Exception: " + except )
;
except.printStackTrace( System.err ) ;
}

System.exit( 1 ) ;
}
}

-----IDL

module SimpleBank {

interface Account ;
interface Bank ;

enum AccountType { DEPOSIT, CHEQUE } ;

struct FunnyMoney {
long amount ;
} ;

exception BankingException {
string message ;
} ;

interface Account {
readonly attribute string number ;
readonly attribute string name ;
readonly attribute AccountType type ;

FunnyMoney deposit( in FunnyMoney money ) raises
(BankingException) ;
FunnyMoney getBalance( ) raises (BankingException) ;
} ;

interface DepositAccount : Account {
} ;

interface ChequeAccount : Account {
FunnyMoney withdraw( in FunnyMoney money ) raises
(BankingException) ;
} ;

typedef sequence <Account> AccountList ;
typedef sequence <string> AccountNumberList ;

interface Bank {
readonly attribute string name ;

Account openAccount( in string number, in string name, in
AccountType type )
raises
(BankingException) ;
void closeAccount( in string number ) raises (BankingException)
;

AccountNumberList getAllAccountNumbers( ) raises
(BankingException) ;
Account getAccount( in string number ) raises (BankingException)
;
AccountList getAllAccounts( ) raises (BankingException) ;
} ;
} ;

<

M.Lyttle.vcf
0 new messages