Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8024175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:47:14+00:00 2026-06-04T22:47:14+00:00

I have a spring MVC application running on the application server. Each request to

  • 0

I have a spring MVC application running on the application server. Each request to the application results in Hibernate calling the entityManager.merge() to update a row in the database.

I run a test today sending in multiple requests and noticed that something i get the following error:

javax.persistence.OptimisticLockException
        at org.jboss.resteasy.core.SynchronousDispatcher.handleApplicationException(SynchronousDispatcher.java:340) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:214) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:190) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:540) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:502) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) [resteasy-jaxrs-2.3.1.GA.jar:]
        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) [resteasy-jaxrs-2.3.1.GA.jar:]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.10.Final.jar:]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.10.Final.jar:]
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.10.Final.jar:]
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.10.Final.jar:]
        at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.0.Final.jar:7.1.0.Final]
        at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:154) [jboss-as-web-7.1.0.Final.jar:7.1.0.Final]
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.10.Final.jar:]
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.10.Final.jar:]
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.10.Final.jar:]
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.10.Final.jar:]
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.10.Final.jar:]
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.10.Final.jar:]
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.10.Final.jar:]
        at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_20]

To be able to resolve the above i need to understand the following:

  • How are the requests handled on the application server? Is the case that each request is processed by its own thread?

  • Looking at the error i noticed that they were referred to as (http–10.10.4.16-8080-1) and (http–10.10.4.16-8080-7). Is the number at the end the thread number that processed the request?

  • The optimistiLockException suggests that there was an attempt to update the same message before JPA/Hibernate issued a commit. If i put the relevant code in a synchronized block, how do i ensure that the order the requests came in is the order they are processed when the synchronized block is available?

  • Is there a way to instruct JPA/Hibernate to not attempt to update the message if there are uncommitted changes?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T22:47:16+00:00Added an answer on June 4, 2026 at 10:47 pm

    The fixes available to you depend on how you’ve architectured your tiers and where the entity you’re merging comes from. Is the detached entity being assembled by the spring data binder, or stored on the web session, or are you fetching an entity from the database and making changes to it at the time the request arrives?

    How are the requests handled on the application server? Is the case
    that each request is processed by its own thread?

    They are handled by a thread pool. So each request does not get “its own” thread, but at any given time each active request is being processed by a seoarate thread, yes. (Or in a queue waiting for one to free.)

    Looking at the error i noticed that they were referred to as
    (http–10.10.4.16-8080-1) and (http–10.10.4.16-8080-7). Is the number
    at the end the thread number that processed the request?

    The whole thing is the name of the thread. Tomcat puts numbers at the end to make them unique, but that # doesn’t have any particular meaning other than an arbitrary sequential string assigned by tomcat.

    The optimistiLockException suggests that there was an attempt to
    update the same message before JPA/Hibernate issued a commit. If i put
    the relevant code in a synchronized block, how do i ensure that the
    order the requests came in is the order they are processed when the
    synchronized block is available?

    If order matters you will need to put them in some kind of a queue before processing. Synchronization makes no promises about the order waiting threads execute. If this process is a must-not-fail, consider using a pessimistic lock in the database rather than synching up on the app server. Some other thread using the table might not bother sycnhing and cause the exception anyway.

    Is there a way to instruct JPA/Hibernate to not attempt to update the
    message if there are uncommitted changes?

    Not really, there isn’t any direct way to check if an entity has pending updates in some other session’s in memory cache. The OptimisticLock check is the mechanism for knowing if someone else made a change.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a spring MVC based web application running on Tomcat 7.0. We are
I have a spring mvc application that I am using Hibernate with. I am
I have a Spring MVC application trying to use a rich domain model, with
I have a spring mvc application that I have broken up into separate maven
I have a Spring Web MVC application that I'd like to serve a large,
My setup : In a Spring MVC 3.1 application, I have a Spring Security
I have my application using Spring MVC + Apache 2 tiles + Spring security,
I have a controller (Spring-MVC) that generates a PDF report on a get request.
I'm running Spring MVC 3.x and I have one Controller with RequestMapping annotations (
I have a spring mvc application and we run tests with it using jetty.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.