I'm writing an entity bean and I'm having problems compiling when I add a method to the remote interface and have a matching method in the bean class. I'm not sure what I'm doing wrong!
The following code compiles and works fine:
*************************************
1. HOME:
package headfirst;
import javax.ejb.*;
import java.rmi.RemoteException;
public interface MovieHome extends EJBHome
{
public Movie create(String aGenre,int aYear,String aTitle) throws CreateException, RemoteException;
public Movie findByPrimaryKey(String primarykey) throws FinderException, RemoteException;
}
*********************************
2. REMOTE INTERFACE:
package headfirst;
import java.rmi.RemoteException;
import javax.ejb.*;
public interface Movie extends EJBObject
{
}
*************************************
3. BEAN:
package headfirst;
import java.io.Serializable;
import java.rmi.RemoteException;
import java.rmi.Remote;
import javax.ejb.*;
import java.util.*;
import headfirst.RandomString;
public abstract class MovieBean implements EntityBean
{
private EntityContext ctx;
public String ejbCreate(String aGenre,int aYear,String aTitle) throws RemoteException, CreateException
{
String key = RandomString.randomString();
setMovieID(key);
setGenre(aGenre);
setYear(aYear);
setTitle(aTitle);
return null;
}
public void ejbPostCreate(String aGenre,int aYear,String aTitle)
{
System.out.println("ejbPostCreate()");
}
public void ejbActivate() throws RemoteException
{
System.out.println("ejbActivate()");
}
public void ejbLoad() throws RemoteException
{
System.out.println("ejbLoad()");
}
public void ejbPassivate() throws RemoteException
{
System.out.println("ejbPassivate()");
}
public void ejbRemove() throws RemoteException, RemoveException
{
System.out.println("ejbRemove()");
}
public void ejbStore() throws RemoteException
{
System.out.println("ejbStore()");
}
public void setEntityContext(EntityContext context) throws RemoteException {
this.ctx = context;
}
public void unsetEntityContext() throws RemoteException
{
this.ctx = null;
}
/*public void setMovietitle(String aTitle) throws RemoteException
{
setTitle(aTitle);
}*/
public String getMovietitle(){ return getTitle(); }
public abstract void setMovieID(String aString);
public abstract String getMovieID();
public abstract void setGenre(String aString);
public abstract String getGenre();
public abstract void setYear(int anInt);
public abstract int getYear();
public abstract void setTitle(String aString);
public abstract String getTitle();
}
*********************************
The code above compiles and works fine. Now if I add a method to the remote interface and bean class I can't compile the code. I'll show you below.
*************************************
A. Modified REMOTE INTERFACE:
package headfirst;
import java.rmi.RemoteException;
import javax.ejb.*;
public interface Movie extends EJBObject
{
public void doSomething() throws RemoteException;
}
****************************************************
B. BEAN class with method matching the remote interface:
package headfirst;
import java.io.Serializable;
import java.rmi.RemoteException;
import java.rmi.Remote;
import javax.ejb.*;
import java.util.*;
import headfirst.RandomString;
public abstract class MovieBean implements EntityBean
{
private EntityContext ctx;
public String ejbCreate(String aGenre,int aYear,String aTitle) throws RemoteException, CreateException
{
String key = RandomString.randomString();
setMovieID(key);
setGenre(aGenre);
setYear(aYear);
setTitle(aTitle);
return null;
}
public void ejbPostCreate(String aGenre,int aYear,String aTitle)
{
System.out.println("ejbPostCreate()");
}
public void ejbActivate() throws RemoteException
{
System.out.println("ejbActivate()");
}
public void ejbLoad() throws RemoteException
{
System.out.println("ejbLoad()");
}
public void ejbPassivate() throws RemoteException
{
System.out.println("ejbPassivate()");
}
public void ejbRemove() throws RemoteException, RemoveException
{
System.out.println("ejbRemove()");
}
public void ejbStore() throws RemoteException
{
System.out.println("ejbStore()");
}
public void setEntityContext(EntityContext context) throws RemoteException {
this.ctx = context;
}
public void unsetEntityContext() throws RemoteException
{
this.ctx = null;
}
/*public void setMovietitle(String aTitle) throws RemoteException
{
setTitle(aTitle);
}*/
public String getMovietitle(){ return getTitle(); }
public abstract void setMovieID(String aString);
public abstract String getMovieID();
public abstract void setGenre(String aString);
public abstract String getGenre();
public abstract void setYear(int anInt);
public abstract int getYear();
public abstract void setTitle(String aString);
public abstract String getTitle();
public void doSomething() throws RemoteException
{
System.out.println("DID SOMETHING!");
}
}
***********************
The modified code will not compile... what am I doing wrong!??
The following code compiles and works fine:
*************************************
1. HOME:
package headfirst;
import javax.ejb.*;
import java.rmi.RemoteException;
public interface MovieHome extends EJBHome
{
public Movie create(String aGenre,int aYear,String aTitle) throws CreateException, RemoteException;
public Movie findByPrimaryKey(String primarykey) throws FinderException, RemoteException;
}
*********************************
2. REMOTE INTERFACE:
package headfirst;
import java.rmi.RemoteException;
import javax.ejb.*;
public interface Movie extends EJBObject
{
}
*************************************
3. BEAN:
package headfirst;
import java.io.Serializable;
import java.rmi.RemoteException;
import java.rmi.Remote;
import javax.ejb.*;
import java.util.*;
import headfirst.RandomString;
public abstract class MovieBean implements EntityBean
{
private EntityContext ctx;
public String ejbCreate(String aGenre,int aYear,String aTitle) throws RemoteException, CreateException
{
String key = RandomString.randomString();
setMovieID(key);
setGenre(aGenre);
setYear(aYear);
setTitle(aTitle);
return null;
}
public void ejbPostCreate(String aGenre,int aYear,String aTitle)
{
System.out.println("ejbPostCreate()");
}
public void ejbActivate() throws RemoteException
{
System.out.println("ejbActivate()");
}
public void ejbLoad() throws RemoteException
{
System.out.println("ejbLoad()");
}
public void ejbPassivate() throws RemoteException
{
System.out.println("ejbPassivate()");
}
public void ejbRemove() throws RemoteException, RemoveException
{
System.out.println("ejbRemove()");
}
public void ejbStore() throws RemoteException
{
System.out.println("ejbStore()");
}
public void setEntityContext(EntityContext context) throws RemoteException {
this.ctx = context;
}
public void unsetEntityContext() throws RemoteException
{
this.ctx = null;
}
/*public void setMovietitle(String aTitle) throws RemoteException
{
setTitle(aTitle);
}*/
public String getMovietitle(){ return getTitle(); }
public abstract void setMovieID(String aString);
public abstract String getMovieID();
public abstract void setGenre(String aString);
public abstract String getGenre();
public abstract void setYear(int anInt);
public abstract int getYear();
public abstract void setTitle(String aString);
public abstract String getTitle();
}
*********************************
The code above compiles and works fine. Now if I add a method to the remote interface and bean class I can't compile the code. I'll show you below.
*************************************
A. Modified REMOTE INTERFACE:
package headfirst;
import java.rmi.RemoteException;
import javax.ejb.*;
public interface Movie extends EJBObject
{
public void doSomething() throws RemoteException;
}
****************************************************
B. BEAN class with method matching the remote interface:
package headfirst;
import java.io.Serializable;
import java.rmi.RemoteException;
import java.rmi.Remote;
import javax.ejb.*;
import java.util.*;
import headfirst.RandomString;
public abstract class MovieBean implements EntityBean
{
private EntityContext ctx;
public String ejbCreate(String aGenre,int aYear,String aTitle) throws RemoteException, CreateException
{
String key = RandomString.randomString();
setMovieID(key);
setGenre(aGenre);
setYear(aYear);
setTitle(aTitle);
return null;
}
public void ejbPostCreate(String aGenre,int aYear,String aTitle)
{
System.out.println("ejbPostCreate()");
}
public void ejbActivate() throws RemoteException
{
System.out.println("ejbActivate()");
}
public void ejbLoad() throws RemoteException
{
System.out.println("ejbLoad()");
}
public void ejbPassivate() throws RemoteException
{
System.out.println("ejbPassivate()");
}
public void ejbRemove() throws RemoteException, RemoveException
{
System.out.println("ejbRemove()");
}
public void ejbStore() throws RemoteException
{
System.out.println("ejbStore()");
}
public void setEntityContext(EntityContext context) throws RemoteException {
this.ctx = context;
}
public void unsetEntityContext() throws RemoteException
{
this.ctx = null;
}
/*public void setMovietitle(String aTitle) throws RemoteException
{
setTitle(aTitle);
}*/
public String getMovietitle(){ return getTitle(); }
public abstract void setMovieID(String aString);
public abstract String getMovieID();
public abstract void setGenre(String aString);
public abstract String getGenre();
public abstract void setYear(int anInt);
public abstract int getYear();
public abstract void setTitle(String aString);
public abstract String getTitle();
public void doSomething() throws RemoteException
{
System.out.println("DID SOMETHING!");
}
}
***********************
The modified code will not compile... what am I doing wrong!??