-
1. Re: EJB method may not be found in base class (EJB 2 Entity Beans)
wolfc Dec 14, 2011 8:32 AM (in response to htfv)While technically such an ejbCreate is viable, it is a violation of the spec:
EJB 3.1 FR 8.6.4 ejbCreate<METHOD> Methods
The return type must be the entity bean’s primary key type.
The exception says exactly (in too much detail ) which method is missing.
-
2. Re: EJB method may not be found in base class (EJB 2 Entity Beans)
htfv Dec 14, 2011 10:22 AM (in response to wolfc)May be I'm missing something, this is the first time I'm dealing with EJB 2 entity beans, but:
- According to EJB 3.1 FR 8.6.4, ejbCreate<METHOD> Methods:
- The return type must be the entity bean’s primary key type.
- According to EJB 3.1 FR 8.6.12, Entity Bean's Local Home Interface:
- The return type for a create<METHOD> method on the local home interface must be the entity bean’s local interface type.
- Each create method name must match one of the ejbCreate<METHOD> methods defined in the enterprise bean class. The matching ejbCreate<METHOD> method must have the same number and types of its arguments. (Note that the return type is different.)
So, here's the local home interface:
{code}
public interface SmartAccessTileParameterHome extends EJBBaseEntityLocalHome
{
...
}
public interface EJBBaseEntityLocalHome extends EJBLocalHome
{
public EJBBaseEntityLocal create(Map<String, Object> params) throws CreateException;
...
}
{code}
Here's the bean class (I changed it to return Integer from ejbCreate):
{code}
public class SmartAccessTileParameterBean extends EJBBaseEntityBean implements SmartAccessTileParameterBeanPersistence
{
...
}
public abstract class EJBBaseEntityBean extends EJBBase implements IBaseEntityBean<Integer>
{
@Override
public Integer ejbCreate(Map<String, Object> params) throws CreateException
{
...
}
...
}
{code}
And here's the descriptor for complete picture:
{code:xml}
<entity>
<ejb-name>SmartAccessTileParameterEJB</ejb-name>
<local-home>com.piConsult.piMedia.ejb.entity.smartaccess.SmartAccessTileParameterHome</local-home>
<local>com.piConsult.piMedia.ejb.entity.util.EJBBaseEntityLocal</local>
<ejb-class>com.piConsult.piMedia.ejb.entity.smartaccess.SmartAccessTileParameterBean</ejb-class>
<persistence-type>Bean</persistence-type>
<prim-key-class>java.lang.Integer</prim-key-class>
<reentrant>True</reentrant>
<security-identity>
<use-caller-identity />
</security-identity>
</entity>
{code}
So, to me everything looks right: bean has ejbCreate which returns Integer, local home interface has create which returns local interface. Still get the same error.
- According to EJB 3.1 FR 8.6.4, ejbCreate<METHOD> Methods:
-
3. Re: EJB method may not be found in base class (EJB 2 Entity Beans)
htfv Dec 15, 2011 4:07 AM (in response to wolfc)BTW, I also tried to put ejbCreate directly in bean, and it worked. The following fixes this particular case:
{code}
public class SmartAccessTileParameterBean extends EJBBaseEntityBean implements SmartAccessTileParameterBeanPersistence
{
public Integer ejbCreate(Map<String, Object> params) throws CreateException
{
return super.ejbCreate(params);
}
...
}
{code}
I can't find any statement in spec, which says that ejbCreate may not be defined in base class. Assuming that it worked in past, I believe that it should also work in AS 7.1. Do you know if other containers dis/allow ejbCreate in base classes?
-
4. Re: EJB method may not be found in base class (EJB 2 Entity Beans)
htfv Dec 21, 2011 6:54 AM (in response to htfv)Hello Carlo,
your answer was correct, I just got confused by multiple levels of inheritance and interfaces, it's an old application with lots of spaghetti inside (examples above are actually simplified). I managed to find the error only after debugging through AS 7 deployment code >;)