Customize error page to connect timed out in Spring

Asked

Viewed 210 times

2

I’m trying to create a friendly error page in case LDAP is off the air, but unfortunately the only answer I have is j_spring_security_check.

I tried to map the exception in web.xml, but I was unsuccessful.

<error-page>
    <exception-type>java.net.SocketTimeoutException</exception-type >
    <location>/408</location>
</error-page>

<error-page>
    <exception-type>java.net.SocketTimeoutException</exception-type >
    <location>/408</location>
</error-page>

Console error:

GRAVE: Servlet.service() for servlet [mvc-dispatcher] in context with path [/gpa-pesquisa] threw exception org.springframework.ldap.CommunicationException: 171.18.0.15:389; nested exception is javax.naming.CommunicationException: 171.18.0.15:389 [Root exception is java.net.SocketTimeoutException: connect timed out]
    at org.springframework.ldap.support.LdapUtils.convertLdapException(LdapUtils.java:108)
    at org.springframework.ldap.core.support.AbstractContextSource.createContext(AbstractContextSource.java:356)
    at org.springframework.ldap.core.support.AbstractContextSource.doGetContext(AbstractContextSource.java:140)
    at org.springframework.ldap.core.support.AbstractContextSource.getReadOnlyContext(AbstractContextSource.java:159)
    at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:357)
    at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:309)
    at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:616)
    at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:586)
    at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:1651)
    at br.ufc.quixada.npi.ldap.dao.LdapUsuarioDao.getByCpf(LdapUsuarioDao.java:76)

1 answer

0


Friend, I did the following to create the customizable error pages. Use Apache Tiles to manage my views.

web xml.

<error-page>
    <error-code>500</error-code>
    <location>/500</location>
</error-page>
<error-page>
    <error-code>404</error-code>
    <location>/404</location>
</error-page>

Indexcontroller.java

@RequestMapping(value = "/404")
public String pageNotFound(Model model) {
    return "base.admin.error.404";
}

@RequestMapping(value = "/500")
public String internalServerError(Model model) {
    return "base.admin.error.500";
}
  • Thank you, in my case I was giving error because I had mapped in the controller the error 500 only for the GET method and should map both for GET and POST.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.