@PostConstruct public void afterCreate() { System.out.println("In SlessEJB3::afterCreate() marked as PostConstruct"); // Access to getBusinessObject is allowed here ((SessionContext) ejbContext).getBusinessObject(SlessSub.class); }
@Resource private void setEJBContext5(SessionContext context) { ejbContext5 = context; try { context.getTimerService(); throw new RuntimeException("Should have gotten IllegalStateEx"); } catch (IllegalStateException ise) { System.out.println( "Successfully got exception when accessing " + "context.getTimerService() in " + "setContext method"); } try { context.getBusinessObject(SlessSub.class); throw new RuntimeException("Should have gotten IllegalStateEx"); } catch (IllegalStateException ise) { System.out.println( "Successfully got exception when accessing " + "context.getBusinessObject() in " + "setContext method"); } }