Skip to Content
0
Former Member
Oct 03, 2005 at 08:34 AM

Typecast exception for DestinationService

60 Views

Hello everybody,

I want to use RFC destinations in my application.

I have used JCO in my EJB to connect to the R/3 system. I donot want to hardcode connection values in code.So, i have set RFC destination for that.

For this purpose i have written following code:

InitialContext ctx = new InitialContext();

DestinationService dstService = (DestinationService)

ctx.lookup(DestinationService.JNDI_KEY);

if (dstService == null)

{

throw new NamingException("Destination Service not available");

}

RFCDestination dst =

(RFCDestination) dstService.getDestination("RFC", "RFCTEST");

int maxPoolSize = dst.getMaxPoolSize();

long maxWaitTime = dst.getMaxWaitTime();

Properties jcoProperties = dst.getJCoProperties();

JCO.Client client = JCO.createClient(jcoProperties);

client.connect();

But, i am getting Class cast exception when i tried to cast my lookup object into DestinationService class.

What should be the problem in this?

Regards,

Bhavik