Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

java client calling on a CORBA Server

Posted on 2004-10-28
20
Medium Priority
?
942 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
Comment
Question by:kiranhk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 5
  • 5
20 Comments
 
LVL 5

Expert Comment

by:Hammadian2
ID: 12437250
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
ID: 12437306
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
ID: 12437365
try explicit casting
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 8

Author Comment

by:kiranhk
ID: 12437384
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
ID: 12437456
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
ID: 12437467
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
ID: 12437573
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
ID: 12437649
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
ID: 12437774
I'm sorry
i'm not good with CORBA
i was just trying to help with JAVA
0
 
LVL 8

Author Comment

by:kiranhk
ID: 12437975
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
ID: 12441978
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
ID: 12444693
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
ID: 12464905
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
ID: 12465218
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:
gushaa earned 1000 total points
ID: 12465432
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
ID: 12465501
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
ID: 12465638
i will check that out
0
 
LVL 8

Author Comment

by:kiranhk
ID: 12473918
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
ID: 12485204
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
ID: 12486310
Glad to hear that you got it working.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Six Sigma Control Plans
Suggested Courses

636 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