Re: CORBA.BAD_PARAM Exception

2007年7月19日 00:55:42 -0700

I googled that Name Server may not have started. Proposed solution is
to start the Java IDL Name Server:
<JDK1.4 Home>/bin/ tnameserv -ORBInitialPort 1050
Do I need the nameserver when accessing WS in CXF/Yoko Binding from
JacORB? I will try to run the JacORBs naming service.
I am sorry I am new to CORBA. Thanks for help
LZ
2007年7月19日, Lukas Zapletal <[EMAIL PROTECTED]>:
Hello all!
I have problem with calling WS from corba. My interface is simple:
module com {
 module pikeelectronic {
 module calc {
 interface Calculator {
 double add(in double x, in double y);
 double sub(in double x, in double y);
 double mul(in double x, in double y);
 double div(in double x, in double y);
 };
 };
 };
};
I have converted this to WSDL and created a WS using CXF wsdl2java tools:
/**
 * Please modify this class to meet your needs
 * This class is not complete
 */
package com.pikeelectronic.calc.wsserver;
import java.util.logging.Logger;
import javax.jws.WebMethod;
import javax.jws.WebResult;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;
/**
 * This class was generated by the CXF 2.0-incubator
 * Wed Jul 18 14:05:16 CEST 2007
 * Generated source version: 2.0-incubator
 *
 */
@javax.jws.WebService(name = "ComPikeelectronicCalcCalculator",
serviceName = "com.pikeelectronic.calc.CalculatorCORBAService",
 portName = "com.pikeelectronic.calc.CalculatorCORBAPort",
 targetNamespace =
"http://schemas.apache.org/yoko/idl/calc";,
 wsdlLocation = "file:calc.wsdl" ,
 endpointInterface =
"com.pikeelectronic.calc.wsserver.ComPikeelectronicCalcCalculator")
public class ComPikeelectronicCalcCalculatorImpl implements
ComPikeelectronicCalcCalculator {
 private static final Logger LOG =
 
Logger.getLogger(ComPikeelectronicCalcCalculatorImpl.class.getPackage().getName());
 /* (non-Javadoc)
 * @see 
com.pikeelectronic.calc.wsserver.ComPikeelectronicCalcCalculator#sub(double
 x ,)double y )*
 */
 public double sub(
 double x,
 double y
 )
 {
 LOG.info("Executing operation sub");
 return x - y;
 }
 /* (non-Javadoc)
 * @see 
com.pikeelectronic.calc.wsserver.ComPikeelectronicCalcCalculator#div(double
 x ,)double y )*
 */
 public double div(
 double x,
 double y
 )
 {
 LOG.info("Executing operation div");
 return x / y;
 }
 /* (non-Javadoc)
 * @see 
com.pikeelectronic.calc.wsserver.ComPikeelectronicCalcCalculator#mul(double
 x ,)double y )*
 */
 public double mul(
 double x,
 double y
 )
 {
 LOG.info("Executing operation mul");
 return x * y;
 }
 /* (non-Javadoc)
 * @see 
com.pikeelectronic.calc.wsserver.ComPikeelectronicCalcCalculator#add(double
 x ,)double y )*
 */
 public double add(
 double x,
 double y
 )
 {
 LOG.info("Executing operation add");
 return x + y;
 }
}
I have implemented a client in JacORB:
package com.pikeelectronic.calc.CORBAClient;
/**
 * An example for using the Dynamic Invocation Interface
 */
//import org.omg.CosNaming.*;
public class Client
{
 public static void main( String[] args )
 {
 org.omg.CORBA.ORB orb = null;
 try
 {
 orb = org.omg.CORBA.ORB.init(args,null);
 org.omg.CORBA.Object obj =
orb.string_to_object("corbaloc::192.168.3.230:40000/calc");
 /*org.omg.CORBA.Object object = orb.resolve_initial_references(
"NameService" );
 NamingContext context = NamingContextHelper.narrow( object );*/
 Calculator c = CalculatorHelper.narrow(obj);
 System.out.println("Initialize ready.....");
 System.out.println("2 + 2 = " + c.add((double)2, (double)2));
 System.out.println("2 * 2 = " + c.mul((double)2, (double)2));
 System.out.println("2 / 2 = " + c.div((double)2, (double)2));
 System.out.println("2 - 2 = " + c.sub((double)2, (double)2));
 }
 catch (Exception e)
 {
 e.printStackTrace();
 }
 orb.shutdown(false);
 }
}
I run the server (in the CXF standalone mode):
public class ComPikeelectronicCalcCalculatorServer{
 protected ComPikeelectronicCalcCalculatorServer() throws Exception {
 System.out.println("Starting Server");
 Object implementor = new ComPikeelectronicCalcCalculatorImpl();
 String address = "corbaloc::192.168.3.230:40000/calc";
 Endpoint.publish(address, implementor);
 }
 public static void main(String args[]) throws Exception {
 new ComPikeelectronicCalcCalculatorServer();
 System.out.println("Server ready...");
 Thread.sleep(60 * 60 * 1000);
 System.out.println("Server exitting");
 System.exit(0);
 }
}
And I run the client. Its giving me this result:
org.omg.CORBA.BAD_PARAM: vmcid: 0x0 minor code: 0 completed: No
 at 
com.pikeelectronic.calc.CORBAClient.CalculatorHelper.narrow(CalculatorHelper.java:60)
 at com.pikeelectronic.calc.CORBAClient.Client.main(Client.java:23)
Whats wrong? Did I miss something?
--
Lukas Zapletal
http://lukas.zapletalovi.com
--
Lukas Zapletal
http://lukas.zapletalovi.com

Reply via email to