Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

communication bet. corba servlet program to server corba program

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Dear Friends,
I am getting a very serious problem.If possible please help me as soon as possible.My problem is---

1.Whenever I am trying to make the commuicatio between my servlet corba client to server corba via visibroker(4.5).I am getting a org.omg.CORBA.BAD_PARAM error at runtime.
I also know that this error is coming due to narrow method.
But I am not able to rectify it.Below ,I am giving my corba client servlet,server corba ,servant file with the idl.Plzz help me.

//Corba Client Servlet

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class JokeClientServlet1 extends HttpServlet
{
public void init(ServletConfig config) throws ServletException
{
super.init(config);
String str1="10";
String str2="aftab";
String str[]=new String[2];
str[0]=str1;
str[1]=str2;
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(str,null);
try
{
byte[] JokeId= "JokeObject".getBytes();
chapter3.joke manager = chapter3.jokeHelper.bind(orb,"Joke_poa",JokeId);
int R = Integer.parseInt(str1);
long Dollar = manager.convert(R);
String show = manager.welcome(str2);
System.out.println(show);
System.out.println(R+" Us Dollars are Equals to Indian Rupees"+Dollar);
System.out.println("AFTABY");
}
catch(Exception ex)
{
System.out.println(ex);
}
}

public void doPost(HttpServletRequest req,HttpServletResponse res) throws IOException,ServletException
{
try
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
out.println(&quot;<html>&quot;);
out.println(&quot;<body>&quot;);
out.println(&quot;hi&quot;);
out.println(&quot;</body>&quot;);
out.println(&quot;</html>&quot;);
}catch(Exception ex)
{}
}
}

//Corba Server Program

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

public class JokeServer1
{
public static void main(String[] args)
{
try
{
ORB orb = ORB.init(args,null);
POA rootPOA = POAHelper.narrow(orb.resolve_initial_references(&quot;RootPOA&quot;));

//Create policies for our persistent POA
org.omg.CORBA.Policy[] policies={rootPOA.create_lifespan_policy(LifespanPolicyValue.PERSISTENT)};
POA myPOA = rootPOA.create_POA(&quot;Joke_poa&quot;,rootPOA.the_POAManager(),policies);
JokeImpl JokeServant = new JokeImpl();
byte[] JokeId = &quot;JokeObject&quot;.getBytes();
myPOA.activate_object_with_id(JokeId,JokeServant);
rootPOA.the_POAManager().activate();

System.out.println(myPOA.servant_to_reference(JokeServant)+&quot; is ready.&quot;);
orb.run();
}
catch(Exception ex)
{
System.out.println(ex);
}
}
}

//Servant Program

import org.omg.PortableServer.*;
import java.awt.*;
import java.net.URL.*;
import java.sql.*;
import java.util.*;

public class JokeImpl extends chapter3.jokePOA
{
public int convert(int Dollar)
{
int R = Dollar;
int Dollar1=45*R;
return Dollar1;
}
public String welcome(String Name)
{
String joke=&quot;Hi &quot;+Name+&quot; Welcome to the USA&quot;;
return joke;
}
}

// joke.IDL FILE
module chapter3
{
interface joke
{
long convert (in long Dollars);
string welcome(in string Name);
};
};



 
Hi,
I got 2 doubts on seeing your code
1. In the server code do you need ORB::Init ?
2.Also resolve_initial_references call must be made on the BootStrap object and not on ORB isn't it .. ?

Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top