Solved

java client calling on a CORBA Server

Posted on 2004-10-28
932 Views
Last Modified: 2013-12-22
dear all,
I am trying to connect to a CORBA server using java.
The IDL file is
***********************IDL FILE***************************************
module SA
{
   struct outLSMSResp
   {
      string TN;
      string LRN;
      string LSMS_STATUS;
      string SERVICE_PROVIDER_ID;
      string ACTIVATION_DATE;
      string PORT_TYPE;
      string OLD_NPA;
      string NPAC_ID;
      string DOWNLOAD_REASON;
      string POOL_INDICATOR;
      string DONOR_SPID;
      string POOL_ALLOCATION_SPID;
      string POOL_ACTIVATION_TIME;
      string POOL_LRN;
   };

   struct inTNQuery
   {
      string USERID;
      string SYSTEM_NAME;
      string TN;
   };

   struct NameValuePair
   {
      string name;
      string value;
   };
   
   typedef outLSMSResp LSMSResp;
   typedef inTNQuery TNQuery;
   typedef sequence<NameValuePair> GenericParam;

   interface LSMS
   {
      long getLSMSData(in TNQuery TNInfo, out LSMSResp LSMSInfo);
      long SyncServiceRequest(in GenericParam Request,
                              out GenericParam Response);
   };
};

************************************************************

client java file is
**********************JAVA CLIENT FILE*****************************************
//This will import the files you generated from the IDL.
import SA.*;
//Import the Java classes for file I/O.
import java.io.*;

public class ClientSA {
  public static void main(String[] args) {
    //A variable to hold the IOR in.
    String ior = null;

    //First, we need to read in the IOR from a file (this is probably the
    //hardest part of the program!!). Reading in ANY file in Java is
    //ALWAYS a bitch...
    try {
      //Open the file for reading:
      BufferedReader reader =
        new BufferedReader(new FileReader("ns.ior"));

      //Read the first line which is the IOR and save it to the 'ior' variable.
      //variable:
      ior = reader.readLine();

      //Be nice and close the file:
      reader.close();



    //We need to create our own ORB that will then connect to the CORBA
    //server at the EBI:
    org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null);

    //Use the IOR to connect to the EBI CORBA server and return a CORBA
    //object:
    org.omg.CORBA.Object object = orb.string_to_object(ior);

    //Convert this CORBA object to the SecretMessage object that it actually is on the
    //CORBA server at the EBI:
    LSMS bioSequenceServer = LSMSHelper.narrow(object);

    } catch (Exception ex) {
          //There was a problem with reading the file - Bomb out.
          ex.printStackTrace();
          System.exit(0);
    }
  }
}
//End of program




**********************JAVA CLIENT FILE*****************************************



I am getting the following error when i run the client

org.omg.CORBA.BAD_PARAM:   vmcid: 0x0  minor code: 0  completed: No
        at SA.LSMSHelper.narrow(LSMSHelper.java:60)
        at ClientSA.main(ClientSA.java:38)


has anybody come across this . i Googled but didnt get much info.

thanks in advance

Kiran
0
Question by:kiranhk
    20 Comments
     
    LVL 5

    Expert Comment

    by:Hammadian2
    ior = reader.readLine();

    make sure that ior gets the correct value
    coz if it's not, 'object' will be null
    and  LSMSHelper.narrow(object) will cause this error

    also

    make sure that the Java IDL Name Serverhave started from JDK1.4

    and

    make sure you have all the necessary jar files in your classpath (eg vbjapp.jar)
    0
     
    LVL 8

    Author Comment

    by:kiranhk
    thanks for your immediate reply
    I have all the necessary jar files in the classpath(eg vbjapp.jar) and also i am sure there is no problem with the ior file and the object is not null i checked for the null condition now.
    so there is some problem happening when it is casting/narrowing it down to the particular object.

    any help is appreciated.

    thanks


    0
     
    LVL 5

    Expert Comment

    by:Hammadian2
    try explicit casting
    0
     
    LVL 8

    Author Comment

    by:kiranhk
    If i cast explictly i get CCE

    java.lang.ClassCastException: org.omg.CosNaming._NamingContextExtStub
            at ClientSA.main(ClientSA.java:39)
    0
     
    LVL 5

    Expert Comment

    by:Hammadian2
    good
    then we're sure now that  LSMSHelper.narrow(object) doesnt return an LSMS as u expect from it

    try the find the returning type of LSMSHelper.narrow(object)
    0
     
    LVL 8

    Author Comment

    by:kiranhk
    LSMSHelper is generated when i run the idlj on the idl file and it is returning and LSMS object.

    this is the generated code

      public static SA.LSMS narrow (org.omg.CORBA.Object obj)
      {
        if (obj == null)
          return null;
        else if (obj instanceof SA.LSMS)
          return (SA.LSMS)obj;
        else if (!obj._is_a (id ()))
          throw new org.omg.CORBA.BAD_PARAM ();
        else
        {
          org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate ();
          SA._LSMSStub stub = new SA._LSMSStub ();
          stub._set_delegate(delegate);
          return stub;
        }
      }
    0
     
    LVL 5

    Expert Comment

    by:Hammadian2
    this is the case that causes trouble:

     else if (!obj._is_a (id ()))
          throw new org.omg.CORBA.BAD_PARAM ();

    0
     
    LVL 8

    Author Comment

    by:kiranhk
    i know that and understand that.
    i want to know what is happening and how to solve it. This is not the code what i wrote, this is the code which the IDL to Java compiler will generate when it is run on a IDL file. Nobody changes these code, we only have to change the IDL and the compiler will generate this code
    0
     
    LVL 5

    Expert Comment

    by:Hammadian2
    I'm sorry
    i'm not good with CORBA
    i was just trying to help with JAVA
    0
     
    LVL 8

    Author Comment

    by:kiranhk
    no problem. i have good experience in java/j2ee so i dont need  help on that side.
    basically i am having problem when running the client which tries to connect to the CORBA server

    thanks anyway

    Anybody ????
    0
     
    LVL 1

    Expert Comment

    by:gushaa
    I think that the object you get when you convert the IOR to an object

    org.omg.CORBA.Object object = orb.string_to_object(ior);

    is not the correct type so when you try to narrow it down to the class you want, you get the BAD_PARAM error.
    0
     
    LVL 8

    Author Comment

    by:kiranhk
    As i told in my previous post i am not a beginner in java/j2ee, so please dont try to explain me abt the literal meaning of the error i am getting, i can understand that just by seeing it. i have been working with java/j2ee for years so know some of the intricacies.

    any help anybody??


    PS: please dont treat me a beginner to java
    0
     
    LVL 1

    Expert Comment

    by:gushaa
    I have some questions.

    Are you sure that the CORBA server is working correctly? Have you tried to access the object with some other program or some other programming language?
    0
     
    LVL 8

    Author Comment

    by:kiranhk
    yes, it is working correctly. other .net team applications r able to work with it.
    they suggested there might be some firewall issue??
    any insights
    0
     
    LVL 1

    Accepted Solution

    by:
    If im not mistaken CORBA opens ports randomly in the high port range >1023 (not 100% sure) so if you are allowed you could try to open those ports on your firewall.

    If you are not allowed to open those ports you can try to find out if its possible to name what ports should be used in the CORBA implementation that you are using.
    0
     
    LVL 1

    Expert Comment

    by:gushaa
    Forgot to say that I read somewhere that CORBA does not work through NAT firewalls without some sort of proxy. I don't know much about that but maybe that hint could help you somehow.
    0
     
    LVL 8

    Author Comment

    by:kiranhk
    i will check that out
    0
     
    LVL 8

    Author Comment

    by:kiranhk
    thanks for the info.

    there is no problem with the Firewall. i checked with our admin guys.

    Any other leads please???

    thanks in advance
    0
     
    LVL 8

    Author Comment

    by:kiranhk
    Got it working. There was a problem with the versions we were using.
    The server was Visibroker 4.5 and the client was using Visibroker 3.x jar files.

    thanks for the help though.

    Kiran
    0
     
    LVL 1

    Expert Comment

    by:gushaa
    Glad to hear that you got it working.
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    860 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now