• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
Sheriffs:
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
Bartenders:
  • Carey Brown
  • salvin francis
  • Piet Souris

ClassCastException at lookup

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
i will thankful if you please go through my problem and suggest me where i am wrong
i am very new to EJB,i have made very simple hello ejb
and i have sucessfully deployed and its status is running i have
set class path so that it should include deployed jar files fron
deployedEJBs folder,
then i try to run my client and it gives following execption
1
2
3
4
java.lang.ClassCastException
at com.ibm.ejs.ns.jndi.CNContextImpl.isContex
ava:1252)
at com.ibm.ejs.ns.jndi.CNContextImpl.doLookup
at com.ibm.ejs.ns.jndi.CNContextImpl.lookup(C
at javax.naming.InitialContext.lookup(Initial
at NishantClient.main(NishantClient.java:28)
please help me what should i do
with regards
Nishant
 
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nishant,
ClassCastException may occur due to several reasons.Check the following:

  1. All the required jar files are available.
  2. The correct jar files are available while client call and during deployment.This is the problem with Oracle products not sure about IBM though!
  3. The Home Object has been published properly in the JNDI namespace.

  4. Most likely the lookup is not able to find the correct HomeObject.This hints to the fact that deployment may not have been correct.Note it may not show errors while deployment but still as I have mentioned in 2, there may be version conflicts.Do confirm that this is not a problem before trying anything different.
    Good luck,
    Sandeep
    Sun Certified Programmer for Java 2 Platform Scored 93%
    Oracle Certified Solution Developer - JDeveloper
    -- Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
    -- Object-Oriented Analysis and Design with UML Scored 73%
    Oracle Certified Enterprise Developer - Oracle Internet Platform
    -- Enterprise Connectivity with J2EE Scored 72%
    -- Enterprise Development on the Oracle Internet Platform Scored 44 out of 56
    [This message has been edited by Desai Sandeep (edited June 26, 2001).]
 
nishant srivastava
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Desai Sandeep:
Hi Nishant,
ClassCastException may occur due to several reasons.Check the following:


  1. All the required jar files are available.
  2. The correct jar files are available while client call and during deployment.This is the problem with Oracle products not sure about IBM though!
  3. The Home Object has been published properly in the JNDI namespace.

  4. Most likely the lookup is not able to find the correct HomeObject.This hints to the fact that deployment may not have been correct.Note it may not show errors while deployment but still as I have mentioned in 2, there may be version conflicts.Do confirm that this is not a problem before trying anything different.
    Good luck,
    [b]Sandeep

    Sun Certified Programmer for Java 2 Platform Scored 93%
    Oracle Certified Solution Developer - JDeveloper
    -- Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
    -- Object-Oriented Analysis and Design with UML Scored 73%
    Oracle Certified Enterprise Developer - Oracle Internet Platform
    -- Enterprise Connectivity with J2EE Scored 72%
    -- Enterprise Development on the Oracle Internet Platform Scored 44 out of 56
    [This message has been edited by Desai Sandeep (edited June 26, 2001).][/B]



Hi!
Thanks for your co-operation.
ok i will tell step by step what i did.
following is my Remote interface
package venus.scc.ejb.stateless.session.bean.nishant;
import java.rmi.RemoteException;
import javax.ejb.EJBObject;
public interface Nishant extends EJBObject
{
public abstract String getMessage() throws RemoteException;
}
my home interface
package venus.scc.ejb.stateless.session.bean.nishant;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;
public interface NishantHome extends EJBHome
{
public abstract Nishant create() throws RemoteException, CreateException;
}
bean class
package venus.scc.ejb.stateless.session.bean.nishant;

import java.rmi.RemoteException;
import java.util.ListResourceBundle;
import java.util.ResourceBundle;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
public class NishantBean implements SessionBean
{
public NishantBean() { }
public void ejbActivate() throws RemoteException { }
public void ejbCreate() { }
public void ejbPassivate() throws RemoteException { }
public void ejbRemove() throws RemoteException { String msgs = null; }
public String getMessage() throws RemoteException {
return "Nishant";
}
public void setSessionContext(SessionContext sessioncontext) throws RemoteException { }
}
i keep them inpacakege structure like "venus.scc.ejb.stateless.session.bean.nishant" where venus folder is at deployableEJBs,then i run th following script
jar cfv nishantkijar.jar venus/scc/ejb/stateless/session/bean/nishant/*.class
then i opened this jar file with jetace and put the name of bean as venus.scc.ejb.stateless.session.bean.nishant.NishantBean
then i save the saved the resulting jar file in deployed using admin console it deployed sucessfully and i started it,

at classpath all deployed jar files are present.
please tell me where is the mistake
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nishant,
I was wondering why you were not setting the SessionContext in your SessionBean
Could you try the following version of Bean and let me know what happens.
<pre>
public class NishantBean implements SessionBean {

protected SessionContext ctx;

public void ejbActivate() throws RemoteException {
}
public void ejbCreate() throws CreateException,RemoteException {
}
public void ejbPassivate() throws RemoteException {
}
public void ejbRemove() throws RemoveException,RemoteException {
}
public String getMessage() throws RemoteException {
return "Nishant";
}
public void setSessionContext(SessionContext ctx) throws RemoteException {
this.ctx = ctx;
}
}
</pre>

Other things looks alright for the components you pasted.Just confirm that the client does a lookup at the right URL that has been published while deployment.
Hope this helps,
Sandeep
[This message has been edited by Desai Sandeep (edited June 27, 2001).]
 
nishant srivastava
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Desai Sandeep:
Hi Nishant,
I was wondering why you were not setting the [b]SessionContext
in your SessionBean
Could you try the following version of Bean and let me know what happens.
<pre>
public class NishantBean implements SessionBean {

protected SessionContext ctx;

public void ejbActivate() throws RemoteException {
}
public void ejbCreate() throws CreateException,RemoteException {
}
public void ejbPassivate() throws RemoteException {
}
public void ejbRemove() throws RemoveException,RemoteException {
}
public String getMessage() throws RemoteException {
return "Nishant";
}
public void setSessionContext(SessionContext ctx) throws RemoteException {
this.ctx = ctx;
}
}
</pre>

Other things looks alright for the components you pasted.Just confirm that the client does a lookup at the right URL that has been published while deployment.
Hope this helps,
Sandeep
[This message has been edited by Desai Sandeep (edited June 27, 2001).][/B]



i did what you said but still same problem i will be highly thankful if you go what i did stap by step as now i am completely frustrated.
i will tell what i did step by step
my package structure is venus\scc\ejb\stateless\session\bean\nishant.
i put this venus folder in c:>WS>serverclasses(i have made serverclasses directory at insatallation directory of WS).
1)then i complie these files
2)then i run following commang from command prompt from c:>WS>serverclass directory
command is "jar cfv nishantnojar.jar venus/scc/ejb/stateless/session/bean/nishant/*.class"
then a jar file nishantnojar.ajr is created at c:>WS>serverclass directory
contents of this jar file are
META-INF/
META-INF/MANIFEST.MF
venus/scc/ejb/stateless/session/bean/nishant/Nishant.class
venus/scc/ejb/stateless/session/bean/nishant/NishantBean.class
venus/scc/ejb/stateless/session/bean/nishant/NishantHome.class
then i open the jetace tool and set name of bean="NishantBean"
and jndi name=NishantBean
BeanClass= venus.scc.ejb.stateless.session.bean.nishant.NishantBean.class
HomeClass=venus.scc.ejb.stateless.session.bean.nishant.NishantHome.class
RemoteClass=venus.scc.ejb.stateless.session.bean.nishant.Nishant.class
then i save this file as nishant_temp in deployableEJBs directory then from admistrator console i deploy and run this bean.
after this copy the deployed bean jar file to another folder where i have client it is at c:>WS>clientclasses
add this jar file in classpath and run the client and same classcast exception.
please help me.
if possible please give me one simplest ejb with all classes and cleint class and step by step procedure about what to do.
i will wait for your reply
Take care
bye
Nishant
 
Eliminate 95% of the weeds in your lawn by mowing 3 inches or higher. Then plant tiny ads:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic