• Post Reply Bookmark Topic Watch Topic
  • New Topic

ejb error  RSS feed

 
Yu Tao
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello everyone

I declare stateful session bean

StoreAccessStateBean:

public void ejbCreate (String userID) throws CreateException{
System.out.println("Entering StoreAccessStateBean.ejbCreate()");
this.userID = userID;
System.out.println("Leaving StoreAccessStateBean.ejbCreate()");
}

LocalHome and Home also have create() method;

but when I deploy ejb have some error
02:34:05,453 WARN [verifier] EJB spec violation:
Bean : StoreAccessState
Method : public abstract StoreAccessStateLocal create() throws CreateException
Section: 7.10.8
Warning: Each create(...) method in the session bean's local home interface must
have a matching ejbCreate(...) method in the session bean's class.

02:34:05,453 ERROR [MainDeployer] could not create deployment: file:/C:/jboss-3.
2.6/jboss-3.2.6/server/default/deploy/MyStoreMgrful.jar
org.jboss.deployment.DeploymentException: Verification of Enterprise Beans faile
d, see above for error messages.

Please tell me how to alter my ejb ??

thanks
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like you either 1) don't have any ejbPostCreate methods, or 2) the parameters for ejbCreate and ejbPostCreate don't match. Make sure you read those error messages!
 
Yu Tao
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is my Bean
public abstract class StoreAccessStateBean implements SessionBean {

/**
* @ejb.interface-method
*view-type="remote"
* @dao.call name=loginUser
**/
private String userID;
protected SessionContext ctx;

public String loginUser (String username, String password){
System.out.println("Entering StoreAccessStateBean.loginUser()");
System.out.println("Leaving StoreAccessStateBean.loginUser()");
return null;
}
/**
* @ejb.interface-method
*view-type="remote"
**/
public void setUserID(String userID){
this.userID = userID;
}
/**
* @ejb.interface-method
*view-type="remote"
**/
public String getUserID(){
return userID;
}
/**
* @ejb.create-method
*view-type="remote"
**/
public void ejbCreate (String userID) throws CreateException{
System.out.println("Entering StoreAccessStateBean.ejbCreate()");
this.userID = userID;
System.out.println("Leaving StoreAccessStateBean.ejbCreate()");
}

public void setSessionContext(SessionContext ctx){
this.ctx = ctx;
}
public void unsetSessionContext(){
this.ctx = null;
}
public void ejbRemove(){
}
public void ejbActivate(){
}
public void ejbPassivate(){
}
}
this declare my bean is right???
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37469
539
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yu,
You need to write an empty ejbPostCreate method with the same signature as your ejbCreate method. The EJB spec requires it. This was Nathaniel's first guess as to what was wrong.
 
Yu Tao
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks erveryone .
That error is OK.
because of my ejbCreate(String userID) but in my localhome is Create();

This is new error.
Test Client:
public void testBean() {
String userID = null;

try {
au.com.tusc.sessionState.StoreAccessState myBean =
getHome().create(userID);
System.out.println("Request from client : ");
userID = myBean.loginUser("ANDY","PASSWD");
System.out.println("Reply from Server: Your userid is " + userID);
myBean.setUserID(userID);
System.out.println("Going to Sleep for 1 min ......................... " );
Thread.sleep(500); // sleep for 1 minute.
System.out.println("Reply from bean after 1min " + myBean.getUserID());
System.out.println("Again going to Sleep for 3 min ......................... " );
Thread.sleep(1000); // sleep for 3 minute.
System.out.println("Resuming after 3 mins ......................... " );
System.out.println("Reply from bean after 2mins " + myBean.getUserID());

//--------------------------------------
//This is the place you make your calls.
//System.out.println(myBean.callYourMethod());

} catch (RemoteException e) {
e.printStackTrace();
} catch (CreateException e) {
e.printStackTrace();
} catch (NamingException e) {
e.printStackTrace();
} catch(InterruptedException e){
}
}
after runing :
Request from client :
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.ServerException: RuntimeException; nested exception is:
java.lang.ClassCastException
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:292)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:534)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:135)
at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:96)
at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:55)
at org.jboss.proxy.ejb.StatefulSessionInterceptor.invoke(StatefulSessionInterceptor.java:105)
at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
at $Proxy1.loginUser(Unknown Source)
at au.com.tusc.client.SessionStateClient.testBean(SessionStateClient.java:52)
at au.com.tusc.client.SessionStateClient.main(SessionStateClient.java:79)
Caused by: java.rmi.ServerException: RuntimeException; nested exception is:
java.lang.ClassCastException
at org.jboss.ejb.plugins.LogInterceptor.handleException(LogInterceptor.java:385)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:195)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
at org.jboss.ejb.StatefulSessionContainer.internalInvoke(StatefulSessionContainer.java:449)
at org.jboss.ejb.Container.invoke(Container.java:709)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:62)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:54)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:82)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:197)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:360)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:534)
Caused by: java.lang.ClassCastException
at au.com.tusc.sessionState.StoreAccessStateSession.getDao(StoreAccessStateSession.java:44)
at au.com.tusc.sessionState.StoreAccessStateSession.loginUser(StoreAccessStateSession.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.ejb.StatefulSessionContainer$ContainerInterceptor.invoke(StatefulSessionContainer.java:982)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:111)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
at org.jboss.ejb.plugins.StatefulSessionInstanceInterceptor.invoke(StatefulSessionInstanceInterceptor.java:273)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:315)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:148)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
... 25 more

where is wrong???
 
Yu Tao
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
14:18:11,140 INFO [EjbModule] Deploying StoreAccessState
14:18:11,312 INFO [EJBDeployer] Deployed: file:/C:/jboss-3.2.6/jboss-3.2.6/serv
er/default/deploy/MyStoreMgrful.jar
14:23:01,921 INFO [STDOUT] Entering StoreAccessStateBean.ejbCreate()
14:23:01,921 INFO [STDOUT] Leaving StoreAccessStateBean.ejbCreate()
14:23:02,046 INFO [STDOUT] Entering StoreAccessStateBean.loginUser()
14:23:02,046 INFO [STDOUT] Leaving StoreAccessStateBean.loginUser()
14:23:02,046 ERROR [LogInterceptor] RuntimeException in method: public abstract
java.lang.String au.com.tusc.sessionState.StoreAccessState.loginUser(java.lang.S
tring,java.lang.String) throws java.rmi.RemoteException
java.lang.ClassCastException

StoreAccessState Code:
public interface StoreAccessState
extends javax.ejb.EJBObject
{

public void setUserID( java.lang.String userID )
throws java.rmi.RemoteException;

public java.lang.String getUserID( )
throws java.rmi.RemoteException;

public String loginUser(String username, String password) throws java.rmi.RemoteException;

}
 
Christian Hutter
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yu Tao, did you manage to solve your prob? Im also stuck at the same problem and cant find a solution. Addind the ejbPostCreate method in the StoreAccessStateBean didnt help me
 
Saso Jordanoski
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One of the reasons for the class cast exception is having deployed another ejb with the same name.
 
Arthur Costa
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had the same problem you had, using the same example.

I solved including this line at the StoreAccessDAOImpl class file.

public class StoreAccessDAOImpl implements StoreAccessDAO ...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!