2

I'm trying to execute PostConstruct annotated method that is in abstract class,

    public abstract class AbstractTest {

            @PostConstruct
            public void init() {

            }
    }

    @ManagedBean
    @SessionScoped
    public Test extends AbstractTest {

    }

but when Test is created init method is not invoked, is it bug? unsupported feature? incorrect code?

on Mojarra 2.1.6 it works

MyFaces 2.1.6, Glassfish 3.1.2-b23

holek
  • 21
  • 2

1 Answers1

2

Java EE section 5.2.3

Resource annotations may appear on any of the classes listed above, or on any superclass of any class listed above. A resource annotation on any class in the inheritance hierarchy defines a resource needed by the application component.

Sounds like a bug to me! Apparently Mojarra had the same bug at one point in time and it was fixed: issue 800.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Jonathan S. Fisher
  • 8,189
  • 6
  • 46
  • 84
  • I created issue [MYFACES-3483](https://issues.apache.org/jira/browse/MYFACES-3483) but it was marked as invalid: "This is an old question. PostConstruct and PreDestroy annotation are only scanned for declared methods on Test class, but not for inherited methods. MyFaces cannot do anything, because this is responsibility of the container. I'll close this issue as invalid. " – holek Feb 28 '12 at 16:03
  • Very strange. If it is indeed responsibility of the container, what container and version are you using? – Jonathan S. Fisher Feb 28 '12 at 16:56
  • I'm using Glassfish 3.1.2-b23, but when I use Mojarra 2.1.6 ( bundled with glassfish ) it works so maybe this Mojarra is little modified.. – holek Feb 28 '12 at 17:52
  • So why use myfaces if you're using glassfish? just curious – Jonathan S. Fisher Feb 28 '12 at 19:01
  • Mojarra 2.1.6 has bug which affects primefaces commandLink in datatable ( it renders invalid update value ) [issue 3544](http://code.google.com/p/primefaces/issues/detail?id=3544) ... and I want to try MyFaces ;) – holek Feb 28 '12 at 19:21
  • 3
    gotacha... knowing PrimeFaces, he'll implement 50 new components before fixing any bugs – Jonathan S. Fisher Feb 28 '12 at 19:29
  • @exabrial Agreed; +1 for amusement. Incidently a similar strategy ended badly for Netscape Navigator... – 8bitjunkie Jul 08 '13 at 10:13