Struts2 Action mapping error - struts2

I am new to Struts2, I have been facing an action mapping issue in my Application. The error message says
Struts has detected an unhandled exception:
Messages: There is no Action mapped for namespace / and action name "yourActionName".
Stacktraces
There is no Action mapped for namespace / and action name "yourActionName". - [unknown location]
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:178)
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
...
The issue is intermittent and it occurs like very rarely. I have verified the action mapping in struts config file and also in JSP action seems to be correctly mapped. As far as I have understood, sometimes the action tries to map to wrong namespace.
I have defined the namespaces in all the concerned JSP. Nothing seems to be wrong with the controller layer.
Please help me with this issue

The same problem came into my application you should change your filter name
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
and after that you should clean your project then run it again if you get error then change
the filter by this
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
Do same process that is mentioned above it will work correctly because dispatcher.FilterDispatcher is deprecated after struts2.3.

Related

Struts 2 cannot resolve java action method in # tag

There's something I'm been missing in how Struts resolve ftl tag,
I have an action with some methods that I'm trying to call from my ftl.
The signature:
<#s.property value="%{someJavaMethod(someVariable)}>
is working fine, but the directive
<#include someJavaMethod(someOtherVariable)>
is giving me this:
----: freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:
==> someJavaMethod
and I cant figure out why, since, based on my limited knowledge of struts the signature # has access to the context Map where action properties and methods are stored.
NB: I checked that the problem is not in the someJavaMethod since debugging the code it doesn't even enter into.
You should reference the action to call its method in Freemarker. It is supported by the Struts 2 framework.
<#include action.someJavaMethod(someOtherVariable)>

#Html.DeleteConfirmation in a Plugin View (Admin) in asp.net core 2.0

Looking at core code examples of say... Edit Action for SpecificationAttribute. I am looking to replicate this delete function in the same manner in my plugin, however, getting an error.
Getting this error
'IHtmlHelper' does not contain a definition for 'DeleteConfirmation' and no extension method 'DeleteConfirmation' accepting a first argument of type 'IHtmlHelper' could be found (are you missing a using directive or an assembly reference?)
I have used in 3.90 but it getting error in 4.0 asp.net core Has anyone used #Html.DeleteConfirmation in a plugin (on administration side) that could give me a clues
I have a span element in the html like the following;
<span id="myattribute-delete" class="k-button">#T("Admin.Common.Delete")</span>
And trying to use #Html.DeleteConfirmation("myattribute-delete")
I know I probably need to double check my route, by the error is leading me to think the issue is not a routing issue.
As #Stephen stated it's not part of MVC, and it's custom helper by nopCommerce.
#Html.DeleteConfirmation is helper till/in nopCommerce 3.90, but in 4.0 it has been changed to
<nop-delete-confirmation asp-model-id="#Model.Id" asp-button-id="myattribute-delete" />
And that helper located at Nop.Web.Framework.TagHelpers.Adminso you have to add reference of it to your view file.

XWork class loading error in startup- Unable to read class [WEB-INF

In a Struts2 application, I'm seeing this error even though there are no issues in the functionality. But I'm seeing some delay in executing every action. This delay is valid for simple actions which return a JSP page with a search box in it. I'm using Struts 2.3.1.1 and xwork-core-2.3.1.1.
ERROR finder.ClassFinder: Unable to read class [WEB-INF.classes.com.***.***.ConfigManagement]
Could not load WEB-INF/classes/com/***/***/ConfigManagement.class - [unknown location]
at com.opensymphony.xwork2.util.finder.ClassFinder.readClassDef(ClassFinder.java:785)
Thanks in advance..
This got resolved with the latest Struts (2.3.12) update along with the relevant library files. I should have missed some of the libraries in the previous version of the Struts.

Struts 2 - struts tags error

I had this message when trying to execute struts 2 application. Please anyone can help? Should i provide additional info?
Though i am not able to see the image clearly and what the error is there, but looking in to the URL you are hitting i can tell you the cause of this exception.
In Struts2 you need to call the filter for every request in order to make Struts2 specific tag works ,since calling filter means letting framework to do its init work so that it should make available you things needed by you, in your case you are hitting a jsp page directly which means you are not letting S2 filter and its other associated classes to do the initial work and due to this Struuts2 tags do not have the required data which is cause of this error.
i suggest you to use action to make call for other JSP so as to let framework do its work
You need to create a filter in your web.xml for struts. Something like this
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter </filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

T4MVC renderpartial and Spark views

#Html.RenderPartial(MVC.Shared.Views._Sorter);
throws error =>
There is no build provider registered for the extension '.spark'. You can register one in the section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: There is no build provider registered for the extension '.spark'. You can register one in the section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.
Any ideas what might be wrong?
Adding this to web.config=>system.web=>compilation
<buildProviders>
<add extension=".spark" type="System.Web.Compilation.PageBuildProvider" />
</buildProviders>
Forces app to build spark view as webforms view and produces ${Something.something} all around. So - what's an equivalent for spark viewengine?
Can you please try to make the following change to T4MVT.tt. In the method ViewsFolderInfo.AddView, change the line:
Views[viewFieldName] = GetVirtualPath(item);
to
Views[viewFieldName] = viewFieldName;
If that works well, we can just add a switch to the settings file that makes it do this instead of the default full path.
Let me know how that goes!
Note that MVC.Shared.Views._Sorter is just a constant with the path to the view. If you were to write this code without T4MVC, what exact string would you pass in there?
Maybe Spark has different requirements in the type of view paths it accepts here? If needed, we can tweak T4MVC to make this work, but I'd like to fully understand the Spark behavior outside of T4MVC first.

Resources