MyEclipse Forums
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
dpowers@bigskyhsd.com
Post subject: client app calls session bean (adduser) call creat entity  PostPosted: Oct 14, 2004 - 01:09 AM
Veteran Member
Veteran Member


Joined: Jul 09, 2004
Posts: 12

Hi:
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 more
 
 View user's profile Send private message  
Reply with quote Back to top
support-rkalla
Post subject:   PostPosted: Oct 14, 2004 - 05:55 PM
Registered Member
Registered Member


Joined: Jan 06, 2004
Posts: 23824

Moving to Software Dev for community involvement.

_________________
Riyad
MyEclipse Support
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
nabil
Post subject:   PostPosted: Oct 15, 2004 - 10:01 AM
Quality Board
Quality Board


Joined: Feb 01, 2004
Posts: 303

Hi 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
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
nabil
Post subject:   PostPosted: Oct 15, 2004 - 10:04 AM
Quality Board
Quality Board


Joined: Feb 01, 2004
Posts: 303

can't edit my own post ? can some mod fix my second url for me please ? :)
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
dpowers@bigskyhsd.com
Post subject:   PostPosted: Oct 15, 2004 - 07:14 PM
Veteran Member
Veteran Member


Joined: Jul 09, 2004
Posts: 12

My UserManager is a session bean managing the entity bean UserBean.
Thanks.
 
 View user's profile Send private message  
Reply with quote Back to top
nabil
Post subject:   PostPosted: Oct 15, 2004 - 11:06 PM
Quality Board
Quality Board


Joined: Feb 01, 2004
Posts: 303

yes, I suggest using a regular java class that talks to the Entity bean, your session bean talks to that regular java class.
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits