- This topic has 5 replies, 3 voices, and was last updated 9 years, 2 months ago by
Nabil Suleiman.
-
AuthorPosts
-
Diane PowersMemberHi:
I am executing a client application (separate jvm) which calls a session bean remotely (adduser). The session bean adduser then calls entity bean.The client blows up and produces the error at the bottom when I call adduser. I have stepped through the debugger. I see my values passed in. I am in the server side stubs _UserNabagenebtBeanStub_ . I am thinking my adduser isn’t exposed there. I will decompile the .class files.
Any help would be greatly appreciated!
My client code is as follows:
public static void main(String[] args)
{try {
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,”com.sun.jndi.cosnaming.CNCtxFactory”);
env.put(Context.PROVIDER_URL,”iiop://127.0.0.1:3700″);Context initial = new InitialContext(env);
Object ref = initial.lookup(UserManagementBeanHome.JNDI_NAME);
System.out.println(“class type ” + ref.getClass().getName());
UserManagementBeanHome home =
(UserManagementBeanHome)PortableRemoteObject.narrow(ref,
UserManagementBeanHome.class);UserManagementBean userMgmt = home.create();
–> userMgmt.addUser(“dpowers@nowheres.com”, “xxxxxx”);
userMgmt.addUser(“dpowers@anywheres.com”, “xxxxxx”);
…My session bean uses the following ejbdoclet tags.
* @ejb.bean name = “UserManagementBean”
* type = “Stateless”
* display-name = “UserManagementBean”
* description = “UserManagementBean EJB”
* view-type = “both”
* jndi-name = “ejb/UserManagementBeanHome”
*
*The followin tags adds ejb-ref tags into sun-ejb-jar.xml file and
*adds ejb-local-ref tags into ejb.jar.xml file.
*
* @ejb.ejb-ref ejb-name = “UserBean”
* view-type = “local”
* ref-name = “UserBeanLocalHome”
*//**
*
* @ejb.interface-method view-type = “remote”
*
* @ejb.transaction
* type = “Required”
*
*
* @throws EJBException Thrown if the instance could not perform
* the function requested by the container because of an system-level error.
*/
public void addUser(java.lang.String email, java.lang.String password)
{
try {
System.out.println(“addUser I am here!”);
UserBeanLocal user = userBeanLocalHome.create(email, password);
} catch (CreateException e)
{
throw new EJBException
(“Unable to create the local user ” + email, e);
}}
Entity bean
* @ejb.bean name = “UserBean”
* type = “CMP”
* cmp-version = “2.x”
* display-name = “UserBean”
* description = “UserBean EJB”
* view-type = “local”
* jndi-name = “ejb/UserBeanHome”
* local-jndi-name = “ejb/UserBeanLocalHome”
* primkey-field = “emailId”
*
* @ejb.pk
* class = “java.lang.String”
*
* @ejb.persistence
* read-only = “true”
* table-name = “USERTAB”
*
* @sunone.persistence-manager
* table-name = “USERTAB”
*
* @ejb:util
* generate=”physical”
*/
public abstract class UserBean implements EntityBean
.
.
.
/**
* @throws CreateException Thrown if the instance could not perform
* the function requested by the container because of an system-level error.
*
* @ejb.create-method
*/
public String ejbCreate(java.lang.String emailId, java.lang.String password) throws CreateException
{
setEmailId(emailId);
setPassword(password);
return null;
}/**
* @ejb.pk-field
*
* @ejb.interface-method
* view-type=”local”
*
* @ejb.persistence
* read-only = “true”
* column-name = “EMAILID”
*
* @ejb.transaction
* type = “Required”
*
*/public abstract String getEmailId();
/**
* @ejb.interface-method
* view-type =”local”
* @ejb.persistence
* column-name =”EMAILID”
* @ejb.transaction
* type = “Required”
*/
public abstract void setEmailId(java.lang.String emailId);/**
* @ejb.interface-method
* view-type=”local”
*
* @ejb.persistence
* read-only = “true”
* column-name = “PASSWORD”
*
* @ejb.transaction
* type = “Required”
*
*/
public abstract String getPassword();/**
* @ejb.interface-method
* view-type =”local”
* @ejb.persistence
* column-name =”PASSWORD”
* @ejb.transaction
* type = “Required”
*/
public abstract void setPassword(java.lang.String password);error produced by the client when it executes adduser.
class type com.mcsi3.synesis7.auth.interfaces._UserManagementBeanHome_Stub
MESSAGE:RemoteException occurred in server thread; nested exception is:
java.rmi.RemoteException: nested exception is: javax.ejb.EJBException: nested exception is: javax.ejb.CreateException: Could not create stateless EJB: java.lang.reflect.InvocationTargetException; nested exception is:
javax.ejb.EJBException: nested exception is: javax.ejb.CreateException: Could not create stateless EJB: java.lang.reflect.InvocationTargetException
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.RemoteException: nested exception is: javax.ejb.EJBException: nested exception is: javax.ejb.CreateException: Could not create stateless EJB: java.lang.reflect.InvocationTargetException; nested exception is:
javax.ejb.EJBException: nested exception is: javax.ejb.CreateException: Could not create stateless EJB: java.lang.reflect.InvocationTargetException
at com.sun.corba.se.internal.iiop.ShutdownUtilDelegate.mapSystemException(ShutdownUtilDelegate.java:64)
at javax.rmi.CORBA.Util.mapSystemException(Util.java:65)
at com.mcsi3.synesis7.auth.interfaces._UserManagementBean_Stub.addUser(Unknown Source)
at com.mcsi3.synesis7.auth.client.Section2Client.main(Section2Client.java:44)
Caused by: java.rmi.RemoteException: nested exception is: javax.ejb.EJBException: nested exception is: javax.ejb.CreateException: Could not create stateless EJB: java.lang.reflect.InvocationTargetException; nested exception is:
javax.ejb.EJBException: nested exception is: javax.ejb.CreateException: Could not create stateless EJB: java.lang.reflect.InvocationTargetException
at com.sun.enterprise.iiop.POAProtocolMgr.mapException(POAProtocolMgr.java:213)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:797)
at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:137)
at $Proxy47.addUser(Unknown Source)
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 com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:117)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:651)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:190)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1653)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1513)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:895)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:172)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:668)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.dispatch(SocketOrChannelConnectionImpl.java:375)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.read(SocketOrChannelConnectionImpl.java:284)
at com.sun.corba.ee.impl.transport.ReaderThreadImpl.doWork(ReaderThreadImpl.java:73)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:382)
Caused by: javax.ejb.EJBException: nested exception is: javax.ejb.CreateException: Could not create stateless EJB: java.lang.reflect.InvocationTargetException
at com.sun.ejb.containers.StatelessSessionContainer$SessionContextFactory.create(StatelessSessionContainer.java:599)
at com.sun.ejb.containers.util.pool.NonBlockingPool.getObject(NonBlockingPool.java:168)
at com.sun.ejb.containers.StatelessSessionContainer._getContext(StatelessSessionContainer.java:359)
at com.sun.ejb.containers.BaseContainer.getContext(BaseContainer.java:993)
at com.sun.ejb.containers.BaseContainer.preInvoke(BaseContainer.java:716)
at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:126)
… 17 moreOctober 14, 2004 at 11:55 am #217652
Riyad KallaMemberMoving to Software Dev for community involvement.
October 15, 2004 at 4:01 am #217728
Nabil SuleimanParticipantHi there,
Use session facade pattern (look here and here)
the bottom line, instead of getting your session beans calling entity beans directly, create a “Manager” class. that class calls exposes the entities that “Manager” deals with to your sessions (each manager can manage a number of related beans) leaving your session beans code clean and simple and makes your systemmore flexable.
p.s. remember this “A level of Indirection solves every problem in computer science” – someone
October 15, 2004 at 4:04 am #217729
Nabil SuleimanParticipantcan’t edit my own post ? can some mod fix my second url for me please ? 🙂
October 15, 2004 at 1:14 pm #217766
Diane PowersMemberMy UserManager is a session bean managing the entity bean UserBean.
Thanks.October 15, 2004 at 5:06 pm #217798
Nabil SuleimanParticipantyes, I suggest using a regular java class that talks to the Entity bean, your session bean talks to that regular java class.
-
AuthorPosts