• 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+Tomcat+Spring+Vaadin-how display the ErrorPage,when we get the exceptions in the server console

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Requirement:

I want to show an error page when ever we get any exception(i.e.,NullPointer,IndexOutofBoundsException etc) in Server Console.

System Requirements:

We are using apache tomcat 7.0.61,maven 3.2.3,Spring and Vaadin 7 (For UI Framework).

Ours WEB.XML file:

<context-param>
..............
</context-param>

<context-param>
<param-name>contextClass</param-name>
<param-value>
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
</param-value>
</context-param>
.....
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<servlet>
<servlet-name>Vaadin Application Servlet</servlet-name>
<servlet-class>com.vaadin.server.VaadinServlet</servlet-class>
<init-param>
<description>Vaadin UI to display</description>
<param-name>UI</param-name>
<param-value>com.lone.ui.LoneUI</param-value>
</init-param>
<init-param>
<description>Application widgetset</description>
<param-name>widgetset</param-name>
<param-value>com.lone.ui.AppWidgetSet</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Vaadin Application Servlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
So i browsed and tried with some of the scenarios:

Scenario 1)

First i have configured

<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/error</location>
</error-page>
(or)
<error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/error</location>
</error-page>
in web.xml file and then i have written the Controller class by using the @RequestMapping("/error") in the method level but this scenario not worked.

Scenario 2)

Same with the above web.xml file i have written the Servlet class as

@WebServlet(value = {"/error"},asyncSupported = true)
public class ExceptionHandling extends VaadinServlet{
@Override
protected VaadinServletService getService() {
System.out.println("First if i display the sout message then i can Navigate to the Error Page....");
return super.getService();
}
}
But this is also not at worked.

Scenario 3)

Same with the above web.xml file i have written the Servlet class by extending the HTTPServlet but still unable to display the sout message.

Scenario 4) I have tried with Spring @ControllerAdvice and @Exception handler Annotation still i am unable to display the Error Page

Main Requirement:

I need to configure the Exceptions in the Web.xml file,so that when we get any exceptions in the server console it should hit the web.xml file and should navigate to the error page.

Could you please suggest me to complete the requirement because i have been working on this requirement from past 2 days.

Thanks in advance.
 
reply
    Bookmark Topic Watch Topic
  • New Topic