Hello
After days of investigations I narrowed the problem down to Blob fields.
I created the following test code in a controller.
Code:
private String path = "testdir/test6.log";
private String content = path;
@RequestMapping(value = "/update/test6", method = RequestMethod.GET)
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void test6(Writer writer) throws Exception {
try {
IEntityManagerService entityManagerService = CommonPlugin.getService(IEntityManagerService.class);
EntityManager entityManager = entityManagerService.getEntityManager();
Session session = (Session) entityManager.getDelegate();
RepositoryEntry entry = SoftmodelerFactory.eINSTANCE.createRepositoryEntry();
entry.setId(IdUtil.generateUUID(entry.eClass()));
entry.setModifyDate(new Date());
entry.setType("data");
entry.setPath(path);
entry.setData(session.getLobHelper().createBlob(content.getBytes()));
session.merge(entry);
writer.append("Entry ID: ").append(entry.getId());
} catch (Exception e) {
e.printStackTrace();
}
}
@RequestMapping(value = "/update/test7", method = RequestMethod.GET)
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void test7(Writer writer) throws Exception {
try {
IEntityManagerService entityManagerService = CommonPlugin.getService(IEntityManagerService.class);
EntityManager entityManager = entityManagerService.getEntityManager();
Session session = (Session) entityManager.getDelegate();
Criteria criteria = session.createCriteria(RepositoryEntry.class);
criteria.add(Restrictions.eq("path", path));
RepositoryEntry entry = (RepositoryEntry) criteria.uniqueResult();
entry.setModifyDate(new Date());
session.merge(entry);
writer.append("Entry ID: ").append(entry.getId());
} catch (Exception e) {
e.printStackTrace();
}
}
First I call "/update/test6" to create the repository entry object. I then call "/update/test7" and it may work first, but after at least 3 executions I get the following exception:
Code:
WARN: Transaction - Unexpected exception from beforeCompletion; transaction will roll back
javax.persistence.PersistenceException: org.hibernate.exception.DataException: The stream value is not the specified length. The specified length was 17, the actual length is 0.
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1387) ~[hibernate-entitymanager-4.1.10.Final.jar:4.1.10.Final]
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1310) ~[hibernate-entitymanager-4.1.10.Final.jar:4.1.10.Final]
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1316) ~[hibernate-entitymanager-4.1.10.Final.jar:4.1.10.Final]
at org.hibernate.ejb.AbstractEntityManagerImpl$CallbackExceptionMapperImpl.mapManagedFlushFailure(AbstractEntityManagerImpl.java:1510) ~[hibernate-entitymanager-4.1.10.Final.jar:4.1.10.Final]
at org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorImpl.beforeCompletion(SynchronizationCallbackCoordinatorImpl.java:109) ~[hibernate-core-4.1.10.Final.jar:4.1.10.Final]
at org.hibernate.engine.transaction.synchronization.internal.RegisteredSynchronization.beforeCompletion(RegisteredSynchronization.java:53) ~[hibernate-core-4.1.10.Final.jar:4.1.10.Final]
at org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion(TransactionImpl.java:522) [geronimo-transaction-2.1.2.jar:na]
at org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion(TransactionImpl.java:506) [geronimo-transaction-2.1.2.jar:na]
at org.apache.geronimo.transaction.manager.TransactionImpl.beforePrepare(TransactionImpl.java:400) [geronimo-transaction-2.1.2.jar:na]
at org.apache.geronimo.transaction.manager.TransactionImpl.commit(TransactionImpl.java:260) [geronimo-transaction-2.1.2.jar:na]
at org.apache.geronimo.transaction.manager.TransactionManagerImpl.commit(TransactionManagerImpl.java:250) [geronimo-transaction-2.1.2.jar:na]
at org.springframework.transaction.jta.JtaTransactionManager.doCommit(JtaTransactionManager.java:1009) [org.springframework.transaction_3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754) [org.springframework.transaction_3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723) [org.springframework.transaction_3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.jencks.GeronimoPlatformTransactionManager.commit(GeronimoPlatformTransactionManager.java:76) [jencks-2.1.jar:na]
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:393) [org.springframework.transaction_3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.transaction.aspectj.AbstractTransactionAspect.ajc$afterReturning$org_springframework_transaction_aspectj_AbstractTransactionAspect$3$2a73e96c(AbstractTransactionAspect.aj:78) [org.springframework.aspects_3.0.5.RELEASE.jar:3.0.5.RELEASE]
at ch.scodi.server.update.UpdateController.test7(UpdateController.java:1374) [ch.scodi.server/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_17]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_17]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_17]
at java.lang.reflect.Method.invoke(Method.java:601) ~[na:1.7.0_17]
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176) [org.springframework.web_3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426) [org.springframework.web.servlet_3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414) [org.springframework.web.servlet_3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790) [org.springframework.web.servlet_3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719) [org.springframework.web.servlet_3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644) [org.springframework.web.servlet_3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549) [org.springframework.web.servlet_3.0.5.RELEASE.jar:3.0.5.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:735) [javax.servlet_3.0.0.v201112011016.jar:na]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848) [javax.servlet_3.0.0.v201112011016.jar:na]
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:669) [org.eclipse.jetty.servlet_8.1.9.v20130131.jar:8.1.9.v20130131]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1448) [org.eclipse.jetty.servlet_8.1.9.v20130131.jar:8.1.9.v20130131]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:343) [org.springframework.security.web_3.0.2.RELEASE.jar:na]
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109) [org.springframework.security.web_3.0.2.RELEASE.jar:na]
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83) [org.springframework.security.web_3.0.2.RELEASE.jar:na]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) [org.springframework.security.web_3.0.2.RELEASE.jar:na]
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97) [org.springframework.security.web_3.0.2.RELEASE.jar:na]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) [org.springframework.security.web_3.0.2.RELEASE.jar:na]
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100) [org.springframework.security.web_3.0.2.RELEASE.jar:na]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) [org.springframework.security.web_3.0.2.RELEASE.jar:na]
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78) [org.springframework.security.web_3.0.2.RELEASE.jar:na]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) [org.springframework.security.web_3.0.2.RELEASE.jar:na]
at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:112) [org.springframework.security.web_3.0.2.RELEASE.jar:na]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) [org.springframework.security.web_3.0.2.RELEASE.jar:na]
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54) [org.springframework.security.web_3.0.2.RELEASE.jar:na]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) [org.springframework.security.web_3.0.2.RELEASE.jar:na]
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35) [org.springframework.security.web_3.0.2.RELEASE.jar:na]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) [org.springframework.security.web_3.0.2.RELEASE.jar:na]
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:188) [org.springframework.security.web_3.0.2.RELEASE.jar:na]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) [org.springframework.security.web_3.0.2.RELEASE.jar:na]
at com.softmodeler.windows.server.security.SoftmodelerWindowsPreAuthenticationProcessingFilter.doFilter(SoftmodelerWindowsPreAuthenticationProcessingFilter.java:52) [com.softmodeler.windows.server/:na]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) [org.springframework.security.web_3.0.2.RELEASE.jar:na]
at com.softmodeler.windows.server.security.NegotiateSecurityFilter.doFilter(NegotiateSecurityFilter.java:132) [com.softmodeler.windows.server/:na]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) [org.springframework.security.web_3.0.2.RELEASE.jar:na]
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79) [org.springframework.security.web_3.0.2.RELEASE.jar:na]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) [org.springframework.security.web_3.0.2.RELEASE.jar:na]
at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:109) [org.springframework.security.web_3.0.2.RELEASE.jar:na]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355) [org.springframework.security.web_3.0.2.RELEASE.jar:na]
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:149) [org.springframework.security.web_3.0.2.RELEASE.jar:na]
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237) [org.springframework.web_3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167) [org.springframework.web_3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1419) [org.eclipse.jetty.servlet_8.1.9.v20130131.jar:8.1.9.v20130131]
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455) [org.eclipse.jetty.servlet_8.1.9.v20130131.jar:8.1.9.v20130131]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137) [org.eclipse.jetty.server_8.1.9.v20130131.jar:8.1.9.v20130131]
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557) [org.eclipse.jetty.security_8.1.9.v20130131.jar:8.1.9.v20130131]
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231) [org.eclipse.jetty.server_8.1.9.v20130131.jar:8.1.9.v20130131]
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075) [org.eclipse.jetty.server_8.1.9.v20130131.jar:8.1.9.v20130131]
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384) [org.eclipse.jetty.servlet_8.1.9.v20130131.jar:8.1.9.v20130131]
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193) [org.eclipse.jetty.server_8.1.9.v20130131.jar:8.1.9.v20130131]
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009) [org.eclipse.jetty.server_8.1.9.v20130131.jar:8.1.9.v20130131]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135) [org.eclipse.jetty.server_8.1.9.v20130131.jar:8.1.9.v20130131]
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154) [org.eclipse.jetty.server_8.1.9.v20130131.jar:8.1.9.v20130131]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116) [org.eclipse.jetty.server_8.1.9.v20130131.jar:8.1.9.v20130131]
at org.eclipse.jetty.server.Server.handle(Server.java:368) [org.eclipse.jetty.server_8.1.9.v20130131.jar:8.1.9.v20130131]
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:488) [org.eclipse.jetty.server_8.1.9.v20130131.jar:8.1.9.v20130131]
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:932) [org.eclipse.jetty.server_8.1.9.v20130131.jar:8.1.9.v20130131]
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:994) [org.eclipse.jetty.server_8.1.9.v20130131.jar:8.1.9.v20130131]
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:640) [org.eclipse.jetty.http_8.1.9.v20130131.jar:8.1.9.v20130131]
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235) [org.eclipse.jetty.http_8.1.9.v20130131.jar:8.1.9.v20130131]
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82) [org.eclipse.jetty.server_8.1.9.v20130131.jar:8.1.9.v20130131]
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628) [org.eclipse.jetty.io_8.1.9.v20130131.jar:8.1.9.v20130131]
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52) [org.eclipse.jetty.io_8.1.9.v20130131.jar:8.1.9.v20130131]
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608) [org.eclipse.jetty.util_8.1.9.v20130131.jar:8.1.9.v20130131]
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543) [org.eclipse.jetty.util_8.1.9.v20130131.jar:8.1.9.v20130131]
at java.lang.Thread.run(Thread.java:722) [na:1.7.0_17]
The problem seems to occure because of the RepositoryEntry.data field which is a Blob and only if it contains content.
If I remove this line in test6(),
"entry.setData(session.getLobHelper().createBlob(content.getBytes()));"
no exception is thrown after lots of update/test7 calls.
Can somebody verify this as bug?
greets
Flavio