• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java.lang.NullPointerException org.apache.struts2.dispatcher.ServletRedirectResult.isPathUrl(Servl

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello guys,

i have this action :


package it.consip.cafe.sicurezza.webapp.action;

/**
* Created by IntelliJ IDEA.
* User: hp
* Date: 21-lug-2010
* Time: 16.44.50
* To change this template use File | Settings | File Templates.
*/

import it.consip.cafe.common.webapp.action.AbstractAction;
import it.consip.cafe.security.business.manager.RuoloManager;
import it.consip.cafe.security.business.manager.UtenteManager;
import it.consip.cafe.security.business.model.Ruolo;
import it.consip.cafe.security.business.model.Utente;
import org.apache.commons.lang.xwork.StringUtils;
import org.apache.struts2.convention.annotation.*;
import org.apache.struts2.interceptor.validation.SkipValidation;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Results({
@Result(location = "/WEB-INF/jsp/sicurezza/ricercaUtente.jsp"),


@Result(name = "associaRuoli", location = "/WEB-INF/jsp/sicurezza/associaRuolo.jsp")
})

@Namespace("/sicurezza")
public class UtenteAction extends AbstractAction {


@Autowired
UtenteManager utenteManager;

@Autowired
RuoloManager ruoloManager;

private final String ASSOCIARUOLI = "associaRuoli";
private final String INSERISCI = "inserisci";
private String matricola;
private String cognome;

private List<Utente> utentiRicerca;
private List<Ruolo> listaRuoli;
private String setup;
private Long idUtenteSelezionato;
private Utente utenteSelezionato;
private Long[] ruoliSelezionati;

@Action(value = "cerca",
results = {@Result(name = "input", location = "/WEB-INF/jsp/sicurezza/ricercaUtente.jsp"),
@Result(location = "/WEB-INF/jsp/sicurezza/ricercaUtente.jsp")})
public String cerca() {
setUtentiRicerca(utenteManager.ricercaUtente(getMatricola(), getCognome()));

return SUCCESS;
}

@Action(value = "associaRuoli",
results = {@Result(name = "input", type = "redirect", params = {"method", "cerca"} ),
@Result(location = "/WEB-INF/jsp/sicurezza/ricercaUtente.jsp")})
public String associaRuoli() {
setUtenteSelezionato(utenteManager.findById(idUtenteSelezionato));
getSetup();
setListaRuoli(ruoloManager.findAll());

return ASSOCIARUOLI;
}

@Action(value = "inserisci",
results = {@Result(name = "input", type = "chain", params = {"method", "associaruoli"}),
@Result(location = "/WEB-INF/jsp/sicurezza/associaRuolo.jsp")})
public String inserisci() {




return SUCCESS ;
}


public void validateCerca() {
if (StringUtils.isBlank(getCognome()) && StringUtils.isBlank(getMatricola())) {
addActionError(getText("ricerca.campiObbligatori"));
}
}

public void validateAssociaRuoli() {
if (getIdUtenteSelezionato() == null) {
addActionError(getText("ricerca.radioObbligatorio"));

}

}

public void validateInserisci() {

if (getRuoliSelezionati() == null) {
addActionError(getText("ricerca.checkboxObbligatori"));

}

}


public String getCognome() {
return cognome;
}

public void setCognome(String cognome) {
this.cognome = cognome;
}


public String getMatricola() {
return matricola;
}

public void setMatricola(String matricola) {
this.matricola = matricola;
}


public List<Utente> getUtentiRicerca() {
return utentiRicerca;
}

public void setUtentiRicerca(List<Utente> utentiRicerca) {
this.utentiRicerca = utentiRicerca;
}

public Long getIdUtenteSelezionato() {
return idUtenteSelezionato;
}

public void setIdUtenteSelezionato(Long idUtenteSelezionato) {
this.idUtenteSelezionato = idUtenteSelezionato;
}

public Utente getUtenteSelezionato() {
return utenteSelezionato;
}

public void setUtenteSelezionato(Utente utenteSelezionato) {
this.utenteSelezionato = utenteSelezionato;
}

public List<Ruolo> getListaRuoli() {
return listaRuoli;
}

public void setListaRuoli(List<Ruolo> listaRuoli) {
this.listaRuoli = listaRuoli;
}

public Long[] getRuoliSelezionati() {
return ruoliSelezionati;
}

public void setRuoliSelezionati(Long[] ruoliSelezionati) {
this.ruoliSelezionati = ruoliSelezionati;
}

public String getSetup() {
return setup;
}

public void setSetup(String setup) {
this.setup = setup;
}
}




and this jsp



<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib uri="http://displaytag.sf.net" prefix="display" %>

<html>
<head>
<title>Ricerca Utente</title>
</head>
<body>

<meta name="immagine" content="<%= request.getContextPath() %>/img/logoSub4.jpg"/>
<s:form action="utente">
<div class="boxTable">


<s:actionerror/>
<fieldset class="form1">

<legend><strong>Cerca utente</strong></legend>

<s:label class="1200" for="matricola" key="ricerca.matricola"/>
<s:textfield name="matricola"/>
<br/>

<s:label class="1200" for="cognome" key="ricerca.cognome"/>
<s:textfield name="cognome"/>
<br/>

</fieldset>


<div class="tableButton3">
<s:submit action="cerca" key="default.pulsanteCerca"/>
</div>

</div>


<br/>
<s:if test="utentiRicerca.size > 0">
<display:table name="utentiRicerca" id="utente" class="dati testo11" summary="testo" style="width: 100%;">
<display:caption title="Tabella degli utenti"/>
<display:column property="matricola" title="Matricola" scope="col" style="text-align: center;"/>
<display:column property="cognome" title="Cognome"/>
<display:column property="nome" title="Nome"/>
<display:column property="stampaRuoli" title="Ruoli"/>
<display:column class="w1" style="text-align: center;" title="Seleziona">
<input type="radio" name="idUtenteSelezionato" value='<s:property value="#attr.utente.id"/>'/>
</display:column>
</display:table>

<div class="tableButton3">
<s:submit action="associaRuoli" key="default.pulsanteAssociaRuoli"/>

</div>

</s:if>
</s:form>
</body>
</html>



In tha action i used a ridirect when i submit the jsp with the button <s:submit action="associaRuoli" key="default.pulsanteAssociaRuoli"/> and if there are error it must riderect on the same page that call la same action with the object to see in the jsp

@Action(value = "associaRuoli",
results = {@Result(name = "input", type = "redirect", params = {"method", "cerca"} ),
@Result(location = "/WEB-INF/jsp/sicurezza/ricercaUtente.jsp")})
why don't work??

i See this error :

Stacktraces
java.lang.NullPointerException

org.apache.struts2.dispatcher.ServletRedirectResult.isPathUrl(ServletRedirectResult.java:231)
org.apache.struts2.dispatcher.ServletRedirectResult.doExecute(ServletRedirectResult.java:148)
org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:362)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:266)
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129)
com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77)
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:102)
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:211)
org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
org.mortbay.jetty.Server.handle(Server.java:313)
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:506)
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:844)
org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:644)
org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:396)
org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)



thankyou

 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please UseCodeTags when posting code or configuration. Unformatted code and configuration is unnecessarily difficult to read. You can edit your post by using the button.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The location of a redirect must be an actual application resource, not the name of a result.

http://struts.apache.org/2.x/docs/redirect-result.html
http://struts.apache.org/2.x/docs/result-types.html
 
sol loc
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you give me an axample, please??

thankyou
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are examples on the linked page, and the Convention plugin page has examples as well.
 
sol loc
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok thanks, but i start to programmer a few time and i don't understant if someone can give me an example.

thank you
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you want an example of? A redirect needs something other than a result name. You don't use result names as arguments to results: results *have* names, and are things like actions, JSPs, etc.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic