While testing the no-interface support, i found that the SessionContainer mandates the
presence of either a local or a remote interface for beans:
| Caused by: java.lang.RuntimeException: Bean Class
org.jboss.ejb3.nointerface.test.viewcreator.SimpleSLSBWithoutInterface has no local,
webservice, or remote interfaces defined and does not implement at least one business
interface: SimpleSLSBWithoutInterface
| at
org.jboss.ejb3.proxy.factory.ProxyFactoryHelper.getLocalAndBusinessLocalInterfaces(ProxyFactoryHelper.java:255)
| at
org.jboss.ejb3.proxy.factory.ProxyFactoryHelper.getLocalBusinessInterfaces(ProxyFactoryHelper.java:550)
| at
org.jboss.ejb3.session.SessionContainer.resolveBusinessInterfaces(SessionContainer.java:192)
| at org.jboss.ejb3.EJBContainer.instantiated(EJBContainer.java:1564)
| at org.jboss.ejb3.session.SessionContainer.instantiated(SessionContainer.java:182)
| ...
|
The code in question is this:
| protected List<Class<?>> resolveBusinessInterfaces()
| {
| // Obtain all business interfaces
| List<Class<?>> list = new ArrayList<Class<?>>();
|
list.addAll(Arrays.asList(ProxyFactoryHelper.getLocalBusinessInterfaces(this)));
|
list.addAll(Arrays.asList(ProxyFactoryHelper.getRemoteBusinessInterfaces(this)));
|
| return list;
| }
|
|
| public static Class<?>[] getLocalAndBusinessLocalInterfaces(Container
container)
| {
| // Initialize
| Set<Class<?>> localAndBusinessLocalInterfaces = new
HashSet<Class<?>>();
|
| // Obtain Bean Class
| Class<?> beanClass = container.getBeanClass();
|
| // Obtain @Local
| Local localAnnotation = ((EJBContainer) container).getAnnotation(Local.class);
|
| // Obtain @LocalHome
| LocalHome localHomeAnnotation = ((EJBContainer)
container).getAnnotation(LocalHome.class);
|
| // Obtain @Remote
| Remote remoteAnnotation = ((EJBContainer)
container).getAnnotation(Remote.class);
|
| // Obtain Remote and Business Remote interfaces
| Class<?>[] remoteAndBusinessRemoteInterfaces =
ProxyFactoryHelper.getRemoteAndBusinessRemoteInterfaces(container);
|
| // Obtain all business interfaces from the bean class
| Set<Class<?>> businessInterfacesImplementedByBeanClass =
ProxyFactoryHelper.getBusinessInterfaces(beanClass);
|
| // Obtain all business interfaces directly implemented by the bean class (not
including supers)
| Set<Class<?>> businessInterfacesDirectlyImplementedByBeanClass =
ProxyFactoryHelper.getBusinessInterfaces(
| beanClass, false);
|
| // Determine whether Stateful or Stateless
| boolean isStateless = (container instanceof StatelessContainer) ? true : false;
|
|
| ... // lot more stuff which is trimmed from the post
|
| // If no local interfaces have been defined/discovered
| else
| {
| // Obtain WS Endpoint
| String endpoint = ProxyFactoryHelper.getEndpointInterface(container);
|
| // If neither WS Endpoint or remotes are defined
| if (remoteAndBusinessRemoteInterfaces.length == 0 && endpoint ==
null)
| throw new RuntimeException(
| "Bean Class "
| + beanClass.getName()
| + " has no local, webservice, or remote interfaces
defined and does not implement at least one business interface: "
| + container.getEjbName());
|
| }
|
| // No local or business local interfaces discovered
| return new Class<?>[]
| {};
| }
|
Questions:
1) From what i remember, this sort of logic is already in place in some deployer. So do we
need this here again?
2) Shouldn't this logic be based on metadata which already has all the necessary
information? Instead of looking for the annotations and other stuff on the bean class
(again)
3) The restriction will not hold good for no-interface view for EJB 3.1
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4232150#...
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&a...