Foros del Web » Programación para mayores de 30 ;) » Java »

request.getRemoteUserN() devuelve nulo

Estas en el tema de request.getRemoteUserN() devuelve nulo en el foro de Java en Foros del Web. Me devuelve el siguiente error al crear una inscripcion onSubmit java.lang.NullPointerException at org.drugfarma.SedapSpring.webapp.controller.Inscri pcionController.onSubmit(InscripcionController.jav a:108) at org.springframework.web.servlet.mvc.SimpleFormCont roller.processFormSubmission(SimpleFormController. java:267) at org.drugfarma.SedapSpring.webapp.controller.BaseFo rmController.processFormSubmission(BaseFormControl ler.java:150) at org.drugfarma.SedapSpring.webapp.controller.Inscri ...
  #1 (permalink)  
Antiguo 07/09/2010, 07:29
 
Fecha de Ingreso: junio-2006
Mensajes: 10
Antigüedad: 18 años, 5 meses
Puntos: 0
request.getRemoteUserN() devuelve nulo

Me devuelve el siguiente error al crear una inscripcion onSubmit


java.lang.NullPointerException
at org.drugfarma.SedapSpring.webapp.controller.Inscri pcionController.onSubmit(InscripcionController.jav a:108)
at org.springframework.web.servlet.mvc.SimpleFormCont roller.processFormSubmission(SimpleFormController. java:267)
at org.drugfarma.SedapSpring.webapp.controller.BaseFo rmController.processFormSubmission(BaseFormControl ler.java:150)
at org.drugfarma.SedapSpring.webapp.controller.Inscri pcionController.processFormSubmission(InscripcionC ontroller.java:92)
at org.springframework.web.servlet.mvc.AbstractFormCo ntroller.handleRequestInternal(AbstractFormControl ler.java:265)
at org.springframework.web.servlet.mvc.AbstractContro ller.handleRequest(AbstractController.java:153)
at org.springframework.web.servlet.mvc.SimpleControll erHandlerAdapter.handle(SimpleControllerHandlerAda pter.java:48)
at org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:875)
at org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:807)
at org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:571)
at org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:511)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.inv oke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.pro cessRequest(ApplicationDispatcher.java:436)
at org.apache.catalina.core.ApplicationDispatcher.doF orward(ApplicationDispatcher.java:342)
at org.apache.catalina.core.ApplicationDispatcher.for ward(ApplicationDispatcher.java:302)
at org.drugfarma.SedapSpring.webapp.filter.StaticFilt er.doFilterInternal(StaticFilter.java:103)
at org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
at com.opensymphony.sitemesh.webapp.SiteMeshFilter.ob tainContent(SiteMeshFilter.java:129)
at com.opensymphony.sitemesh.webapp.SiteMeshFilter.do Filter(SiteMeshFilter.java:77)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
at org.tuckey.web.filters.urlrewrite.RuleChain.handle Rewrite(RuleChain.java:164)
at org.tuckey.web.filters.urlrewrite.RuleChain.doRule s(RuleChain.java:141)
at org.tuckey.web.filters.urlrewrite.UrlRewriter.proc essRequest(UrlRewriter.java:90)
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter .doFilter(UrlRewriteFilter.java:417)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
at org.displaytag.filter.ResponseOverrideFilter.doFil ter(ResponseOverrideFilter.java:125)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
at net.sf.ehcache.constructs.web.filter.GzipFilter.do Filter(GzipFilter.java:81)
at net.sf.ehcache.constructs.web.filter.Filter.doFilt er(Filter.java:92)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
at org.drugfarma.SedapSpring.webapp.filter.LocaleFilt er.doFilterInternal(LocaleFilter.java:74)
at org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
at org.springframework.security.util.FilterChainProxy $VirtualFilterChain.doFilter(FilterChainProxy.java :378)
at org.springframework.security.intercept.web.FilterS ecurityInterceptor.invoke(FilterSecurityIntercepto r.java:109)
at org.springframework.security.intercept.web.FilterS ecurityInterceptor.doFilter(FilterSecurityIntercep tor.java:83)
at org.springframework.security.util.FilterChainProxy $VirtualFilterChain.doFilter(FilterChainProxy.java :390)
at org.springframework.security.ui.SessionFixationPro tectionFilter.doFilterHttp(SessionFixationProtecti onFilter.java:67)
at org.springframework.security.ui.SpringSecurityFilt er.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy $VirtualFilterChain.doFilter(FilterChainProxy.java :390)
at org.springframework.security.ui.ExceptionTranslati onFilter.doFilterHttp(ExceptionTranslationFilter.j ava:101)
at org.springframework.security.ui.SpringSecurityFilt er.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy $VirtualFilterChain.doFilter(FilterChainProxy.java :390)
at org.springframework.security.providers.anonymous.A nonymousProcessingFilter.doFilterHttp(AnonymousPro cessingFilter.java:105)
at org.springframework.security.ui.SpringSecurityFilt er.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy $VirtualFilterChain.doFilter(FilterChainProxy.java :390)
at org.springframework.security.ui.rememberme.Remembe rMeProcessingFilter.doFilterHttp(RememberMeProcess ingFilter.java:109)
at org.springframework.security.ui.SpringSecurityFilt er.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy $VirtualFilterChain.doFilter(FilterChainProxy.java :390)
at org.springframework.security.wrapper.SecurityConte xtHolderAwareRequestFilter.doFilterHttp(SecurityCo ntextHolderAwareRequestFilter.java:91)
at org.springframework.security.ui.SpringSecurityFilt er.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy $VirtualFilterChain.doFilter(FilterChainProxy.java :390)
at org.springframework.security.ui.basicauth.BasicPro cessingFilter.doFilterHttp(BasicProcessingFilter.j ava:174)
at org.springframework.security.ui.SpringSecurityFilt er.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy $VirtualFilterChain.doFilter(FilterChainProxy.java :390)
at org.springframework.security.ui.AbstractProcessing Filter.doFilterHttp(AbstractProcessingFilter.java: 277)
at org.springframework.security.ui.SpringSecurityFilt er.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy $VirtualFilterChain.doFilter(FilterChainProxy.java :390)
at org.springframework.security.ui.logout.LogoutFilte r.doFilterHttp(LogoutFilter.java:89)
at org.springframework.security.ui.SpringSecurityFilt er.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy $VirtualFilterChain.doFilter(FilterChainProxy.java :390)
at org.springframework.security.context.HttpSessionCo ntextIntegrationFilter.doFilterHttp(HttpSessionCon textIntegrationFilter.java:235)
at org.springframework.security.ui.SpringSecurityFilt er.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy $VirtualFilterChain.doFilter(FilterChainProxy.java :390)
at org.springframework.security.util.FilterChainProxy .doFilter(FilterChainProxy.java:175)
at org.springframework.web.filter.DelegatingFilterPro xy.invokeDelegate(DelegatingFilterProxy.java:236)
at org.springframework.web.filter.DelegatingFilterPro xy.doFilter(DelegatingFilterProxy.java:167)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFi lter.doFilterInternal(CharacterEncodingFilter.java :96)
at org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run( JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)
  #2 (permalink)  
Antiguo 07/09/2010, 07:30
 
Fecha de Ingreso: junio-2006
Mensajes: 10
Antigüedad: 18 años, 5 meses
Puntos: 0
Respuesta: request.getRemoteUserN() devuelve nulo

en inscripcionController

public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response,
Object command, BindException errors)
throws Exception {
if (log.isDebugEnabled()) {
log.debug("entering 'onSubmit' method...");
}
Inscripciones inscripcion = (Inscripciones) command;
Locale locale = request.getLocale();
inscripcion.setIp(request.getRemoteAddr());
inscripcion.setFecha(new Date());
//System.out.println(request.getRemoteUser());

User user = this.userManager.getUserByUsername(request.getRemo teUser());

Long idUser = user.getId();
inscripcion.setIdUsuario(idUser.intValue());
Session sesion=inscripcionDAO.getSessionFactory().openSess ion();
Transaction trx = sesion.beginTransaction();
//Trabajos t = trabajosDAO.findByTitulo(fileUpload.getNombreTraba jo()).get(0);
//saveMessage(request, getText("fileUpload.deleted", fileUpload.getNombreTrabajo(), locale));


try {
this.getInscripcionDAO().save(inscripcion);
trx.commit();
//this.getInscripcionDAO().save(inscripcion);
//this.getInscripcionManager().saveInscripciones(ins cripcion);

} catch (AccessDeniedException ade) {
// thrown by UserSecurityAdvice configured in aop:advisor userManagerSecurity
log.warn(ade.getMessage());
trx.rollback();
response.sendError(HttpServletResponse.SC_FORBIDDE N);
return null;
} catch (Exception e) {
errors.rejectValue("inscripcion", "errors.creating.inscripcion",
new Object[]{inscripcion.getEMail()}, "inscripcion fallida");
trx.rollback();
// redisplay the unencrypted passwords
return showForm(request, response, errors);

} finally{
sesion.close();
//sesionAutor.close();
}

saveMessage(request, getText("inscripcion.registered", inscripcion.getEMail(), locale));
request.getSession().setAttribute(Constants.REGIST ERED, Boolean.TRUE);

// Send user an e-mail
if (log.isDebugEnabled()) {
log.debug("Sending user '" + inscripcion.getNombre() + "' an account information e-mail");
}
request.setAttribute("nombre", inscripcion.getNombre());
request.setAttribute("apellidos", inscripcion.getApellidos());
request.setAttribute("email", inscripcion.getEMail());

request.setAttribute("empresa", inscripcion.getEmpresa());
request.setAttribute("idInscripcion", inscripcion.getId());

// Send an account information e-mail

try {
//sendInscripcionDao(inscripcion, getText("signup.email.message", locale), RequestUtil.getAppURL(request));
} catch (MailException me) {
saveError(request, me.getMostSpecificCause().getMessage());
}

return new ModelAndView(getSuccessView());
}

