Wrox Home  
Search P2P Archive for: Go

  Return to Index  

enterprise_java_beans thread: Encounter TransactionRolledbackLocalException


Message #1 by "sachin_sisodia" <sachi_sisodia@r...> on Mon, 10 Mar 2003 07:39:49
Hi mamata,
thanx to reply me.
As u mentioned in ur reply that i have to used ejb query language,bt i m 
wondering, is there any need to write it in my DD. coz there r nt any 
finder method in my code except default findByPrimaryKey.

i didn't use any more, if there is any need of it could u mail me how i 
have to write in DD.

thanx in advance
cheers
sachin


> Hi Sachin,
          i went through your code and there apparently seems to be 
nothing wrong with it. However, since you are going to deploy a cmp 
entity bean, you must have used the EJB Query language in the deployment 
descriptor. Are u sure that when you are going to create a user through 
the bean, there's nothing wrong with the query. Can u send me a copy of 
that descriptor?

Thanks,
Regards,
Mamata.

-----Original Message-----
From: "sachin_sisodia"<sachi_sisodia@r...>
To: "Enterprise Java Beans"<enterprise_java_beans@p...>
Date: Mon Mar 10 21:09:46 PST 2003
Subject: [enterprise_java_beans] Re: Encounter 
TransactionRolledbackLocalException

>Hello guys
>thanx to reply me. i m trying to slove it for last 1 week bt yet i 
>couldn't get any satisfactory ans. 
>
>i wanna to try a simple local interface 
>it is my java code:
>
>// LocalUser3.java
>package user;
>public interface LocalUser3 extends javax.ejb.EJBLocalObject {
> 
>public String getEmail();
>public String getPassword();
>public  void setEmail(String email);
>public  void setPassword(String email); 
>   
>}
>                 
>//LocalUser3Home.java
>package user;
> 
>import javax.ejb.CreateException;
>import javax.ejb.FinderException;
> 
>import java.util.Collection;
> 
>public interface LocalUser3Home extends javax.ejb.EJBLocalHome {
> 
>    public LocalUser3 create( String email, String password
>                        )
>                                    throws CreateException;
>   
>}
>//User3EJB.java
>package user;
>
>import java.util.ArrayList;
>import java.util.Collection;
>import java.util.Iterator;
>import javax.ejb.CreateException;
>import javax.ejb.EntityBean;
>import javax.ejb.EntityContext;
>import javax.naming.Context;
>import javax.naming.InitialContext;
>
>public abstract class User3EJB implements EntityBean {
> 
>    public  abstract String getEmail();
>    public abstract String getPassword();   
>	public  abstract void setEmail( String email);
>    public abstract void setPassword(String password);    
>    
>	
>	public String ejbCreate (
>            String email,
>            String password) 
>        throws CreateException {
>		setEmail(email);
>        setPassword(password);
>		return null;
>            }
>
>     public void ejbPostCreate (
>            String email,
>            String password)
>        throws CreateException { }
>
>    private EntityContext ctx;
>	public void setEntityContext(EntityContext ctx) { 
>                                              	   this.ctx = ctx;  
>	   								
>			    }  
>	 public void unsetEntityContext() {
>	     							
>	this.ctx = null;
>		 						
>	  }	
>    
>    public void ejbRemove() { }    
>    public void ejbLoad() { }    
>    public void ejbStore() { }    
>   public void ejbPassivate(){ 
>    setEmail(null);
>    setPassword(null);
>   }  
>	
>public void ejbActivate() { }
>
>    
>}
>
>// session bean
>//UserManagementHome 
>
>package user;
>
>import javax.ejb.*;
>import java.rmi.*;      
>             
>public interface UserManagementHome extends javax.ejb.EJBHome {
>      UserManagement create()  throws java.rmi.RemoteException, 
>javax.ejb.CreateException;                   
>                        
>   }            
>package user;
>
>//UserManagement.java 
>
>import javax.ejb.*;
> import java.rmi.*;                  
>public interface UserManagement extends javax.ejb.EJBObject {
>                        
>    public void addUser(String email, String password) throws 
>RemoteException;
>    }    
>
>         
>//UserManagementEJB .java
>package user;
>
>import java.util.ArrayList;
>import java.util.Collection;
>import java.util.Iterator;
>import javax.ejb.CreateException;
>
>import javax.naming.Context;
>import javax.naming.InitialContext;
>
>import javax.ejb.*;
>import javax.naming.*;
>import java.rmi.*;
>import javax.rmi.*;
>
>import javax.ejb.SessionBean;
>import javax.ejb.SessionContext;
>import javax.ejb.*;
> import java.rmi.*;  
> import javax.naming.*;
>import java.util.*;
> 
> 
>public class UserManagementEJB implements SessionBean {
>                        
>    public void addUser(String email, String password){
>        try {
>            InitialContext ctx= null;
>			 ctx =new InitialContext();
>			
>		
>			LocalUser3Home user = (LocalUser3Home)  ctx.lookup
>( "local/User" );
>									
>			LocalUser3 user1 = user.create(email, password);
>						
>                 } catch (CreateException e) {
>            throw new EJBException();
>                          } 
>		catch (Exception ex) {
>            ex.printStackTrace();
>        }
>		
>                            
>    }
>         
>    	
>	
>	public void setSessionContext( javax.ejb.SessionContext 
>ejbSessionContext )
>		throws RemoteException
>	{
>        }
>
>	public void unsetSessionContext()
>		throws RemoteException
>	{
>	}
>
>	public void ejbRemove()
>		throws java.rmi.RemoteException, javax.ejb.EJBException
>	{
>		}
>
>	public void ejbActivate()
>		throws java.rmi.RemoteException
>	{
>		}
>
>	public void ejbPassivate()
>		throws java.rmi.RemoteException
>	{
>		}
>
>	public void ejbCreate() throws java.rmi.RemoteException {}
>	
>	
>         
>}
>
>
>Now i m trying to invoke this session bean from my client program that 
>further communicate with local entity bean.Both session and entity bean 
>in one jar.
>
>Bt doing so i encounter a tranctionrollback exception which i mentioned 
>earlier
>
>plz help me how to slove it ,i m wrong somewhere, or i miss something 
>
>thanx in advance
>
>cheers 
>sachin
>
>
>
>
>
>
>
>
>---
>Change your mail options at http://p2p.wrox.com/manager.asp or 
>to unsubscribe send a blank email to 


___________________________________________________
GO.com Mail                                    
Get Your Free, Private E-mail at http://mail.go.com



  Return to Index