struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lukasz Lenart (Jira)" <j...@apache.org>
Subject [jira] [Commented] (WW-5089) @PreDestroy callbacks not invoked on injected beans
Date Fri, 11 Sep 2020 08:28:00 GMT

    [ https://issues.apache.org/jira/browse/WW-5089?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17194091#comment-17194091
] 

Lukasz Lenart commented on WW-5089:
-----------------------------------

I think action isn't a CDI bean so it won't have a scope at all

> @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.3.4#803005)

Mime
View raw message