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

Help needed with visibroker

4 views
Skip to first unread message

debopam

unread,
Oct 11, 2004, 5:04:01 AM10/11/04
to
Hi All,
I am developing an application using Visibroker. I have created a IDL as
follows:-
============== Start of IDL ==============
module ciims
{
module idl
{
typedef sequence<octet> Message;
interface UserContext;
/* ------------- Enumerations ------------- */
enum ExecutionMode
{
CIIMS_NORMAL_MODE,
CIIMS_TRAINING_MODE
};

enum LanguageType
{
CIIMS_ENGLISH,
CIIMS_CHINESE
};

enum SessionTerminateOption
{
CIIMS_NORMAL,
CIIMS_IMMEDIATE
};

/* ------------- Structs ------------- */
struct CompletionPacket
{
string version;
string returnCode;
long messageCount;
Message messageText;
};

struct ConnectCompletionPacket
{
string version;
string return_code;
Message message_text;
long maximum_message_size;
long minimum_keep_alive_interval;
long inactive_time_out;
ExecutionMode execution_mode;
LanguageType language_type;
string subsystem_id;
string privilege;
};

struct ConnectOptionPacket
{
string user_id;
string password;
string subsystem_id;
};

struct TerminateOptionPacket
{
string subsystem_id;
SessionTerminateOption terminate_option;
};


/* ------------- Interfaces ------------- */
interface Base
{
short destroy();
};

interface EntryPoint: Base
{
UserContext connect (out ConnectCompletionPacket
messageCompletion,
in ConnectOptionPacket messageOption,
inout Message messageBody);
};

interface UserContext: Base
{
short keepAlive (out CompletionPacket messageCompletion);
short disconnect (out CompletionPacket messageCompletion,
in TerminateOptionPacket messageOption,
inout Message messageBody);
};
};
};
============== End of IDL ==============

Using the above idl, i have generated the classes using idl2java.
Then i have created a server, whose code is as follows:-

============== Start of Server Code ==============
package ciims.rtib.server;

import org.omg.PortableServer.LifespanPolicyValue;
import org.omg.PortableServer.POA;
import org.omg.PortableServer.POAHelper;

public class ServerMain
{
public static void main(String args[])
{
int status = 0;
org.omg.CORBA.ORB orb = null;
try
{
// Initialize the ORB.
orb = org.omg.CORBA.ORB.init(args,null);
status = run(orb);
}
catch(Exception ex)
{
ex.printStackTrace();
status = 1;
}
if(orb != null)
{
try
{
orb.destroy();
}
catch(Exception ex)
{
ex.printStackTrace();
status = 1;
}
}
System.exit(status);
}//main
static int run(org.omg.CORBA.ORB orb) throws
org.omg.CORBA.UserException
{
org.omg.PortableServer.POAManager manager;
POA rootPOA;
org.omg.PortableServer.POA myPOA;
try
{
// get a reference to the root POA
rootPOA
=POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
manager = rootPOA.the_POAManager();

// Create policies for our persistent POA
org.omg.CORBA.Policy[] policies=

{rootPOA.create_lifespan_policy(LifespanPolicyValue.PERSISTENT)};

// Create myPOA with the right policies
myPOA=rootPOA.create_POA("ciims", rootPOA.the_POAManager(),
policies);

// Create the servant
CIIMSEntryPoint ciimsEntryPoint = new CIIMSEntryPoint();

// Create an Id and Activate the servant with the ID on myPOA

myPOA.activate_object_with_id("ciims".getBytes(),ciimsEntryPoint);
}
catch(Exception ex)
{
ex.printStackTrace();
return 1;
}
// Activate the POA manager
manager.activate();
System.out.println(myPOA.the_name() + " is ready.
POA==>"+rootPOA);

// Wait for incoming requests
orb.run();
return 0;
}//run
}
============== End of Server Code ==============

and the client:-

============== Start of Client Code ==============
package ciims.test.subsystem;

import ciims.idl.ConnectCompletionPacket;
import ciims.idl.ConnectCompletionPacketHolder;
import ciims.idl.ConnectOptionPacket;
import ciims.idl.EntryPoint;
import ciims.idl.EntryPointHelper;
import ciims.idl.ExecutionMode;
import ciims.idl.LanguageType;
import ciims.idl.MessageHolder;
import ciims.idl.UserContext;

/**
*
* @author Debopam Ghoshal
*/
public class ClientMain
{
/** Creates a new instance of ClientMain */
public ClientMain()
{
}

public static void main(String[] s)
{
int status = 0;
org.omg.CORBA.ORB orb = null;
try
{
System.out.println("Initializing the orb...");
orb = org.omg.CORBA.ORB.init(s, null);
status = run(orb);
}
catch(Exception x)
{
System.out.println("Error while initializing ORB.");
x.printStackTrace();
}

if(orb != null)
{
try
{
orb.destroy();
}
catch(Exception x)
{
System.out.println("Error while destroying orb.");
x.printStackTrace();
}
}
}

static int run(org.omg.CORBA.ORB orb)
{
try
{
EntryPoint entryPoint = EntryPointHelper.bind(orb, "/ciims",
"ciims".getBytes());
System.out.println("Bind successful...");

// Create ConnectCompletionPacket
ConnectCompletionPacket connectComp = new
ConnectCompletionPacket();
//connectComp.execution_mode =
ExecutionMode.CIIMS_NORMAL_MODE;
//connectComp.inactive_time_out = 1800;
//connectComp.language_type = LanguageType.CIIMS_ENGLISH;
//connectComp.maximum_message_size = 1200;
//connectComp.message_text = "Test Message".getBytes();
//connectComp.minimum_keep_alive_interval = 1000;
//connectComp.privilege = "10000110001";
//connectComp.return_code = "rc";
connectComp.subsystem_id = "DUMMY";
//connectComp.version = "1.00";

// Put it in the holder.
ConnectCompletionPacketHolder connectHolder =
new ConnectCompletionPacketHolder(connectComp);

// Create ConnectOptionPacket
ConnectOptionPacket connectOption = new
ConnectOptionPacket();
connectOption.user_id = "system";
connectOption.password = "system";
connectOption.subsystem_id = "ADMIN";

// Create the Message.
MessageHolder msgHolder = new MessageHolder("Test
Message".getBytes());

System.out.println("Calling method...");
UserContext userContext = entryPoint.connect(connectHolder,
connectOption, msgHolder);

return 0;
}
catch (org.omg.CORBA.UNKNOWN ux)
{
System.out.println("Error while calling method.");
ux.printStackTrace();
return -1;
}
catch(Exception x)
{
System.out.println("Error while binding servant.");
x.printStackTrace();
return -1;
}
}
}

============== End of Client Code ==============
When i run the server i get the following output:-
ciims is ready. POA==>POA[name=/,fullname=/]
CIIMSEntryPoint.connect() has been called.

When i run the client, i get the following output:-
Initializing the orb...
Bind successful...
Calling method...
Error while calling method.
org.omg.CORBA.UNKNOWN: vmcid: 0x0 minor code: 0 completed: No
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)

at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
orAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:27)
at
java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at java.lang.Class.newInstance0(Class.java:308)
at java.lang.Class.newInstance(Class.java:261)
at com.inprise.vbroker.orb.SE.read(SE.java:28)
at
com.inprise.vbroker.orb.DelegateImpl.handleReply(DelegateImpl.java:85
2)
at
com.inprise.vbroker.orb.DelegateImpl.invoke(DelegateImpl.java:739)
at org.omg.CORBA.portable.ObjectImpl._invoke(ObjectImpl.java:457)
at ciims.idl._EntryPointStub.connect(_EntryPointStub.java:51)
at ciims.test.subsystem.ClientMain.run(ClientMain.java:94)
at ciims.test.subsystem.ClientMain.main(ClientMain.java:38)

Can anyone please help me out with this problem?

Thanks a lot in advance,
~Debopam~

Mark Woyna

unread,
Oct 11, 2004, 2:55:22 PM10/11/04
to
I haven't used "out" parameters in ages, but I don't believe you
can attempt to marshall null attributes. It appears that you're
allocating a ConnectCompletionPacket (struct) object, but the
attributes aren't being initialized, as the code is commented-out.
Since uninitialized strings are null in Java, and CORBA doesn't
allow null (primitive) values, this may be causing your problem.

Why don't you try setting the struct string attributes to "".

Mark

> // Create ConnectCompletionPacket
> ConnectCompletionPacket connectComp = new
> ConnectCompletionPacket();
> //connectComp.execution_mode =
> ExecutionMode.CIIMS_NORMAL_MODE;
> //connectComp.inactive_time_out = 1800;
> //connectComp.language_type = LanguageType.CIIMS_ENGLISH;
> //connectComp.maximum_message_size = 1200;
> //connectComp.message_text = "Test Message".getBytes();
> //connectComp.minimum_keep_alive_interval = 1000;
> //connectComp.privilege = "10000110001";
> //connectComp.return_code = "rc";
> connectComp.subsystem_id = "DUMMY";
> //connectComp.version = "1.00";


"debopam" <debo...@yahoo.com> wrote in message news:<65612772b9b4e70b...@localhost.talkaboutprogramming.com>...

LL

unread,
Oct 12, 2004, 3:39:30 AM10/12/04
to
Seems like some java exception is being thrown on the server side (e.g. NPE)

On the server, set the following property:
vbroker.orb.warn=2

Re-run your application and note the actual exception thrown.

If above property does not help, set following additional props:
vbroker.orb.debug=true
vbroker.orb.logLevel=debug

HTH
LL

0 new messages