Struts 2和JSON奇怪"找不到动作或结果"例外

时间:2017-01-06 03:23:46

标签: java json ajax jsp struts2

我在struts 2代码中找不到非常奇怪的异常的原因。我使用ajax表单JSP调用一个动作。我debuged和动作返回SUCCESS然而在invocation.invoke返回结果为null我得到该异常

感谢您的建议和想法......谢谢!

支柱-查卡布科-json.xml

<struts>
<package name="struts-json" namespace="/" extends="default,json-default">
    ...
    <action name="go.liquidaciones.pagar" method="pagarLiquidacion" class="ar.com.cipres.chacabuco.contabilidad.LiquidacionProfesoresAction">
        <interceptor-ref name="loginStack"></interceptor-ref>
        <result type="json">
            <param name="excludeNullProperties">true</param>
            <param name="noCache">true</param>
        </result>
        <result name="error">ajaxerror.jsp</result> 
    </action>
</package>
</struts>

动作类

package ar.com.cipres.chacabuco.contabilidad;

....

public class LiquidacionProfesoresAction extends ActionSupport implements SessionAware, ServletRequestAware {

private static final long serialVersionUID = 1L;
private static final Logger log = Logger.getLogger(LiquidacionProfesoresAction.class);

private HttpServletRequest request;
private Map<String, Object> sessionMap;
private Long id;
private Receipt receipt;

public String pagarLiquidacion() { 

    log.debug("Ejecutando pagarLiquidacion con id=[" + id + "]");

    if (id == null) {
        log.debug("Id de liquidacion es nulo. Informe a soporte técnico.");
        addActionError("Id de liquidacion es nulo. Informe a soporte técnico.");
        return ERROR;
    }

    try {
        String terminal =  SessionUtilities.getRemoteIPAddress(request);
        receipt = ControladorLiquidacionProfesores.getInstance().pagarLiquidacionAProfesoresByID(id,AccountController.getInstance().getCuentaByNumero(Integer.valueOf(ChacabucoProperties.get("accounterTask.cuentaDeCaja"))).getId(),usuarioLogueado.getId(),terminal);
    } catch (Exception e) {
        log.error("Error al pagar liquidacion con id="+id, e);
        addActionError("Error al pagar liquidacion con id=" + id + "<BR>" + e.getMessage() + "<BR>Informe a soporte técnico");
        return ERROR;
    }
    return SUCCESS; 
}

拦截

package ar.com.cipres.framework.logic;

import ....

public class LoginInterceptor extends AbstractInterceptor {

private static final long serialVersionUID = 1L;
private static final Logger log = Logger.getLogger(LoginInterceptor.class);

@Override
public String intercept(final ActionInvocation invocation) throws Exception {

    HttpServletRequest rs = ServletActionContext.getRequest();
    HttpServletResponse resp = ServletActionContext.getResponse();


    Map<String, Object> session = ActionContext.getContext().getSession();

    User user = SessionUtilities.getUser(session);

    if(!SessionUtilities.userHasRequiredRole(user, ActionContext.getContext().getName())) {
        return "noPermission";
    }

    if (user != null) {
        log.debug(invocation.getAction().toString());
        String result ="";
        try {
            result = invocation.invoke();
        } catch (Exception e) {
            log.error(e.getClass());
            log.error(e.getCause());
        }
        return result; 
    }

    Object action = invocation.getAction();

    if (!(action instanceof LoginAction)) { 
        return "loginRedirect";
    }

    return invocation.invoke();
}
}

异常

2017-01-08 12:12:57 DEBUG 5E65B LiquidacionProfesoresAction:242 - Ejecutando pagarLiquidacion con id=[473]
2017-01-08 12:12:57 DEBUG 5E65B AccountController:138 - Ejecutando getCuentaByNumero [numero=1018]
2017-01-08 12:12:57 DEBUG 5E65B AccountController:170 - Resultado del query "Cuenta [id=1, numero=1018, denominacion=Caja Central, tipo=2, status=1, cuentaDeActividad=false, cuentaDeActividadClub=false, cuentaDeActividadProfesor=false, cuen
taDeEspacioEnReserva=false, cuentaDeCargaManual=false, fechaDeCreacion=null, fechaDeModificacion=2016-07-02 15:34:31.0]"
2017-01-08 12:12:57 DEBUG 5E65B AccountController:138 - Ejecutando getCuentaByNumero [numero=1121]
2017-01-08 12:12:57 DEBUG 5E65B AccountController:170 - Resultado del query "Cuenta [id=10, numero=1121, denominacion=Banco Ciudad Cta.Cte. Pesos, tipo=2, status=1, cuentaDeActividad=false, cuentaDeActividadClub=false, cuentaDeActividadProf
esor=false, cuentaDeEspacioEnReserva=false, cuentaDeCargaManual=false, fechaDeCreacion=null, fechaDeModificacion=2016-07-06 19:58:02.0]"
2017-01-08 12:12:57 DEBUG 5E65B AccountController:138 - Ejecutando getCuentaByNumero [numero=1018]
2017-01-08 12:12:57 DEBUG 5E65B AccountController:170 - Resultado del query "Cuenta [id=1, numero=1018, denominacion=Caja Central, tipo=2, status=1, cuentaDeActividad=false, cuentaDeActividadClub=false, cuentaDeActividadProfesor=false, cuen
taDeEspacioEnReserva=false, cuentaDeCargaManual=false, fechaDeCreacion=null, fechaDeModificacion=2016-07-02 15:34:31.0]"
2017-01-08 12:12:57 DEBUG 5E65B ControladorLiquidacionProfesores:275 - Ejecutando pagarLiquidacionAProfesoresByID de liquidacion con id=[473] en cuenta=[1], uid=[2] y terminal=[127.0.0.1]
2017-01-08 12:12:57 DEBUG 5E65B UsersController:126 - Ejecutando getUserByID para 2
2017-01-08 12:12:57 DEBUG 5E65B UsersController:128 - Ejecutando select user from User user where id = '2'
2017-01-08 12:12:57 DEBUG 5E65B PersistanceManager:69 - Ejecutando select user from User user where id = '2'
2017-01-08 12:12:57 DEBUG 5E65B UsersController:139 - Resultado del query usuario "cpires"(2)
2017-01-08 12:12:57 DEBUG 5E65B ControladorLiquidacionProfesores:113 - Ejecutando obtenerLiquidacionAProfesoresByID para id=[473]
2017-01-08 12:12:57 DEBUG 5E65B AccountingController:42 - ar.com.cipres.chacabuco.contabilidad.AccountingController@14939c77
2017-01-08 12:12:57 ERROR 5E65B LoginInterceptor:61 - class org.apache.struts2.json.JSONException
2017-01-08 12:12:57 ERROR 5E65B LoginInterceptor:62 - org.apache.struts2.json.JSONException: java.lang.reflect.InvocationTargetException
2017-01-08 12:12:57 WARN  5E65B Dispatcher:68 - Could not find action or result: /chacabuco/go.liquidaciones.pagar.action?id=473&_=1483888370558
No result defined for action ar.com.cipres.chacabuco.contabilidad.LiquidacionProfesoresAction and result  - action - file:/C:/Users/claudio/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/chacabuco/WEB-INF/classes/s
truts-chacabuco-json.xml:141:140
    at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:371)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:273)
    at org.apache.struts2.interceptor.DeprecationInterceptor.intercept(DeprecationInterceptor.java:41)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
    at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
    at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:167)
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
    at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
    at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:76)
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
    at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
    at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:229)
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
    at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:229)
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
    at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
    at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
    at org.apache.struts2.interceptor.DateTextFieldInterceptor.intercept(DateTextFieldInterceptor.java:125)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
    at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
    at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:253)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
    at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
    at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
    at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
    at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
    at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:139)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
    at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
    at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
    at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:244)
    at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
    at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:564)
    at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:81)
    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at ar.com.cipres.framework.logic.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:44)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)

0 个答案:

没有答案