• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

no-interface bean implementing interface without local annotation

 
Tarik Aazizi
Greenhorn
Posts: 19
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Could you please tell me if the interface IBEAN in that case is considered as a local business view or not?



I looked a lot for that in the EJB 3.1 specs, could you also specify the source of information if there is any.

Thanks in advance
 
L Foster
Ranch Hand
Posts: 185
10
Android Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Tarik:
Greetings. Here is a document from Oracle that claims you DO have a local interface there.

https://docs.oracle.com/cd/E11035_01/wls100/ejb30/annotations.html#wp1416811

value

Specifies the list of local interfaces as an array of classes.
You are required to specify this attribute only if your bean class implements more than a single interface, not including the following:
java.io.Serializable
java.io.Externalizable
javax.ejb.*


Since you implement only one interface, it is implied that the one you implement is the local interface.

Should you ever have doubts again, at least some deployment logs will tell you how an EJB is accessible, once you have deployed it. Just look at your log. Further, with EJB 3.1, you should have at least one global-portable JNDI name for your ejb, based on the implemented interface. You could probe that remotely to see if the expected name exists.
 
Tarik Aazizi
Greenhorn
Posts: 19
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Foster for your reply,

I agree that I implement only one interface, but as I know the no-interface view is considered as local view, so annotating the bean with @LocalBean will not prevent from applying that rule?

Another quick question, what do you mean by looking at logs? can we see JNDI names without configuring that in the logs?

 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2531
112
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you please tell me if the interface IBEAN in that case is considered as a local business view or not?

The exact answer to your question lies in the ejb-specs:

4.9.7 Session Bean’s Business Interface
The bean class must implement the interface or the interface must be designated as a local or remote business interface of the bean by means of the Local or Remote annotation or in the deployment descriptor.

The following rules apply:
- If the bean does not expose any other business interfaces (Local, Remote) or No-Interface view, and the bean class implements a single interface, that interface is assumed to be the business interface of the bean. This business interface will be a local interface unless the interface is designated as a remote business interface by use of the Remote annotation on the bean class or interface or by means of the deployment descriptor.
 
Tarik Aazizi
Greenhorn
Posts: 19
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Frits for your reply, So this means that in this case IBean will not be a Local business interface (as it expose a No-Interface view)? could you please confirm ?

By the way, Thanks a lot for your notes
 
L Foster
Ranch Hand
Posts: 185
10
Android Java Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Tarik,

Here is what I meant by logs. This is output from WildFly. No guarantee whether this will happen with any other server, but I note below, that all the JNDI bindings provided for the two EJBs I deployed, are printed in the log. The log level is just "info", which is not an uncommon log level setting. I did not have to change the logging level to get this output.

I mentioned this as a way for you to learn. Your own server might make this information available some other way.

18:21:12,291 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-11) JNDI bindings for session bean named TaxonHandler in deployment unit deployment "CAV.war" are as follows:

java:global/CAV/TaxonHandler!self.lesfoster.cav.ejb.TaxonHandler
java:app/CAV/TaxonHandler!self.lesfoster.cav.ejb.TaxonHandler
java:module/TaxonHandler!self.lesfoster.cav.ejb.TaxonHandler
java:global/CAV/TaxonHandler
java:app/CAV/TaxonHandler
java:module/TaxonHandler

18:21:12,323 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-11) JNDI bindings for session bean named ResultHandler in deployment unit deployment "CAV.war" are as follows:

java:global/CAV/ResultHandler!self.lesfoster.cav.ejb.ResultHandler
java:app/CAV/ResultHandler!self.lesfoster.cav.ejb.ResultHandler
java:module/ResultHandler!self.lesfoster.cav.ejb.ResultHandler
java:global/CAV/ResultHandler
java:app/CAV/ResultHandler
java:module/ResultHandler


BTW, a "No Interface View" means you do not have to implement an interface. It is a convenience offered as of the later versions of the EJB standard, in response to all the complaints about how complicated EJB deployment used to be. It works only for Local EJBs--not Remote ones.

 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2531
112
Android Chrome Eclipse IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tarik Aazizi wrote:Thanks Frits for your reply, So this means that in this case IBean will not be a Local business interface (as it expose a No-Interface View)? could you please confirm ?

Yes, according to the specifications IBean will only be considered as a business interface when the @LocalBean annotation is removed. However this bean, by the definition of the specs, is not exposing a "No-Interface View" either.

The rules for exposing a No-Interface-view are (4.9.8 Session Bean’s No-Interface View)
  • If the bean does not expose any other client views (Local, Remote, No-Interface, 2.x Remote Home, 2.x Local Home, Web Service) and its implements clause is empty, the bean defines a no-interface view.
  • If the bean exposes at least one other client view, the bean designates that it exposes a no-interface view by means of the @LocalBean annotation on the bean class or in the deployment descriptor.
  • The following interfaces are excluded when determining whether the bean exposes a no-interface view : java.io.Serializable; java.io.Externalizable; any of the interfaces defined by the javax.ejb package

  • My conclusion on your Bean and IBean is: that it is not a valid declaration.

    It would be interesting to test what Glassfish does in this case for example. Just define 1 method in the IBean interface and define 2 public methods in the Bean class. If Glassfish exposes both public methods it considers this bean as having a No-Interface View. If it only exposes the method in the IBean interface it considers the IBean interface as the local business interface (and it ignores the @LocalBean annotation).

    By the way, Thanks a lot for your notes

    Welcome
     
    Tarik Aazizi
    Greenhorn
    Posts: 19
    1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    @Frits, that's a good point.

    However, I think that it exposes a "No-Interface View" according to the definition of the annotation, in the JavaEE 6 docs it sais that @LocalBean:

    Designates that a session bean exposes a no-interface view.


    Also, in the JavaEE 7 docs it sais that @LocalBean:


    Designates that a session bean exposes a no-interface view.

    This annotation is required if a session bean exposes any other client views (local, remote, no-interface, 2.x Remote Home, 2.x Local Home, Web Service) in addition to the no-interface view or its implements clause contains an interface other than java.io.Serializable; java.io.Externalizable; or any of the interfaces defined by the javax.ejb package.

    This annotation is optional if a session bean exposes only a no-interface view.


    I think its the "its implements clause contains an interface other than" which makes the difference regarding the specs, and make our Bean in that case exposing a No-Interface view.

    @Foster, Thanks for the logs and your explanations. Meanwhile I know what is No-Interface as I am willing to pass the OCE EJB exam (you can wish me a good luck by the way ).
     
    Frits Walraven
    Creator of Enthuware JWS+ V6
    Saloon Keeper
    Pie
    Posts: 2531
    112
    Android Chrome Eclipse IDE
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Nice it seems they wanted to fix this inconsistency in the EE6 specs (API versus EJB spec).

    Have a Cow for the research you did!

    Good luck on your exam!
     
    Tarik Aazizi
    Greenhorn
    Posts: 19
    1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks Frits
     
    L Foster
    Ranch Hand
    Posts: 185
    10
    Android Java Netbeans IDE
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    @Tarik, Good luck.
     
    Tarik Aazizi
    Greenhorn
    Posts: 19
    1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks @Foster
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic