This week's book giveaway is in the Python forum.
We're giving away four copies of High Performance Python for Data Analytics and have Tiago Rodrigues Antao on-line!
See this thread for details.
Win a copy of High Performance Python for Data Analytics this week in the Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

EJB and inheritance

 
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I'd greatly appreciate if you could shed some light on the followin question

Question.
SessionBean2(SB2) extends SessionBean1(SB1).
SB2 has public access as it is declared as <ejb-class> in the ejb-jar.xml, SB1 has package access as it is never declared a <ejb-class> and should be only visible to classes that live in the same package.


Will the ejb container throw an error when deploying/executing methods on SB2 as it extends a bean (SB1) that does not have public access?

Thanks a lot in advance to all.
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your example does not conform to what the spec mandates in section 7.10.2, namely that session bean classes must be declared public.

I know this does not answer your question, but everything that does not conform to the spec is not worth investigating anyway
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Valentin Crettaz:
Your example does not conform to what the spec mandates in section 7.10.2, namely that session bean classes must be declared public.

I know this does not answer your question, but everything that does not conform to the spec is not worth investigating anyway



In my opinion the example is correct. Here is why.
We are deploying session bean SB2 which is public and implements SessionBean interface indirectly. As long as SB1 class file is accessable to SB2 and they both reside in the same package, container should be fine with it.

Vitaly
 
Alex Sharkoff
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Valentin & Vitaly for your replies.

We will have to agree with the spec and Valentin . I have tested the situation (the one I described in my original question) on JBoss and it throws an error. Made SB1 public - no error.

Thanks a lot again.

[ June 22, 2004: Message edited by: Alex Sharkoff ]
[ June 22, 2004: Message edited by: Alex Sharkoff ]
 
Valentin Crettaz
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alex,
I'm glad you made it work

Vitaliy,
Unfortunately, when the spec says that the session bean class has to be public, it really means it and expects that container providers enforce the rule
 
Vitaliy Geraymovych
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Valentin Crettaz:
Alex,
I'm glad you made it work

Vitaliy,
Unfortunately, when the spec says that the session bean class has to be public, it really means it and expects that container providers enforce the rule



I guess there is a misunderstanding. I just deployed a quick example into RI server without any problems.

Here is the code:

class AdviceBeanSuper implements SessionBean {
... /* all needed stuff here, callbacks and ejbCreate */
}


public class AdviceBean extends AdviceBeanSuper {
/* actual bean*/
}

As long as I am deploying AdviceBean and not AdviceBeanSuper I am OK. I think all spec rules are correct. AdviceBean is public and implements SessionBean interface. HFE page 186 refers to inheritance in EJB.

Alex, you are not trying to deploy SB1 in your exmaple? Right? Only SB2.

Vitaly
 
Space pants. Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic