• Post Reply Bookmark Topic Watch Topic
  • New Topic

What might be the problem??  RSS feed

 
pardha saradhi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I wrote a small program with state less session bean. I am using J2EE. It is working fine. Now I converted that to state full session bean through deployment tool and redployed the bean nut am getting the following error
server side this is firing
setSessionContext() Fired...
Client side I got this error
javax.ejb.CreateException: ERROR creating stateful SessionBean: java.lang.ClassCastException: BookBean_EJBObjectImpl
<<no stack trace available>>
Please help me in finding the sol.
Thanking you in advance
Saradhi
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please don't post the same question multiple times!!! You posted an identical question on thread.
Kyle
 
pardha saradhi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok I won't
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I deleted the other one.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok so when are you getting the error? What command are you attempting to execute? What app server are you using?
 
pardha saradhi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi thank you.
Ya I am using J2EE server. First I created a stateless session bean. It is working fine. Now I I converted the same program in to statefull session bean using Deploy tool and redeployed then I got this problem?
Just I changed from stateless to statefull thats all I din't touch the code
now I am getting error in create method of bean.
am I missing any thing here?
I am getting this error in beans create method.
 
Steve Chernyak
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's see the code.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Saradhi,
For some reason I doubt that your last name is Java. javaranch has a naming standard that requires you to use your real first name - space - your real last name. Failure to use a real name will prevent you from being eligible for the book of the week. Please change your display name to match our requirements. Thanks.
 
pardha saradhi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok I changed
thank you for information
Saradhi
 
pardha saradhi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Still getting that error.
Hi I am pasting my code here please go thru..
***************BookBean******************
import javax.ejb.*;
import java.rmi.*;
import java.io.*;
import java.util.*;
public class BookBean implements SessionBean
{
SessionContext ctx;
Vector v = new Vector();
public void setSessionContext(SessionContext
ctx)
{
this.ctx = ctx;
System.out.println("setSessionContext()
Fired");
}
public void ejbCreate()throws CreateException
{
System.out.println("ejbCreate() Fired");
}
public void ejbActivate()
{
System.out.println("ejbActivate() Fired");
}
public void ejbPassivate()
{
System.out.println("ejbPassivate() Fired");
}
public void ejbRemove()
{
System.out.println("ejbRemove() Fired");
}
public void addBook(String str)throws
RemoteException
{
v.add(str);
}
public Vector getContents()throws
RemoteException
{
return v;
}
}
**********Book Home*******************
import javax.ejb.*;
import java.rmi.*;
public interface BookHome extends EJBHome
{
public Book create()throws CreateException,RemoteException;
}
***************Book*****************************
//package ejb.stateless;
import javax.ejb.*;
import java.rmi.*;
import java.util.*;
public interface Book extends EJBObject
{
public void addBook(String str)throws RemoteException;
public Vector getContents()throws RemoteException;
}
************Book Client******************
import javax.ejb.*;
import javax.naming.*;
import javax.rmi.*;
import java.util.Properties;
import java.util.*;
public class BookClient
{
Book remote;
BookHome home;
Vector bookList;
public void callEJB()
{
try
{
Properties props=System.getProperties();
Context ctx=new InitialContext(props);
home = (BookHome) ctx.lookup("BookHome");
System.out.println("Step 1");
remote = home.create();
System.out.println("Step 2");
remote.addBook("VB");
remote.addBook("ASP");
remote.addBook("EJB");
remote.addBook("Java");
remote.addBook("Oracle");
bookList = remote.getContents();
Enumeration e = bookList.elements();
while(e.hasMoreElements())
{
System.out.println(e.nextElement());
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args)
{
BookClient client = new BookClient();
client.callEJB();
}
}
********************************************
It is my statefull session bean
I am getting the following error
javax.ejb.CreateException: ERROR creating stateful SessionBean: java.lang.ClassCastException: BookBean_EJBObjectImpl
<<no stack trace available>>
Thanking you in advance
 
pardha saradhi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi please help me in solving this error. I got stuckup here. I am trying in all possible ways but could not solve my problem.
Please go thru the above code and error and let me know what might be the problem
Thanking you in advance
Saradhi
 
Manoranjan Mishra
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please describe the error message in detail.. Or try doing the deployment once again..(it may work)
 
Matjaz Juric
Author
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Saradhi,
Be sure to use the new stub on the client side (in the client library) for the stateful session bean. And be sure to deploy the bean correctly.
Cheers,
Matjaz
 
pardha saradhi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Juric thank you
My problem got solved. I included try catch blocks in my bean and redployed again. It is working fine
what do u mean by new stub on the client side?
How to create that.
Thanking you in advance
Saradhi
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!