El security.xml.

<http auto-config='true' lowercase-comparisons="false">
<intercept-url pattern="/images/*" filters="none"/>
<intercept-url pattern="/styles/*" filters="none"/>
<intercept-url pattern="/scripts/*" filters="none"/>
<intercept-url pattern="/admin/*" access="ROLE_ADMIN"/>
<intercept-url pattern="/passwordHint.html*" access="ROLE_ANONYMOUS,ROLE_ADMIN,ROLE_USER"/>
<intercept-url pattern="/signup.html*" access="ROLE_ANONYMOUS,ROLE_ADMIN,ROLE_USER"/>
<intercept-url pattern="/inscripcion.html*" access="ROLE_ANONYMOUS"/>
<intercept-url pattern="/resultadoInscripcion.html*" access="ROLE_ANONYMOUS,ROLE_ADMIN,ROLE_USER"/>
<intercept-url pattern="/**/*.html*" access="ROLE_ADMIN,ROLE_USER"/>
<form-login login-page="/login.jsp" authentication-failure-url="/login.jsp?error=true" login-processing-url="/j_security_check"/>
<!--<remember-me user-service-ref="userDao" key="e37f4b31-0c45-11dd-bd0b-0800200c9a66"/>
--></http>

<authentication-provider user-service-ref="userDao">
<!--<password-encoder ref="passwordEncoder"/>
--></authentication-provider><!--

Override the default password-encoder (SHA) by uncommenting the following and changing the class
--><!--<beans:bean id="passwordEncoder" class="org.springframework.security.providers.enco ding.ShaPasswordEncoder"/>

--><global-method-security>
<protect-pointcut expression="execution(* *..service.UserManager.getUsers(..))" access="ROLE_ADMIN"/>
<protect-pointcut expression="execution(* *..service.UserManager.removeUser(..))" access="ROLE_ADMIN"/>
</global-method-security><!--


Si me podeis ayudar gracias.

Etiquetas: nulo
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 14:24.