Questions tagged [postconstruct]

@PostConstruct is a Java EE annotation used to select a method that needs to be executed after dependency injection is done to perform any initialization.

The @PostConstruct annotation is used on a method that needs to be executed after dependency injection is done to perform any initialization. This method MUST be invoked before the class is put into service.

This annotation is recognized by all Java EE compliant containers as well as .

See also

242 questions
0
votes
1 answer

Why PostConstruct method is called several times inside an RichFaces 4.3 component with a ViewScoped?

I 'm facing a problem with JSF 2.2, richfaces 4.3.2 on Tomcat 7 . My page is annoted ViewScoped. I display a first form. When i change the value and select a specific one , i display by ajax a rich:panel element inside an a4j:outputPanel. Inside…
ZheFrench
  • 1,164
  • 3
  • 22
  • 46
0
votes
0 answers

@PostConstruct called multiple times with custom view scope

I have a project using JSF 2.0 , mojarra 2.2.4, Tomcat 7 and Primefaces 3.5. We also use Spring and Hibernate. I am facing a problem regarding the @PostContruct anotated method. It should be called only once, when the Page is created, but instead it…
Anika
  • 398
  • 5
  • 23
0
votes
0 answers

PostConstruct is called in each rowSelect

I have a dataTable with ajax event="rowSelect". Every time I click in another row the PostConstruct is called again, and I have no idea why. So, my dataTable code is:
Shelly
  • 1,035
  • 5
  • 27
  • 51
0
votes
1 answer

How to save form data from in JSF 1.2

I am trying to save the data edited in a t:dataTable object when a user clicks on a Save button h:commandButton. However, before the action is called, the postConstruct() method in the bean is called which tries to load the data for the table, but…
0
votes
0 answers

In Spring, does @Controller accept requests only after completing any other beans' @PostConstruct methods?

I have to initialize something with DAO using @PostConstruct. And before completing it, @Controller SHOULD NOT accept any request. Is it default behaviour? Or need any other configuration?
Johnny Lim
  • 5,623
  • 8
  • 38
  • 53
0
votes
1 answer

Multiple Instances of Session Bean created & @PostConstruct method called

Project comprise of EJB 2.0 and EJB 3.0 Beans. I converted a session bean from EJB 2.0 to EJB 3.0 and as I start the project, it initialize the session bean multiple times. The session bean call other session beans which in turn calls different…
Nabeel
  • 184
  • 2
  • 12
0
votes
1 answer

Invoking a secured method from a method in JSF managed bean which is annotated by @PostConstruct

In a JSF managed bean a method annotated with @PostConstruct - (javax.annotation.PostConstruct) is invoked as soon as the JSF managed bean is loaded i.e after the constructor of the managed bean finishes its execution. When I attempt to initialize a…
Tiny
  • 27,221
  • 105
  • 339
  • 599
0
votes
0 answers

stop faces message being added again in restore view

I add some faces message in the post construct. but when there is navigation from the current page the postconstruct is called again during restore view phase and adds the faces message again. is there a way to prevent the faces message from being…
sam
  • 1
  • 2
0
votes
0 answers

SessionScoped Bean @PostConstruct called twice

I have a SessionScoped bean to manage user authentication. The main page displays some additional text if the user is authenticated When the page loads I can see that the…
avrono
  • 1,648
  • 3
  • 19
  • 40
0
votes
1 answer

The spring bean is not injected if I call a method in the post-constructed class

I am doing a spring bean injection to my jsf managed bean property for which am getting the above mentioned error. The following is the full stack trace: SEVERE: Error Rendering View[/sample.xhtml] javax.faces.FacesException: Could not retrieve…
h-kach
  • 351
  • 2
  • 8
  • 25
0
votes
1 answer

Initializing data of a SessionBean in JSF using a GET param

My navigation case is as follows. I have a landing page, from which I can navigate to a store page. This store page can work with two different catalogues of products. This is controlled by a given Retailer object. From the store page on, there are…
Carlos
  • 41
  • 5
0
votes
3 answers

Call method after JBoss deploy

I want to have some method run, only after my WAR has been deployed to JBoss. The problem: Currently I am using @PostConstruct to load saved schedules from the DB. The problem is that I am creating instances of the Schedulers from this method, which…
JBotha
  • 42
  • 1
  • 3
  • 9
0
votes
1 answer

Spring3 @PostConstruct goes null after tomcat starts and get a Null Object when trying to use on a Service Class

hello everyone what Im trying to do is prefill a CustomDetail Object with some properties with the help of @Value and @PostConstruct, then use this prefilled Object on a service but when the Object arrives to the service class its null…
Jesse
  • 29
  • 1
  • 9
0
votes
2 answers

@PostConstruct not working in JBoss 5

I have a servlet that I cannot change (com.sun.jersey.spi.container.servlet.ServletContainer of Jersey RS) . What I can do is create a subclass of it. However, I needed that when the servlet is initialized it runs one function of my subclass. I…
Miguel Ribeiro
  • 8,057
  • 20
  • 51
  • 74
-1
votes
2 answers

Spring issue with @PostConstruct and @PreDestroy

I have a Spring application that I am trying to test with EmbededRedis. So I created a component like below to Initialize and kill redis after test. @Component public class EmbededRedis { @Value("${spring.redis.port}") private int redisPort; …
Anand Vaidya
  • 1,374
  • 11
  • 26
1 2 3
16
17