Szymon Lisiecki

Szymon Lisiecki Senior Software
Engineer

Temat: problem ze Struts2

Witam,
Zauważyłem ostatnio dziwną przypadłość. Każda akcja odpala mi się 10 razy pod rząd.
Przed wyświetleniem strony do logowania wywoływana jest akcje prepareLogin, i ona wykonuje się 10 razy. Akcja logowania (login) również. Nie mam pojęcia czym to może być spowodowane.
Będę wdzięczny za jakiekolwiek wskazówki bądź "tropy"

Z góry dzięki
Przemysław Wardowski

Przemysław Wardowski Technology driven HR
solutions / CTO w IT
Systems sp. z o.o.

Temat: problem ze Struts2

cześć. co to znaczy, że akcja odpala się 10 razy? idzie 10 requestów? odpalany jest cały stack 10 razy? czy tylko execute jest wykonywane 10 razy? używasz w połączeniu ze spring security? wklej jak możesz struts.xml (jeśli nie jest pusty), ewentualnie spring-security xml.
Szymon Lisiecki

Szymon Lisiecki Senior Software
Engineer

Temat: problem ze Struts2

to jest struts.xml, a spring security nie używam

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
<package name="multi" namespace="" extends="struts-default">
<interceptors> <interceptor-stack name="defaultStack">
<interceptor-ref name="logger"/>
<interceptor-ref name="timer"/>
<interceptor-ref name="alias"/>
<interceptor-ref name="params"/>
<interceptor-ref name="staticParams"/>
<interceptor-ref name="servletConfig"/>
<interceptor-ref name="prepare"/>
<interceptor-ref name="chain"/>
<interceptor-ref name="staticParams"/>
<interceptor-ref name="conversionError"/>
<interceptor-ref name="validation"/>
<interceptor-ref name="workflow"/>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="defaultStack" />
<default-action-ref name="prepareLogin" /> <global-results>
<result name="prepareLogin">/jsp/all/login.jsp</result>
</global-results>

<action name="prepareLogin" class="pl.sl.multi.actions.LoginPrepareAction">
<result name="success" type="dispatcher">/jsp/all/login.jsp</result>
<result name="conf" type="dispatcher">/jsp/all/conf.jsp</result>
</action>
<action name="login" class="pl.sl.multi.actions.LoginAction">
<result name="success" type="dispatcher">/jsp/all/login.jsp</result>
<result name="conf" type="dispatcher">/jsp/all/conf.jsp</result>
</action>

</package>
<include file="struts/admin.xml"></include>
<include file="struts/adminBills.xml"></include>
<include file="struts/adminLogs.xml"></include>
<include file="struts/inlandRevenue.xml"></include>
</struts>
Szymon Lisiecki

Szymon Lisiecki Senior Software
Engineer

Temat: problem ze Struts2

Kilka linijek logów. Ustawiłem wszystkie na debug więc wyrzuca dużo info, ale te linijki myślę że są zastanawiające. w odstępie 0.013 sek jest ponownie wywoływana metoda execute w akcji


[DEBUG] 2011-07-11 12:54:11,641 : Setting static parameters {}
[DEBUG] 2011-07-11 12:54:11,641 : Setting static parameters {}
[DEBUG] 2011-07-11 12:54:11,641 : Validating /prepareLogin with method execute.
[DEBUG] 2011-07-11 12:54:11,659 : Checking ConfigurationProviders for reload.
[DEBUG] 2011-07-11 12:54:11,660 : Entering nullPropertyValue [target=[com.opensymphony.xwork2.DefaultTextProvider@d637d], property=struts]
[DEBUG] 2011-07-11 12:54:11,660 : Checking ConfigurationProviders for reload.
[DEBUG] 2011-07-11 12:54:11,660 : Checking ConfigurationProviders for reload.
[DEBUG] 2011-07-11 12:54:11,660 : Entering nullPropertyValue [target=[com.opensymphony.xwork2.DefaultTextProvider@d637d], property=struts]
[DEBUG] 2011-07-11 12:54:11,660 : Checking ConfigurationProviders for reload.
[DEBUG] 2011-07-11 12:54:11,661 : Creating an DefaultActionProxy for namespace and action name prepareLogin
[INFO ] 2011-07-11 12:54:11,661 : Starting execution stack for action prepareLogin
[DEBUG] 2011-07-11 12:54:11,661 : Setting params
[DEBUG] 2011-07-11 12:54:11,661 : Setting static parameters {}
[DEBUG] 2011-07-11 12:54:11,661 : Setting static parameters {}
[DEBUG] 2011-07-11 12:54:11,662 : Validating /prepareLogin with method execute.
[DEBUG] 2011-07-11 12:54:11,663 : Invoking validate() on action pl.sl.multi.actions.LoginPrepareAction@1c931fb
[DEBUG] 2011-07-11 12:54:11,663 : cannot find method [validateExecute] in action [pl.sl.multi.actions.LoginPrepareAction@1c931fb]
[DEBUG] 2011-07-11 12:54:11,663 : cannot find method [validateDoExecute] in action [pl.sl.multi.actions.LoginPrepareAction@1c931fb]
[DEBUG] 2011-07-11 12:54:11,663 : Executing action method = null
[DEBUG] 2011-07-11 12:54:11,663 : [LoginPrepareAction] getRemoteAddr = 0:0:0:0:0:0:0:1
[DEBUG] 2011-07-11 12:54:11,678 : Invoking validate() on action pl.sl.multi.actions.LoginPrepareAction@1f07360
[DEBUG] 2011-07-11 12:54:11,678 : cannot find method [validateExecute] in action [pl.sl.multi.actions.LoginPrepareAction@1f07360]
[DEBUG] 2011-07-11 12:54:11,678 : cannot find method [validateDoExecute] in action [pl.sl.multi.actions.LoginPrepareAction@1f07360]
[DEBUG] 2011-07-11 12:54:11,678 : Executing action method = null
[DEBUG] 2011-07-11 12:54:11,678 : [LoginPrepareAction] getRemoteAddr = 0:0:0:0:0:0:0:1
[DEBUG] 2011-07-11 12:54:12,664 : Forwarding to location /jsp/all/login.jsp

Szymon Lisiecki

Szymon Lisiecki Senior Software
Engineer

Temat: problem ze Struts2

Problem rozwiązany :)
Dla potomnych:

W pliku index.jsp robiłem przekierowanie na akcję prepareLogin.

<% response.sendRedirect("prepareLogin.html"); %> 


W innych plikach jsp zaczytywałem różne rzeczy m.in obrazki, css-y czy js-y.


<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/style.css" />


W pliku web.xml ustawiłem error page:

<error-page>
<error-code>404</error-code>
<location>/index.jsp</location>
</error-page>


I teraz rzecz decydująca. Za każdym razem gdy nie było jakiegoś pliku .js czy .css generował się błąd 404 a tym samym następowało przekierowanie na plik index.jsp a to z kolei wywoływało akcję ... itd. Tyle razy ile nie było jakiegoś pliku tyle razy odpalała się jedna akcja :)

Następna dyskusja:

Struts2 strust.extension pr...




Wyślij zaproszenie do