Return-Path: X-Original-To: apmail-struts-issues-archive@minotaur.apache.org Delivered-To: apmail-struts-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1937517320 for ; Mon, 2 Mar 2015 14:12:44 +0000 (UTC) Received: (qmail 39141 invoked by uid 500); 2 Mar 2015 14:06:04 -0000 Delivered-To: apmail-struts-issues-archive@struts.apache.org Received: (qmail 39098 invoked by uid 500); 2 Mar 2015 14:06:04 -0000 Mailing-List: contact issues-help@struts.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@struts.apache.org Delivered-To: mailing list issues@struts.apache.org Received: (qmail 39087 invoked by uid 99); 2 Mar 2015 14:06:04 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Mar 2015 14:06:04 +0000 Date: Mon, 2 Mar 2015 14:06:04 +0000 (UTC) From: "Lukasz Lenart (JIRA)" To: issues@struts.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (WW-3161) When using execAndWait interceptor, getText() fails with npe (ActionContext.getContext() is null) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/WW-3161?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14343172#comment-14343172 ] Lukasz Lenart commented on WW-3161: ----------------------------------- Feel free to re-open :) > When using execAndWait interceptor, getText() fails with npe (ActionContext.getContext() is null) > ------------------------------------------------------------------------------------------------- > > Key: WW-3161 > URL: https://issues.apache.org/jira/browse/WW-3161 > Project: Struts 2 > Issue Type: Bug > Components: Core Interceptors > Affects Versions: 2.1.6 > Reporter: Gustavo De Sanctis > Fix For: 2.1.8 > > > I have a simple action that extends ActionSupport and uses the execAndWait interceptor. > In the "execute" method there is a getText("samekey") that fails with: > java.lang.NullPointerException > com.opensymphony.xwork2.util.LocalizedTextUtil.findText(LocalizedTextUtil.java:318) > com.opensymphony.xwork2.TextProviderSupport.getText(TextProviderSupport.java:191) > com.opensymphony.xwork2.TextProviderSupport.getText(TextProviderSupport.java:106) > com.opensymphony.xwork2.ActionSupport.getText(ActionSupport.java:80) > it.test.SimpleAction.execute(SimpleAction.java:10) > When using the default interceptor stack, it works fine. > My guess is that as the action context is threadlocal and as the execAndWait interceptor creates a new thread to handle the request... this new thread has no reference to the action context (infact ActionContext.getContext() returns null when using execAndWait) > Below the data to reproduce the problem: > ***************************** > ACTION CLASS: it.test.SimpleAction > ***************************** > package it.test; > import com.opensymphony.xwork2.ActionContext; > import com.opensymphony.xwork2.ActionSupport; > public class SimpleAction extends ActionSupport { > public String execute(){ > System.out.println(ActionContext.getContext()); > addActionMessage(getText("message.sample","ciao")); > return SUCCESS; > } > } > *********************** > Struts config > ************************ > > > /simple.jsp > > *********************** > simple.jsp > ********************** > > <%@taglib prefix="s" uri="/struts-tags"%> > > > > Simple > > > > > -- This message was sent by Atlassian JIRA (v6.3.4#6332)