[ https://issues.apache.org/jira/browse/WW-5089?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Lukasz Lenart closed WW-5089. ----------------------------- Resolution: Not A Problem > @PreDestroy callbacks not invoked on injected beans > --------------------------------------------------- > > Key: WW-5089 > URL: https://issues.apache.org/jira/browse/WW-5089 > Project: Struts 2 > Issue Type: Bug > Components: Plugin - CDI > Affects Versions: 2.5.22 > Environment: Apache Tomcat 9.0.31, Open JDK 13.0.2 > Reporter: Bartłomiej N > Priority: Major > > I have web app deployed on tomcat with: > {code:xml} > <dependency> > <groupId>org.apache.struts</groupId> > <artifactId>struts2-core</artifactId> > <version>2.5.22</version> > </dependency> > <dependency> > <groupId>org.apache.struts</groupId> > <artifactId>struts2-cdi-plugin</artifactId> > <version>2.5.22</version> > </dependency> > <dependency> > <groupId>org.jboss.weld.servlet</groupId> > <artifactId>weld-servlet-core</artifactId> > <version>3.1.5.Final</version> > </dependency> > {code} > and: > {code:xml} > <listener> > <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class> > </listener> > <resource-env-ref> > <resource-env-ref-name>BeanManager</resource-env-ref-name> > <resource-env-ref-type> > javax.enterprise.inject.spi.BeanManager > </resource-env-ref-type> > </resource-env-ref> > {code} > > as CDI bootstrap in web.xml and empty beans.xml in META-INF directory. There > is also context.xml for Tomcat in webapp/META-INF: > {code:xml} > <?xml version='1.0' encoding='utf-8'?> > <Context> > <Resource name="BeanManager" > auth="Container" > type="javax.enterprise.inject.spi.BeanManager" > factory="org.jboss.weld.resources.ManagerObjectFactory"/> > </Context> > {code} > In app there is a simple CDI bean: > {code:java} > public class CDIBean { > @PostConstruct > private void postConstruct() { > //some code > } > @PreDestroy > private void preDestroy() { > //some code > } > } > {code} > when is use it in Struts action: > {code:java} > class MyAction extends ActionSupport implements SessionAware { > @Inject > private CDIBean bean; > Strign execute() { > //some code > } > } > {code} > @postConstruct callback is invoked and bean is injected correctly, but after > request completion @preDestroy is not invoked. -- This message was sent by Atlassian Jira (v8.20.10#820010)