Announcement Announcement Module
Collapse
No announcement yet.
How to handle exceptions Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to handle exceptions

    How to handle exception в Spring web flow.
    For example
    I have such (correct) exceptions
    ....
    Caused by: org.springframework.dao.DataIntegrityViolationExce ption: Could not execute JDBC batch update; ....
    .....
    Caused by: org.hibernate.exception.ConstraintViolationExcepti on: Could not execute JDBC batch update
    ....
    Caused by: java.sql.BatchUpdateException: Batch entry 0 insert into ROLES (roleName, id) values ('ORDERS_OFFICER', '2') was aborted. Call getNextException to see the cause.



    How I can catch them and show on page?

  • #2
    Go to the link "http://spring-rich-c.sourceforge.net/1.0.0/spring-richclient-manual/reference/html/exception-handling.html" you may solve your problem.
    Last edited by davisjerry; May 22nd, 2012, 02:06 AM.

    Comment


    • #3
      Hello,

      I also have the problem of reacting on the occurrence of Exceptions. For instance when a user upload something in a view, there can occure Exceptions when the connections between the browser and the server breaks down. The examples in the Spring-Web-Flow reference have a lack in dealing with such exceptions.

      I am wondering how i can handle such a situation. So, when for instance such a Exception
      Mit folgendem Fehler: org.springframework.web.multipart.MultipartExcepti on: Could not parse multipart servlet request; nested exception is org.apache.commons.fileupload.FileUploadException: Stream ended unexpectedly
      I want to redirect to the same state and display an Error-Message.

      The same applies, when a User Uploads a File that is to big. Then a Exception of Type org.springframework.web.multipart.MaxUploadSizeExc eededException occurs.

      After some research, I do not find anything better then trying the following:

      <view-state id="extraData" model="adData" view="views/flows/place-ad/extra" >
      <on-entry>
      <evaluate expression="adDataBean.getInstance(userManager, issueManager, advertisementManager, cityManager, flowRequestContext)" result="flowScope.adData" />
      </on-entry>
      <transition on-exception="org.springframework.web.multipart.MaxUp loadSizeExceededException" to="extraData" />
      <transition on-exception="java.lang.Exception" to="extraData"/>
      <transition on="submit_back" to="contactabilityData" validate="false">
      <evaluate expression="adData.processImageUpload(pictureManag er)" />
      </transition>
      <transition on="submit_forward" to="contactData">
      <evaluate expression="adData.processImageUpload(pictureManag er)" />
      <evaluate expression="states.markState('EXTRA')" />
      </transition>
      <transition on="submit_and_review" to="review" >
      <evaluate expression="adData.processImageUpload(pictureManag er)" />
      <evaluate expression="states.markState('EXTRA')" />
      </transition>
      </view-state>
      Of course I don`t excpect with this, dass some error messages are being produced. But at least that that Webflow display the same state again. But instead of this exception being propagated to the browser:

      javax.servlet.ServletException: org.springframework.web.util.NestedServletExceptio n: Request processing failed; nested exception is org.springframework.web.multipart.MaxUploadSizeExc eededException: Maximum upload size of 41943040 bytes exceeded; nested exception is org.apache.commons.fileupload.FileUploadBase$SizeL imitExceededException: the request was rejected because its size (997631302) exceeds the configured maximum (41943040)
      at net.sf.ehcache.constructs.web.filter.Filter.logThr owable(Filter.java:143)
      at net.sf.ehcache.constructs.web.filter.Filter.doFilt er(Filter.java:91)
      at org.eclipse.jetty.servlet.ServletHandler$CachedCha in.doFilter(ServletHandler.java:1333)
      at de.coolibri.core.webapp.filter.SessionFilter.doFil ter(SessionFilter.java:51)
      at org.eclipse.jetty.servlet.ServletHandler$CachedCha in.doFilter(ServletHandler.java:1333)
      at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 311)
      at org.springframework.security.web.access.intercept. FilterSecurityInterceptor.invoke(FilterSecurityInt erceptor.java:116)
      at org.springframework.security.web.access.intercept. FilterSecurityInterceptor.doFilter(FilterSecurityI nterceptor.java:83)
      at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 323)
      at org.springframework.security.web.access.ExceptionT ranslationFilter.doFilter(ExceptionTranslationFilt er.java:113)
      at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 323)
      at org.springframework.security.web.session.SessionMa nagementFilter.doFilter(SessionManagementFilter.ja va:101)
      at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 323)
      at org.springframework.security.web.authentication.An onymousAuthenticationFilter.doFilter(AnonymousAuth enticationFilter.java:113)
      at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 323)
      at org.springframework.security.web.savedrequest.Requ estCacheAwareFilter.doFilter(RequestCacheAwareFilt er.java:45)
      at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 323)
      at org.springframework.security.web.servletapi.Securi tyContextHolderAwareRequestFilter.doFilter(Securit yContextHolderAwareRequestFilter.java:54)
      at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 323)
      at org.springframework.security.web.authentication.Ab stractAuthenticationProcessingFilter.doFilter(Abst ractAuthenticationProcessingFilter.java:182)
      at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 323)
      at org.springframework.security.web.authentication.lo gout.LogoutFilter.doFilter(LogoutFilter.java:105)
      I hope someone can help me,

      Marc

      Comment

      Working...
      X