Back Forum Reply New

EJB, RemoteException and service layer

Hi,

I use Remote EJB and I struggle with a RemoteException problem.
I would like to be able to switch the service layer implementation from EJB to mock objects but I don't want to use XDoclet generated interfaces for my mock objects.

Our architecture looks like :

Current state (use of the Xdoclet generated remote interface):

Code:   lt;bean id=quot;searchManquot;      class=quot;org..ejb.access.SimpleRemoteStatelessSessionProxyFactoryBeanquot;      lazy-init=quot;truequot;gt;       lt;property name=quot;jndiNamequot; value=quot;xxx/SearchManagerHomequot; /gt;       lt;property name=quot;businessInterfacequot; value=quot;xxx.service.ejb.SearchManagerquot; /gt;   lt;/beangt;
What I'd like to do (use the service interface)

Code:   lt;bean id=quot;searchManquot;      class=quot;org..ejb.access.SimpleRemoteStatelessSessionProxyFactoryBeanquot;      lazy-init=quot;truequot;gt;       lt;property name=quot;jndiNamequot; value=quot;xxx/SearchManagerHomequot; /gt;       lt;property name=quot;businessInterfacequot; value=quot;xxxservice.SearchServicequot; /gt;   lt;/beangt;

Interface for both ejbs and mock imple. In fact ejb is just used as technology adapter and call a pojo implementation
[Code]
/* Business interface */
interface ISearchService {  List search(Criteria c);   ...
}
[/Code[

Session bean is just a wrapper to  pojo implementation

Code:
/* Session bean implementation */
SearchSessionBean implementes SessionBean, ISearchService {  ...
}

I do not want EJB dependancies in my actions

Code:
/* Action */
SearchAction extends FormAction { SearchService searchManager; ...
}
This class is generated by XDoclet. To be able to cast the SimpleRemoteStatelessBean to my SearchService on the spring side I need to
also implements my own Service interface.

Code:
/* XDoclet generated remote interface */
public interface SearchManager implements javax.ejb.EJBObject, ISearchService
{
  public java.util.List search( xxx.model.SimpleSearchCriteria searchCriteria )     throws java.rmi.RemoteException;
  public java.lang.String getVersion(  )     throws java.rmi.RemoteException;
}
Here I get following Exception (which makes sense):

Code:   [javac] Compiling 25 source files to C:\Dev\workspace\xxx\build\gen\classes   [javac] C:\Dev\workspace\xxx\build\gen\src\xxx\service\ej
b\SearchManager.java:23: getVersion() in xxx.service.ejb.SearchManager
clashes with getVersion() in xxx.service.SDSService; overridden method does not throw java.rmi.RemoteException   [javac]    public java.lang.String getVersion(  )   [javac]                            ^   [javac] 1 error
To solve this  I see four solutions:
1) Use local ejbs instead if remote --gt; Sorry I cannot
2) Add throws RemoteException to my service interfaces --gt;  
2) Add throws Exception to my service interfaces --gt;  
3) Use an exception adapter between the action and the ejbDo you have a better idea how to handle this ?
What is the best practice ?

Many thanks in advance

Regards

Steve

I would recommand searching the forums forAbstractStatelessSessionBean or SimpleRemoteStatelessSessionProxyFactoryBean.  Also, take a look at this thread.  It might help.

Thanks a lot
¥
Back Forum Reply New