Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 5E8BD200D5C for ; Fri, 15 Dec 2017 23:13:48 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 5CBF9160C14; Fri, 15 Dec 2017 22:13:48 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id A2E6F160C04 for ; Fri, 15 Dec 2017 23:13:47 +0100 (CET) Received: (qmail 15297 invoked by uid 500); 15 Dec 2017 22:13:46 -0000 Mailing-List: contact user-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list user@struts.apache.org Received: (qmail 12142 invoked by uid 99); 15 Dec 2017 22:11:00 -0000 X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.999 X-Spam-Level: * X-Spam-Status: No, score=1.999 tagged_above=-999 required=6.31 tests=[HTML_MESSAGE=2, SPF_PASS=-0.001] autolearn=disabled Subject: Re: Re: java.lang.ClassCastException: org.apache.struts2.dispatcher.mapper.ActionMapping From: Prasanth Pasala To: user@struts.apache.org References: Organization: The Pangburn Company Message-ID: <4eb38db7-c680-429f-86b1-0de208dffbf3@pangburngroup.com> Date: Fri, 15 Dec 2017 16:10:53 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------A87450AD098865E5CA29FB59" Content-Language: en-US archived-at: Fri, 15 Dec 2017 22:13:48 -0000 --------------A87450AD098865E5CA29FB59 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit It seems like removeAttribute or setAttribute is not getting rid of the attribute from request. See below. If I set the value to a random string then I get a String can't be cast to ActionMapping exception.        Enumeration attrs = request.getAttributeNames();         while(attrs.hasMoreElements()) {             System.out.println(attrs.nextElement());         }         System.out.println(request.getAttribute("struts.actionMapping"));         request.setAttribute("struts.actionMapping", null);         System.out.println(request.getAttribute("struts.actionMapping")); Output: 16:05:05,300 INFO  [stdout] (default task-13) javax.servlet.forward.context_path 16:05:05,302 INFO  [stdout] (default task-13) javax.servlet.forward.servlet_path 16:05:05,303 INFO  [stdout] (default task-13) javax.servlet.forward.request_uri 16:05:05,303 INFO  [stdout] (default task-13) javax.servlet.forward.path_info 16:05:05,303 INFO  [stdout] (default task-13) javax.servlet.forward.query_string 16:05:05,303 INFO  [stdout] (default task-13) javax.servlet.request.key_size 16:05:05,303 INFO  [stdout] (default task-13) __cleanup_recursion_counter 16:05:05,303 INFO  [stdout] (default task-13) javax.servlet.request.cipher_suite 16:05:05,304 INFO  [stdout] (default task-13) struts.valueStack 16:05:05,308 INFO  [stdout] (default task-13) javax.servlet.request.ssl_session_id 16:05:09,121 INFO  [stdout] (default task-13) ActionMapping{name='Login', namespace='/', method='null', extension='action', params=null, result=null} 16:05:10,960 INFO  [stdout] (default task-13) ActionMapping{name='Login', namespace='/', method='null', extension='action', params=null, result=null} On 12/15/2017 02:28 PM, Prasanth Pasala wrote: > Thanks for the prompt response. Tried removing the attribute from the request, but still getting the class cast exception. Is it possible it is being set after I have called the forward?     > request.removeAttribute("struts.actionMapping");     // FORWARD THE REQUEST     ServletContext sContext = context.getContext("/context2");     RequestDispatcher rd = > sContext.getRequestDispatcher("/Login.action");    rd.forward(request, response);    [show/hide original text] > No it's not a Struts issue. You don't see this in Struts1 because maybe > it doesn't use any object bounded to dispatched request. But Struts2 > wants to > > ActionMapping mapping = > (ActionMapping)request.getAttribute("struts.actionMapping"); > > A workaround would be removing object with key "struts.actionMapping" > from request before dispatching. > > I hope this helps. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org > For additional commands, e-mail: user-help@struts.apache.org    --------------A87450AD098865E5CA29FB59--