postconstruct

jsf-spring : managedbean postconstruct not called

北城余情 提交于 2019-12-11 23:31:53
问题 I'm rather learning by doing so it might be a stupid question but I couldn't find any answer. I have an JSF application which worked well as used with simple JDBC. Take an example of the "domain.xhtml", which had a table listing elements from a "DomainController" bean. It was all working great then we switched to JPA. That controller has to use services so it's declared as @Component and includes (@Autowired) services from there. It also works well EXCEPT that all my JSF injections (

@ManagedProperty + @PostConstruct + init() = Nullpointer

人盡茶涼 提交于 2019-12-11 16:22:11
问题 Im getting a Nullpointer exception when using a managedProperty in my @PostConstruct - init() method as follows: package mx.com.clubjava.pexapp.view.bean; import java.io.Serializable; import java.util.List; import javax.annotation.PostConstruct; import javax.faces.bean.ManagedBean; import javax.faces.bean.ManagedProperty; import javax.faces.bean.ViewScoped; import mx.com.clubjava.pexapp.model.domain.Estado; import mx.com.clubjava.pexapp.model.service.EstadoFacade; @ManagedBean(name =

EJB @PostConstruct not called

拟墨画扇 提交于 2019-12-11 08:02:44
问题 When I want to invoke a method with @PostConstruct, the method is not invoked. I don't get any errors or logs from the server. Do I have to add some configuration xml files or add additional annotations to invoke the method? Serlvet: public class PersonServlet extends HttpServlet { private static final long serialVersionUID = 1L; private static final Logger LOG = LoggerFactory.getLogger(PersonServlet.class); @EJB Storage storage; protected void service(final HttpServletRequest req, final

How to get access to ServletContext inside of an @Configuration or @SpringBootApplication class

折月煮酒 提交于 2019-12-11 04:06:30
问题 I'm attempting to update an old Spring application. Specifically, I'm trying to pull all of the beans out of the old xml-defined form and pull them into a @SpringBootApplication format (while dramatically cutting down on the overall number of beans defined, because many of them did not need to be beans). My current issue is that I can't figure out how to make the ServletContext available to the beans that need it. My current code looks something like this: package thing; import stuff

Using Spring @Lazy and @PostConstruct annotations

左心房为你撑大大i 提交于 2019-12-11 03:09:02
问题 I have following classes: @Repository class A { public void method1() { ... } } @Component class B implements C { @Autowired @Lazy private A a; public void method2() { a.method1(); } } @Component class D { @Autowired private List<C> c; @PostConstruct public void method3() { // iterate on list c and call method2() } } Let's suppose Spring initializes the beans as following: 1. First bean B is created. When bean B is being created, field a will not be initialized because of the @Lazy annotation

Spring @PostConstruct depending on @Profile

二次信任 提交于 2019-12-10 13:48:22
问题 I'd like to have multiple @PostConstruct annotated methods in one configuration class, that should be called dependent on the @Profile. You can imagine a code snipped like this: @Configuration public class SilentaConfiguration { private static final Logger LOG = LoggerFactory.getLogger(SilentaConfiguration.class); @Autowired private Environment env; @PostConstruct @Profile("test") public void logImportantInfomationForTest() { LOG.info("********** logImportantInfomationForTest"); }

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

倖福魔咒の 提交于 2019-12-08 13:34:41
问题 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 this a4j:outputPanel and rich:panel component, i have a h:commandButton who execute the forms. I want to retrieve messages error for the form if the fields are empty for example (or other stuffs) But when i click h:commandButton , the view is re

Spring AOP and Post Construct

别等时光非礼了梦想. 提交于 2019-12-07 14:06:49
问题 I want to write the name of method which is using with @PostConstruct. But I found that AOP is unable to "Around" the PostConstruct method. Is there any way to use AOP with PostConstruct method? 回答1: Give this a try. @Around("@annotation(javax.annotation.PostConstruct)") public void myAdvice(ProceedingJoinPoint jp) throws Throwable{ System.out.println("This is before " + jp.getSignature().getName() + "()"); jp.proceed(); } Additionally you need to activate compile-time weaving. I published a

@org.omnifaces.cdi.ViewScoped invokes @PostConstruct on unload of an already destroyed view

你离开我真会死。 提交于 2019-12-07 11:33:25
I have a problem working with @org.omnifaces.cdi.ViewScoped and multiple tabs: I have a link in TestPage.xhtml that opens another page (ShowValuePage.xhtml) with a request parameter "someValue". If I open this link 10 times in a new tab and navigate away in the first opened tab, PostConstruct will be called again instead of just navigating away. Same happens if I navigate back from ShowValuePage to TestPage multiple times. (To test this, we must click the links "Show Value" and "Home" multiple times). This only happens if more tabs are opened than defined in the web.xml values

Can @ManagedPropery and @PostConstruct be placed in a base class?

喜夏-厌秋 提交于 2019-12-06 03:36:17
问题 I'm using a hierarchy of classes and what I would optimally try to do is have @ManagedBean 's that inherit a class that have @ManagedProperty members and @PostConstruct methods. Specifically, will this work? : public class A { @ManagedProperty private C c; @PostConstruct public void init() { // Do some initialization stuff } public C getC() { return c; } public void setC(C c) { this.c = c; } } @ManagedBean @SessionScoped public class B extends A { // Content... } Thanks in Advance! 回答1: The