I am configuring the dynamicjasper to my struts2 but it raises an error. First of all I using the following jar files:
DynamicJasper-4.0.3
DynamicJasper-4.0.3-javadoc
DynamicJasper-4.0.3-sources
DynamicJasper-4.0.3-tests
DynamicJasper-4.0.3-test-sources
DynamicJasper-Struts2-1.3
jasperreports-4.7.0
struts2-jasperreports-plugin-2.0.11.1-sources
<result-types>
<result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult" />
<result-type name="redirectAction"
class="org.apache.struts2.dispatcher.ServletActionRedirectResult"/>
<result-type name="dynamic-jasper" class="ar.com.fdvs.dj.struts2.DJStruts2Result"/>
</result-types>
<action name="dynamicreport" class="ActionClass.DynamicJasperAction">
<interceptor-ref name="defaultLoginStack"/>
<param name="operation">showreport</param>
<result name="SUCCESS" type="dynamic-jasper">
<param name="format">PDF</param>
</result>
</action>
When I run the application it displays the following error in glass fish 3+ output window:
INFO: ERROR (org.apache.struts2.dispatcher.Dispatcher:38) - Dispatcher initialization failed
Unable to load configuration. - action - file:/G:/Project/IG/LIMSs/build/web/WEB-INF/classes/struts.xml:2996:78
Caused by: There is no result type defined for type 'dynamic-jasper' mapped with name 'SUCCESS'. Did you mean 'dynamicJasper'? - result - file:/G:/Project/IG/LIMSs/build/web/WEB-INF/classes/struts.xml:2999:58
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.buildResults(XmlConfigurationProvider.java:645)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:379)
... 57 more
INFO: WEB0671: Loading application [IMsys] at [/LIMSs]
INFO: IMsys was successfully deployed in 71,796 milliseconds.
WARNING: StandardWrapperValve[jsp]: PWC1406: Servlet.service() for servlet jsp threw exception
The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag. - [unknown location]
Error in browser as follows:
exception
org.apache.jasper.JasperException: The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag. - [unknown location]
root cause
The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag. - [unknown location]
I'm not sure how to configure the dynamic jasper, can you advise?
just download DynamicJasper-4.0.3-test-sources.jar instead of DynamicJasper-4.0.3-test.jar then add the problem is solved.
Related
In my project i am trying to implement TokenSession interceptor of Struts2. I have done following entries :-
struts.xml:
<interceptor-stack name="tokenStack">
<interceptor-ref name="tokenSession"/>
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
struts-module1.xml:
<action name="Action1" class="Class1" method="method1">
<interceptor-ref name="tokenStack"/>
<result name="input">one.two.three</result>
and in JSP I have added this entry:
<s:token/>
After implementing this code I am getting below exception which i tried after changing autowire properties to name instead of type but that is not a feasible solution to me.:-
2016-01-18 15:23:29 ERROR SpringObjectFactory:[main]->->-> : Error building bean
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.apache.struts2.interceptor.TokenSessionStoreInterceptor': Unsatisfied dependency expressed through bean property 'textProvider': : Error creating bean with name 'abc'
Please help me with this problem provided i want to go with autowiring as 'type' only and struts version is 2.3 (Struts.xml).
I'm having an issue removing the #Action and #Result Convention plugin annotations from an action and replacing them with the equivalent config in struts.xml.
package com.microed.cars.web;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import com.opensymphony.xwork2.ActionSupport;
public class HomeAction extends ActionSupport {
#Action(results = {
#Result(location = "/jsp/home.jsp")
})
#Override
public String execute() throws Exception {
return super.execute();
}
}
When these annotations are there, I can successfully access localhost:port/context/home.action
When I remove the annotations I get 'no result defined for action..... ' struts error, despite there being a 'capture all' result in struts.xml - the entire struts.xml is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.1//EN"
"http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<constant name="struts.devMode" value="true"/>
<constant name="struts.convention.package.locators" value="web"/>
<constant name="struts.convention.default.parent.package" value="beetroot"/>
<package name="beetroot" extends="json-default">
<action name="home" class="homeAction">
<result>/jsp/home.jsp</result>
</action>
<action name="cars" class="baseCarsAction">
<result name="input" type="json">
<param name="root">autoResults</param>
/jsp/home.jsp
</result>
</action>
</package>
</struts>
It extends json-default because I need the json result type for an autocomplete function.
I don't know why it's not picking up the action mapping for the homeAction class. I know struts.xml is being read because if I remove the action mapping "cars" then the autocomplete is disabled (but this needs the annotations which I'm trying to remove in order to validate this).
I know that 'no result defined' is a simple error, usually caused by spelling/capitalization errors but this is definitely not the case here, it's simply seems to be ignoring the whole "home" action mapping.
When stepping through DefaultActionInvocation.createResult, there are no 'results' at all for it to try to match against.
As it stands the cars action declaration isn't valid (nor does it make sense, IMO):
<action name="cars" class="baseCarsAction">
<result name="input" type="json">
<param name="root">autoResults</param>
<param name="location">/jsp/home.jsp</param>
</result>
</action>
That said: if it's a JSON result, a JSP isn't helpful, and it'll be ignored (or downright rejected, I'm not sure if it's an error or not). A single result will be either JSON, or HTML.
Turn logging up to DEBUG level to catch startup errors to narrow the range of possible causes.
If baseAction is configured in your Spring config file (which is unnecessary if you're using Spring annotations for injection) the configuration for the home action is valid.
I'd be wary of deploying the convention plugin if you're not actually using it: it changes how actions are mapped; it may have an impact on the surrounding application and cause problems. Stick with one or the other, avoid both–it makes it harder to reason about the source of application behavior.
Unrelated, but I recommend putting JSP pages under /WEB-INF to disallow direct client access.
I have a java webapp with both struts 1 and struts 2. Inside the app there are several Struts 2 namespaces and Struts 1 modules. For example:
/public (Struts 1 module)
/accounting (Struts 2 namespace)
/auditing (Struts 2 namespace)
/receipts (Struts 1 modules)
In my web.xml, the Struts 1 and 2 filters are specifically mapped to the correct namespace/module. For example,
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/accounting/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts1</filter-name>
<url-pattern>/public/*</url-pattern>
</filter-mapping>
Inside my Struts 1 area, I have a request to have a Struts 1 action forward to a Struts 2 action. I tried the following:
<action path="/myRedirect" forward="/checkAccountRecords.action" module="accounting" />
However, this results in the following stack trace:
The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag. - [unknown location]
I know that this could be fixed by mapping the Struts 1 parts of the website through the Struts 2 filter, but this causes problems for our specific website and I would like to avoid doing that.
I also tried the action without the module:
<action path="/myRedirect" forward="/accounting/checkAccountRecords.action" />
I got the folowing error:
can't find /receipts/accounting/checkAccountRecords.action (file not found)
I also tried the following action mapping:
<action path="/myRedirect" forward="../accounting/checkAccountRecords.action" />
I got the following error:
Path ../accounting/checkAccountRecords.action does not start with a "/" character
So is there anything left that I could try? How do I get a Struts 1 action to return a redirect to a Struts 2 action?
As a workaround, inside my Struts action, I manually modified the response.sendRedirect to send the user to the correct page instead of mapping it inside the struts.xml file.
Currently when you hit the root context of my application Struts2 throws an error:
ex. http://localhost:8080/
returns
HTTP ERROR 404
Problem accessing /. Reason:
There is no Action mapped for namespace / and action name .
Is there a way to do a default redirect in Struts2?
In my app I just do the following to redirect to a chosen action:
<action name="*">
<result type="redirectAction">
<param name="actionName">portal</param>
</result>
</action>
Just make sure you place this as the last action in your struts.xml configuration file and then it will catch everything that couldn't be matched earlier on.
This way the redirect happens within struts2, this is invisible to the user.
You can specify a welcome-file-list in web.xml and specify index.jsp, for example:
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
Then in index.jsp, you can put this at the top:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<META HTTP-EQUIV="Refresh" CONTENT="0;URL=initLogin.action">
Assuming you have something like this in struts.xml:
<action name="*Login" method="{1}" class="com.abc.LoginAction">
<result name="login">/login.jsp</result>
<result name="register">/register.jsp</result>
<result name="success">/success.jsp</result>
</action>
This will redirect to your LoginAction class with an init action.
So then if I went to http://localhost:8080/MyApp, this is the default action it would go to.
Is there no better thing than the meta refresh? Such as in struts there was a jsp:forward... that seems to not work in struts2. I don't know how much I am comfortable with the meta refresh. And don't know different it is than using any java provided redirect, guess I could use that dispatcher class which maybe in the jsp, not sure though.
Go through the examples in the following link, lot of tutorials are given there, using which you can identify your mistakes..
link, link2
I am not sure if this is me or if this is a bug.
I got the following error
11:52:01,623 ERROR ObjectFactory:27 - Unable to set parameter [dest] in result of type [org.apache.struts2.dispatcher.ServletRedirectResult]
Caught OgnlException while setting property 'dest' on type 'org.apache.struts2.dispatcher.ServletRedirectResult'. - Class: ognl.ObjectPropertyAccessor
File: ObjectPropertyAccessor.java
Method: setProperty
Line: 132 - ognl/ObjectPropertyAccessor.java:132:-1
at com.opensymphony.xwork2.ognl.OgnlUtil.internalSetProperty(OgnlUtil.java:392)
And my config is pretty minimal
<package name="esupport" namespace="/esupport" extends="struts-default">
<action name="old-esupport" class="com.my.MyRedirectAction">
<result type="redirect">
<param name="location">http://some.server.com/init.asp</param>
<param name="dest">${dest}</param>
</result>
</action>
</package>
And my class has a pair of get/set method. And that's it. Nothing Fancy
I have found this thread in the forum. But it doesn't solve my problem
I am using
Struts 2.1.16
Spring 2
Spring Security + CAS
(The funny behavior is it sends me to the CAS server after the error, but I guess it will be corrected after the redirect issue got fixed)
it seems like a bug with Struts2. they recommend...hiding the error by:
<category name="com.opensymphony.xwork2.ObjectFactory">
<priority value="fatal"/>
</category>
from....TroubleShooting guide section on redirects
I faced this issue after deploying the application in WAS 7 server. It was an existing application and there was no code change.
Found the following exceptions in the server start-up logs
Failed to write out object: ext___405722372
com.ibm.wkplc.extensionregistry.util.XmlUtilException: Unable to write to the given file
Just cleared the server cache and restarted it and the issue got resolved.