Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with entity beans remote interface and bean class

Status
Not open for further replies.

ennsak

Programmer
Aug 11, 2004
5
CA
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!??
 
I'm not sure what you mean by code tags!?

The compiler error is:

"MovieBean_lrp1q8_EOImpl.java": cannot resolve symbol: variable md_eo_doSomething in class headfirst.MovieBean_lrp1q8_HomeImpl at line 26, column 47
"MovieBean_lrp1q8_EOImpl.java": cannot resolve symbol: method doSomething ()in interface headfirst.MovieBean_lrp1q8_Intf at line 45, column 14
"MovieBean_lrp1q8_EOImpl.java": cannot resolve symbol: variable md_eo_doSomething in class headfirst.MovieBean_lrp1q8_HomeImpl at line 26, column 47
"MovieBean_lrp1q8_EOImpl.java": cannot resolve symbol: method doSomething ()in interface headfirst.MovieBean_lrp1q8_Intf at line 45, column 14
 
looks like the automatically generated ejb files have not been refreshed. are you using eclipse/wsad? if so, regenerate the ejb classes (try deleting the previous copies first - just the ones that were automatically generated - not the actual bean and interface you coded) and redeploy.
 
I'm using JBuilder as an IDE and weblogic 8 as the application server.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top