cancel
Showing results for 
Search instead for 
Did you mean: 

Webservice client JNDI lookup problem(classCastexception)

Former Member
0 Kudos

I have created jndi in my application in ejb-j2ee-engine.xml

<server-component-ref>

<description>

</description>

<name>AddParametersToLocationService</name>

<type>interface</type>

<jndi-name>/wsclients/proxies/xxx.com/admin~WS/com.xxx.folio.admin.wsproxy.lparam.Proxy</jndi-name>

</server-component-ref>

2.created reference in application-j2ee-engine.xml

<reference reference-type="weak">

<reference-target provider-name="sap.com"

target-type="application">admin~WS</reference-target>

</reference>

When i look up for the class it is throwing classcastexception

XXX service = (XXX) context.lookup("java:comp/env/AddService");

I printed the classname and package name of the returned Object. all are ok

Can anyone guide me to resolve classCastexception

Regards

Ganesan S

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Ganesan,

Can you paste your complete code for the client class.

When are you getting this error? while calling EJB or while calling Web Service.

Class cast Exception comes when your referenced object is not equlas or similar to calling object.

Regards,

Piyush

Answers (3)

Answers (3)

Former Member
0 Kudos

Thanks Piyush, Problem was due to wrong typecast, hence it's thrown classcast exception

Former Member
0 Kudos

Hi

I am having public getter/setter methods only .

Few more queries----->

1)In which line are you getting this error?

While Casting the returned object I am getting the Classcastexp

2) are you getting error--

a) while calling EJB

b) or calling WS from EJB

While calling WS from facade

Regards

Ganesan S

Former Member
0 Kudos

Hi Ganesan,

1) Check the structure for LOCTN_SERVICE( consumer or client side) to the one which is on the web service provider side(LOCTN_SERVICE). The interface as well as methods signatures should be same.

2) other problem may be due to wrong JNDI refrence.

Regards,

Piyush

Former Member
0 Kudos

Hi

This is my lookup code

InitialContext context = new InitialContext();

LOCTN_SERVICE ws_SERVICE =(LOCTN_SERVICE)

context.lookup("java:comp/env/RemoveService");

ServiceResponse serviceResponse =

ws_SERVICE.setLoctnService(z4rLoctnService);

Regards

Ganesan S

Former Member
0 Kudos

Hi Ganesan,

Can you check the structure for your class z4rLoctnService.

It should contain only variables name and for each variable, there should be public get/set methods.

eg.

class z4rLoctnService

{

int a;

String b;

public void setA(int a);

public int getA();

// similarly setB() and getB()

And also try including this statement in your code

// Cast object returned by the JNDI lookup to the

// appropriate datatype

home = PortableRemoteObject.narrow(ref, CustomerHome.class);

Few more queries----->

1)In which line are you getting this error?

2) are you getting error--

a) while calling EJB

b) or calling WS from EJB

Regards,

Piyush