cancel
Showing results for 
Search instead for 
Did you mean: 

ClassCastException during JNDI lookup

Former Member
0 Kudos

Hi Gurus,

I am using NW CE 7.1.

I have developed a Java Resource Adapter and deployed it successfully. I am able to see the jndi name in the JNDI Browser.

To test this adapter I have developed a simple Web Application having a Servlet. The servlet does jndi lookup and invokes an operation on the adapter.

The web application WAR file bundles the adapter classes into a jar in the WEB-INF/lib folder.

When I run the web app, during jndi lookup, I get ClassCastException for the ConnectionFactory class of the adapter. I understand that the class is getting loaded by two different class loaders but not able to resolve this issue.

The stack trace is

Details: java.lang.ClassCastException: class com.sap.engine.services.jndi.implclient.ClientContext:service:naming @ 
com.sap.engine.boot.loader.ResourceMultiParentClassLoader @ f5331a @ alive 
incompatible with class 
test.ConnectionFactoryTest:JavaEE/AdapterClient1@ 
com.sap.engine.boot.loader.ResourceMultiParentClassLoader @ 1a27fce @ alive

I tried following alternatives.

Alternative 1:

Removed the common jars from WAR and redeployed it.

With this I got ClassNotFoundException for the ConnectionFactory class.

Alternative 2:

Packaging WAR and RAR into an EAR. Here I took out the common jars from both WAR and RAR and added them directly in EAR.

With this I got ClassCastException for the ConnectionFactory class.

Thanks in advance.

JK

Edited by: Jitendra Kharche on Jul 15, 2010 12:03 PM

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Got resolved.

I was using wrong/imcomplete jndi name. Used complete jndi name "deployedAdapters/myra/shareable/myra".

Then I got another ClassCastException as

Details: java.lang.ClassCastException: class test.ConnectionFactoryTest:JavaEE/myra @ 
com.sap.engine.boot.loader.ResourceMultiParentClassLoader @ f5331a @ alive 
incompatible with class 
test.ConnectionFactoryTest:JavaEE/AdapterClient1@ 
com.sap.engine.boot.loader.ResourceMultiParentClassLoader @ 1a27fce @ alive

Then I did following steps:

1. bundled the WAR and RAR into an EAR.

2. took out the common jars from both WAR and RAR and added them directly in EAR.

Thanks.

JK