Anyone knows what causes this error?
Been struggling with this issue since morning. This error just started and prevents fetching from the DB. After researching i found this link but he just says it was an OPTIMISTIC_LOCK and does not specify how to fix it. When i debug, i notice that i fetch some data then the error shows. The data is in the DB and i am struggling. Please assist: The link i found on internet is below: Transaction cannot proceed STATUS_MARKED_ROLLBACK when running on jboss standalone
11:32:39,036 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-38) SQL Error: 0,
SQLState: null
11:32:39,038 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-38) IJ031070:
Transaction cannot proceed: STATUS_MARKED_ROLLBACK
11:32:39,043 INFO [org.hibernate.event.internal.DefaultLoadEventListener] (default task-38)
HHH000327: Error performing load command : org.hibernate.exception.GenericJDBCException: could not
prepare statement
11:32:39,046 ERROR [org.jboss.as.ejb3.invocation] (default task-38) WFLYEJB0034: EJB Invocation
failed on component MyClassImpl for method public abstract com.service.api.entities.ClassDto com.service.api.MyClassApi.myMethod(com.service.api.entities.Dto,java.lang.Object,com.model.user,java.lang.String) throws com.service.api.exceptions.MyException: javax.ejb.EJBTransactionRolledbackException: org.hibernate.exception.GenericJDBCException: could not prepare statement
at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleInCallerTx(CMTTxInterceptor.java:159)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:256)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:329)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:239)
While you are debugging, transaction can lost connection because of timeout. In my situation, I removed the breakpoints before the transaction statement, the mentioned error has gone.
I've been tasked with finding a solution to a bug that we have been seeing for ~1.5 years off and on since Dec '17 but started happening WAY more in Dec '18. We are using Wildfly 10.1 Final. When I check the logs in Wildfly, I see this:
2019-05-05 00:19:32,980 ERROR [io.undertow.request] (default task-3)
UT005023: Exception handling request to /SMARxT-02.001/Usage/Create: >org.jboss.resteasy.spi.UnhandledException: RESTEASY00 3770: Response is committed, can't handle exception at
org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispa>tcher.java:174)
at
org.jboss.resteasy.core.SynchronousDispatcher.writeResponse(SynchronousDispat>cher.java:478)
at
org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.ja>va:422)
at
org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.ja>va:209)
at
org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(>ServletContainerDispatcher.java:221)
at
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpS>ervletDispatcher.java:56)
at
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpS>ervletDispatcher.java:51)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at
io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java>:85)
at
io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleReques>t(ServletSecurityRoleHandler.java:62)
at
io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletD>ispatchingHandler.java:36)
at
org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.han>dleRequest(SecurityContextAssociationHandler.java:78)
at
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.j>ava:43)
at
io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handle>Request(SSLInformationAssociationHandler.java:131)
at
io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handle>Request(ServletAuthenticationCallHandler.java:57)
at
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.j>ava:43)
at
io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(A>uthenticationConstraintHandler.java:53)
at
io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(Ab>stractConfidentialityHandler.java:46)
at
io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler>.handleRequest(ServletConfidentialityConstraintHandler.java:64)
at
io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handle>Request(ServletSecurityConstraintHandler.java:59)
at
io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(A>uthenticationMechanismsHandler.java:60)
at
io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handl>eRequest(CachedAuthenticatedSessionHandler.java:77)
at
io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(Notif>icationReceiverHandler.java:50)
at
io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handl>eRequest(AbstractSecurityContextAssociationHandler.java:43)
at
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.j>ava:43)
at
org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleReque>st(JACCContextIdHandler.java:61)
at
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.j>ava:43)
at
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.j>ava:43)
at
io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(Servlet>InitialHandler.java:292)
at
io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialH>andler.java:81)
at
io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandl>er.java:138)
at
io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandl>er.java:135)
at
io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(Servle>tRequestContextThreadSetupAction.java:48)
at
io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoa>derSetupAction.java:43)
at
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSet>upActionWrapper.java:44)
at
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSet>upActionWrapper.java:44)
at
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSet>upActionWrapper.java:44)
at
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSet>upActionWrapper.java:44)
at
io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSet>upActionWrapper.java:44)
at
io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletIni>tialHandler.java:272)
at
io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialH>andler.java:81)
at
io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletIni>tialHandler.java:104)
at
io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
at
io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:805)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:114>9)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:62>4)
at java.lang.Thread.run(Thread.java:748) : Caused by:
javax.json.JsonException: I/O error while closing JsonGenerator at
org.glassfish.json.JsonGeneratorImpl.close(JsonGeneratorImpl.java:587)
at org.glassfish.json.JsonWriterImpl.close(JsonWriterImpl.java:126) at
org.jboss.resteasy.plugins.providers.jsonp.JsonObjectProvider.writeTo(JsonObj>ectProvider.java:73)
at
org.jboss.resteasy.plugins.providers.jsonp.JsonObjectProvider.writeTo(JsonObj>ectProvider.java:25)
at
org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.writeTo>(AbstractWriterInterceptorContext.java:131)
at
org.jboss.resteasy.core.interception.ServerWriterInterceptorContext.writeTo(S>erverWriterInterceptorContext.java:60)
at
org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.proceed>(AbstractWriterInterceptorContext.java:120)
at
org.jboss.resteasy.security.doseta.DigitalSigningInterceptor.aroundWriteTo(Di>gitalSigningInterceptor.java:145)
at
org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.proceed>(AbstractWriterInterceptorContext.java:124)
at
org.jboss.resteasy.plugins.interceptors.encoding.GZIPEncodingInterceptor.arou>ndWriteTo(GZIPEncodingInterceptor.java:100)
at
org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.proceed>(AbstractWriterInterceptorContext.java:124)
at
org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse(ServerRespons>eWriter.java:98)
at
org.jboss.resteasy.core.SynchronousDispatcher.writeResponse(SynchronousDispat>cher.java:473)
... 45 more Caused by: java.nio.channels.ClosedChannelException at
io.undertow.server.protocol.framed.AbstractFramedStreamSinkChannel.safeToSend>(AbstractFramedStreamSinkChannel.java:458)
at
io.undertow.server.protocol.framed.AbstractFramedStreamSinkChannel.write(Abst>ractFramedStreamSinkChannel.java:412)
at org.xnio.channels.Channels.writeFinalBasic(Channels.java:961) at
io.undertow.server.protocol.framed.AbstractFramedStreamSinkChannel.writeFinal>(AbstractFramedStreamSinkChannel.java:475)
at
org.xnio.conduits.StreamSinkChannelWrappingConduit.writeFinal(StreamSinkChann>elWrappingConduit.java:66)
at
org.xnio.conduits.ConduitStreamSinkChannel.writeFinal(ConduitStreamSinkChanne>l.java:104)
at
io.undertow.channels.DetachableStreamSinkChannel.writeFinal(DetachableStreamS>inkChannel.java:195)
at
io.undertow.server.HttpServerExchange$WriteDispatchChannel.writeFinal(HttpSer>verExchange.java:2007)
at
io.undertow.servlet.spec.ServletOutputStreamImpl.writeBufferBlocking(ServletO>utputStreamImpl.java:561)
at
io.undertow.servlet.spec.ServletOutputStreamImpl.close(ServletOutputStreamImp>l.java:596)
at
org.jboss.resteasy.plugins.server.servlet.HttpServletResponseWrapper$Deferred>OutputStream.close(HttpServletResponseWrapper.java:58)
at
org.jboss.resteasy.util.CommitHeaderOutputStream.close(CommitHeaderOutputStre>am.java:87)
at sun.nio.cs.StreamEncoder.implClose(StreamEncoder.java:320) at
sun.nio.cs.StreamEncoder.close(StreamEncoder.java:149) at
java.io.OutputStreamWriter.close(OutputStreamWriter.java:233) at
org.glassfish.json.JsonGeneratorImpl.close(JsonGeneratorImpl.java:585)
... 57 more
If I understand this correctly, Wildfly is throwing an unhandled exception error due to the JsonGenerator not being closed properly, which is caused by a ClosedChannelException. I have attempted to correlate these timestamps with our logs from aws to see the network traffic and I cannot find a definitive pattern. Does anyone have any insight as to what/where I should be looking to further troubleshoot this? Apologies if I left anything out. Im still learning how wildfly works and I don't have admin rights but I should be able to provide any info that will help. Thanks!
Using c3p0 0.9.2.1, hibernate 4.2.21, JBoss AS 7.1.1 and connecting with Microsoft SQL Server 2014 - 12.0.2000.8 (X64).
mssql-jdbc 6.2.2 (I tested 6.4.0 for doubt but we are using 6.2.2) is used for JRE7 support.
Scenario
Retrieving data from a table as multiple rows but NOT at once. It's simply a loop and each time a row retrieved and finally they put in HashMap.
Problem & Output
After long investigation and debugging I found out that the problem scope related with two columns in the table. One is VARBINARY(MAX) called signature and the other is VARCHAR(1024) called status. If both of these columns have a value on a row, this exception occurs on retrieving the next row. If any of them is set to null, all is good. No matter the length of the value in them.
Tries so far
Changing the columns order making the VARCHARcolumn is the last cloumn
Changing the columns order making the VARBINARY column is the last cloumn
Changing the length (VARBINARY to 8000 and VARCHAR to 50)
Setting values on other columns with similar or larger length
Logging org.hibernate.session object methods isConnected() and isOpen() and until the exception is thrown, the output was always true for both
Questions
What does that exception means ? Specially that sql server logging doesn't show anything about it !!
Why it's happening and what might be the cause of this ?
18:53:12,294 SEVERE [com.microsoft.sqlserver.jdbc.internals.TDS.TOKEN]
(http-localhost-127.0.0.1-8080-6) ConnectionID:24 ClientConnectionId:
5bbf35a7-2a3c-4fb5-845a-bbd81d2739ef: getNextResult: Encountered
unexpected unknown token (0x1)
18:53:12,296 SEVERE [com.microsoft.sqlserver.jdbc.internals.TDS.Reader]
(http-localhost-127.0.0.1-8080-6) ConnectionID:24 ClientConnectionId:
5bbf35a7-2a3c-4fb5-845a-bbd81d2739ef got unexpected value in TDS
response at offset:1158
18:53:12,300 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) java.lang.reflect.InvocationTargetException
18:53:12,300 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
18:53:12,301 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
18:53:12,301 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
18:53:12,302 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at java.lang.reflect.Method.invoke(Unknown Source)
.
.
18:53:12,304 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
18:53:12,305 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
18:53:12,306 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
18:53:12,307 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
18:53:12,308 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
18:53:12,309 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
18:53:12,309 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
18:53:12,310 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
.
.
18:53:12,312 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
18:53:12,312 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
.
.
18:53:12,314 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
18:53:12,314 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
.
.
18:53:12,316 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
18:53:12,316 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
18:53:12,317 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:101)
18:53:12,318 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
18:53:12,318 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
18:53:12,319 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
18:53:12,320 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
18:53:12,320 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
18:53:12,321 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
18:53:12,322 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
18:53:12,322 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
18:53:12,323 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
18:53:12,324 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
18:53:12,325 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
18:53:12,326 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
18:53:12,327 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at java.lang.Thread.run(Unknown Source)
18:53:12,328 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) Caused by: org.hibernate.exception.GenericJDBCException: could not
extract ResultSet
18:53:12,329 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54)
18:53:12,330 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:124)
18:53:12,332 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:109)
18:53:12,333 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:88)
18:53:12,335 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.hibernate.loader.Loader.getResultSet(Loader.java:2062)
18:53:12,336 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1859)
18:53:12,337 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1838)
18:53:12,338 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.hibernate.loader.Loader.doQuery(Loader.java:906)
18:53:12,339 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:348)
18:53:12,340 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.hibernate.loader.Loader.doList(Loader.java:2550)
18:53:12,340 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.hibernate.loader.Loader.doList(Loader.java:2536)
18:53:12,341 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2366)
18:53:12,342 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.hibernate.loader.Loader.list(Loader.java:2361)
18:53:12,342 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:495)
18:53:12,343 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:357)
18:53:12,343 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:198)
18:53:12,344 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1230)
18:53:12,345 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101)
18:53:12,345 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.hibernate.internal.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:909)
.
.
18:53:12,350 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) ... 38 more
18:53:12,351 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The
connection is closed.
18:53:12,351 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:228)
18:53:12,352 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at com.microsoft.sqlserver.jdbc.SQLServerConnection.checkClosed(SQLServerConnection.java:1007)
18:53:12,353 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at com.microsoft.sqlserver.jdbc.SQLServerStatement.checkClosed(SQLServerStatement.java:1024)
18:53:12,353 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:198)
18:53:12,354 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(SQLServerPreparedStatement.java:401)
18:53:12,355 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:116)
18:53:12,355 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:79)
18:53:12,356 ERROR [stderr] (http-localhost-127.0.0.1-8080-6) ... 59 more
Beware that once you queried data, blob is retrieved as proxy with stream ready to read from it. You might want to check that you read (maybe as byte[]) data from it before closing the connection. Of course according to your situation, you seem to close the connection in someway at sometime which is not clear but reading the data to be in memory instead of holding just the proxy guarantees the safety of closing the session/connection wouldn't cause such problem for the proxy because data has been read already.
The cursor solution is beneficial in case of retrieving large amount of data and executing query before finishing all previous data retrieval and this is probably the issue here. So this is also considered another option without loading data eagerly in memory and avoiding proxy at all.
The following solved the retrieval problem and it showed at some submitting lines (inserting and flushing). It seems that retrieving data from the database to the driver is too much because VARBINARY maps to LOB in Java and being large objects opens stream which is not closed any time soon until another retrieval hits the database and driver which causes this issue. Here is the solution
What's solved the problem if retrieval the data is using cursor JDBC property. As Microsoft team on github cleared, the exception thrown directly from the JDBC driver and provided a sample code that is working, I've failed (until this moment) to replicate the issue.
Using cursor is simply adding selectMethod=cursor to the JDBC url. To fully understands what this option does and how it effects the retrieval of data specially LOB types kindly refer to this and this documentation and article.
From Microsoft documentation
selectMethod, String, ["direct" | "cursor"], default is direct
If this property is set to "cursor," a database cursor is created for
each query created on the connection for TYPE_FORWARD_ONLY and
CONCUR_READ_ONLY cursors. This property is typically required only if
the application generates large result sets that cannot be fully
contained in client memory. When this property is set to "cursor,"
only a limited number of result set rows are retained in client
memory.
The default behavior is that all result set rows are retained in
client memory. This behavior provides the fastest performance when the
application is processing all rows.
From the question and answer article
Some questions to consider:
Does the application use scrollable result sets, forward only result sets or some of both? If scrollable, do they fetch all of the
data or only scroll to and fetch some of the rows?
Are the result sets generated small or large? This includes number of rows and columns as well as the data contained there in(namely, are
there any LOBs)?
Is the application doing transactional work or only operating in auto commit mode?
Does the application ever have more than one result set open at a time on a single connection?
The answers to these questions should help decide which connection
parameter is best for the application. First off be aware that
eliminating the option from your connection URL altogether is that
same as setting the option to “direct” since “direct” is the default
setting.
Next, take a look at our description of this option from the JDBC
User’s Guide and Reference Manual. Here are some of the key points in
this description:
A hint to the driver that determines whether the driver requests a
database cursor for Select statements. Performance and behavior of the
driver are affected by this property, which is defined as a hint
because the driver may not always be able to satisfy the requested
method.
If set to direct (the default), the database server sends the complete
result set in a single response to the driver when responding to a
query. A server-side database cursor is not created if the requested
result set type is a forward-only result set. Typically, responses are
not cached by the driver. Using this method, the driver must process
the entire response to a query before another query is submitted. If
another query is submitted (using a different statement on the same
connection, for example), the driver caches the response to the first
query before submitting the second query. Typically, the direct method
performs better than the cursor method.
If set to cursor, a server-side cursor is requested. When returning
forward-only result sets, the rows are retrieved from the server in
blocks. The setFetchSize() method can be used to control the number of
rows that are retrieved for each request when forward-only result sets
are returned. Performance tests show that, when returning forward-only
result sets, the value of Statement.setFetchSize() significantly
impacts performance. There is no simple rule for determining the
setFetchSize() value that you should use. We recommend that you
experiment with different setFetchSize() values to determine which
value gives the best performance for your application. The cursor
method is useful for queries that produce a large amount of data,
particularly if multiple open result sets are used.
Consider this excerpt from the Performance Considerations section of
the User Guide and Reference Manual:
SelectMethod: In most cases, using server-side database cursors
impacts performance negatively. However, if the following variables
are true for the application, the best setting for this property is
cursor, which means use server-side database cursors:
Your application contains queries that retrieve large amounts of data.
Your application executes a SQL statement before processing or closing a previous large result set and does this multiple times.
Large result sets returned by your application use forward-only cursors.
I think it's a Hibernate varbinary colum encoding issue make changes as the following
Table has: ENGINE=InnoDB DEFAULT CHARSET=utf8;
Hibernate properties has:
<prop key="hibernate.connection.useUnicode">true</prop>
<prop key="hibernate.connection.characterEncoding">UTF-8</prop>
<prop key="hibernate.connection.charSet">UTF-8</prop>
https://www.experts-exchange.com/questions/28131390/Hibernate-varbinary-colum-encoding-issue.html
As you can see on https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc the MS-SQL JDBC Driver has separate versions for different JRE versions (the versions ending with .jre17, .jre11, .jre8, etc.)
I had this error when I had copy-n-pasted a gradle-dependency for the .jre7 version of the MS-SQL JDBC Driver into a JRE 17 project.
Once I changed the gradle dependency to the JRE 17 version, the error went away.
I use wildfly and have a problem with the output of the FILE log handler. It prints every line of an error of a stack trace with the full formatted form. Here it is a cutted example:
12:13:11,238 ERROR [stderr] (default task-48) org.apache.shiro.authc.UnknownAccountException: Realm [XXX.account.library.security.shiro.ClientApplicationRealm#14896aa1] was unable to find account data for the submitted AuthenticationToken [org.apache.shiro.authc.UsernamePasswordToken - XXX, rememberMe=false].
12:13:11,238 ERROR [stderr] (default task-48) at org.apache.shiro.authc.pam.ModularRealmAuthenticator.doSingleRealmAuthentication(ModularRealmAuthenticator.java:184)
12:13:11,238 ERROR [stderr] (default task-48) at org.apache.shiro.authc.pam.ModularRealmAuthenticator.doAuthenticate(ModularRealmAuthenticator.java:267)
12:13:11,238 ERROR [stderr] (default task-48) at org.apache.shiro.authc.AbstractAuthenticator.authenticate(AbstractAuthenticator.java:198)
12:13:11,238 ERROR [stderr] (default task-48) at org.apache.shiro.mgt.AuthenticatingSecurityManager.authenticate(AuthenticatingSecurityManager.java:106)
...
I just wanted to have the the line with "12:13:11,238 ERROR [stderr] (default task-48)" once at the beginning and every party of the stack trace beginning with "at" not as a new log line interpreted as a new log line.
I have an additional SMTP log handler and there is the same problem. So it sends an email for every line of the stack trace and not one email per error or exception.
Thanks in advance.
This looks a lot like someone has left something like the following in their code:
try {
// do something that throws an exception
} catch (SomeException e) {
e.printStackTrace();
}
I would be really surprised if this was in Apache Shiro code.
In general it's a good idea to use one of the many logging libraries around and report it like:
} catch (SomeException e) {
logger.error("Something failed", e);
}
In some cases if you're using a console appender or handler defined in a logging configuration within your deployment this may also cause this. The reason being is that WildFly wraps both System.out and System.err in a logger. This would result in the format you're seeing.
I have absolutely followed the google guide to the letters and the stormpath guide for integrating with google also to the letters
Now, a User can sign in successfully with Google, but Stormpath throws an exception on this line when attempting to retrieve a Stormpath Account object using the authorization code obtained from google;
ProviderAccountResult result = application.getAccount(request);
Here's the code snippet;
public static Account getAccount(String codeOrToken, AuthType authType){
try{
if(getDirectory() != null){
ProviderAccountRequest request = null;
switch(authType){
case AUTH_CODE:
request = Providers.GOOGLE.account().setCode(codeOrToken).build();
break;
case ACCESS_TOKEN:
request = Providers.GOOGLE.account().setAccessToken(codeOrToken).build();
break;
default:
break;
}
Application application = AuthUtil.getApplication();
ProviderAccountResult result = application.getAccount(request);
Account account = result.getAccount();
account.getCustomData().put("isNew", result.isNewAccount());
return account;
}
}catch(Exception ex){
ex.printStackTrace();
}
return null;
}
And here's the Exception StackTrace;
16:45:02,170 ERROR [stderr] (http-localhost-127.0.0.1-8080-5) com.stormpath.sdk.resource.ResourceException: HTTP 400, Stormpath 7200 (http://docs.stormpath.com/errors/7200): Stormpath was not able to complete the request to Google: this can be caused by either a bad Google directory configuration, or the provided account credentials are not valid. Google error message: 400 Bad Request
16:45:02,172 ERROR [stderr] (http-localhost-127.0.0.1-8080-5) at com.stormpath.sdk.impl.ds.DefaultDataStore.execute(DefaultDataStore.java:492)
16:45:02,173 ERROR [stderr] (http-localhost-127.0.0.1-8080-5) at com.stormpath.sdk.impl.ds.DefaultDataStore.access$000(DefaultDataStore.java:67)
16:45:02,174 ERROR [stderr] (http-localhost-127.0.0.1-8080-5) at com.stormpath.sdk.impl.ds.DefaultDataStore$2.filter(DefaultDataStore.java:390)
16:45:02,175 ERROR [stderr] (http-localhost-127.0.0.1-8080-5) at com.stormpath.sdk.impl.ds.DefaultFilterChain.filter(DefaultFilterChain.java:47)
16:45:02,176 ERROR [stderr] (http-localhost-127.0.0.1-8080-5) at com.stormpath.sdk.impl.ds.ProviderAccountResultFilter.filter(ProviderAccountResultFilter.java:31)
16:45:02,177 ERROR [stderr] (http-localhost-127.0.0.1-8080-5) at com.stormpath.sdk.impl.ds.DefaultFilterChain.filter(DefaultFilterChain.java:52)
16:45:02,178 ERROR [stderr] (http-localhost-127.0.0.1-8080-5) at com.stormpath.sdk.impl.ds.api.ApiKeyQueryFilter.filter(ApiKeyQueryFilter.java:74)
16:45:02,180 ERROR [stderr] (http-localhost-127.0.0.1-8080-5) at com.stormpath.sdk.impl.ds.DefaultFilterChain.filter(DefaultFilterChain.java:52)
16:45:02,181 ERROR [stderr] (http-localhost-127.0.0.1-8080-5) at com.stormpath.sdk.impl.ds.cache.WriteCacheFilter.filter(WriteCacheFilter.java:80)
16:45:02,184 ERROR [stderr] (http-localhost-127.0.0.1-8080-5) at com.stormpath.sdk.impl.ds.DefaultFilterChain.filter(DefaultFilterChain.java:52)
16:45:02,184 ERROR [stderr] (http-localhost-127.0.0.1-8080-5) at com.stormpath.sdk.impl.ds.cache.ReadCacheFilter.filter(ReadCacheFilter.java:62)
16:45:02,185 ERROR [stderr] (http-localhost-127.0.0.1-8080-5) at com.stormpath.sdk.impl.ds.DefaultFilterChain.filter(DefaultFilterChain.java:52)
16:45:02,186 ERROR [stderr] (http-localhost-127.0.0.1-8080-5) at com.stormpath.sdk.impl.ds.api.DecryptApiKeySecretFilter.filter(DecryptApiKeySecretFilter.java:62)
16:45:02,187 ERROR [stderr] (http-localhost-127.0.0.1-8080-5) at com.stormpath.sdk.impl.ds.DefaultFilterChain.filter(DefaultFilterChain.java:52)
16:45:02,188 ERROR [stderr] (http-localhost-127.0.0.1-8080-5) at com.stormpath.sdk.impl.ds.EnlistmentFilter.filter(EnlistmentFilter.java:42)
16:45:02,189 ERROR [stderr] (http-localhost-127.0.0.1-8080-5) at com.stormpath.sdk.impl.ds.DefaultFilterChain.filter(DefaultFilterChain.java:52)
16:45:02,189 ERROR [stderr] (http-localhost-127.0.0.1-8080-5) at com.stormpath.sdk.impl.ds.DefaultDataStore.save(DefaultDataStore.java:411)
16:45:02,190 ERROR [stderr] (http-localhost-127.0.0.1-8080-5) at com.stormpath.sdk.impl.ds.DefaultDataStore.create(DefaultDataStore.java:322)
16:45:02,191 ERROR [stderr] (http-localhost-127.0.0.1-8080-5) at com.stormpath.sdk.impl.provider.ProviderAccountResolver.resolveProviderAccount(ProviderAccountResolver.java:46)
16:45:02,192 ERROR [stderr] (http-localhost-127.0.0.1-8080-5) at com.stormpath.sdk.impl.application.DefaultApplication.getAccount(DefaultApplication.java:325)
16:45:02,193 ERROR [stderr] (http-localhost-127.0.0.1-8080-5) at ng.ajo.socials.Google.getAccount(Google.java:79)
16:45:02,193 ERROR [stderr] (http-localhost-127.0.0.1-8080-5) at ng.ajo.server.SocialsServlet.doPost(SocialsServlet.java:81)
//... The rest omitted for brevity
Please what could I be doing wrong and what could be the solution to this problem?
EDIT:
If this helps provide more context, here's how I create my Google Directory :
public class Google {
public static Directory getDirectory(){
try{
Directory directory = DirectoryUtil.getGoogleDirectory();
//if the google directory does not exist CREATE it
if(directory == null){
Client client = AuthUtil.getClient();
directory = client.instantiate(Directory.class);
directory.setName(dirName);
directory.setDescription(dirDescription);
CreateDirectoryRequest request = Directories.newCreateRequestFor(directory)
.forProvider(Providers.GOOGLE.builder()
.setClientId(appID)
.setClientSecret(appSecret)
.setRedirectUri(redirectURI)
.build()
).build();
Tenant tenant = client.getCurrentTenant();
directory = tenant.createDirectory(request);
Application application = AuthUtil.getApplication();
application.addAccountStore(directory.getHref());
}
return directory;
}catch(Exception ex){
ex.printStackTrace();
}
}
}
And when I login to my Stormpath web console I can see that the directory has been created and indeed exists with all the configs in place... now, this whole thing should work, yet it doesn't... still leaves me confused!
Go to https://console.developers.google.com/apis/credentials
Be sure you "Add Credentials"
Take note of "Client ID" and "Client secret"
Add some "Authorized redirect URIs" like http://localhost:8080/googleOauthCallback
Login at https://api.stormpath.com
Add a Google Directory providing the proper ID, Secret and Redirect URI
Now, let's obtain a Google code in a simple way (without having to create a web project). Open this URL in your browser; when prompted, select the Gmail account you want to use.
https://accounts.google.com/o/oauth2/auth?client_id=XXXXXXX
&response_type=code
&scope=openid%20email
&redirect_uri=http://localhost:8080/googleOauthCallback
Note: XXXXXXX must be replaced by the Client ID you obtained in step 3.
You will get a cannot connect to server error but this is OK as we are not running a Web Application where Google can call us back. The important thing here is in the URL. Just copy the code value. It will be something like 4/tcHrwq4N1eah1rwotyCEaXq-yfxBOYrIAVe2_ouHTMQ
This code will retrieve the Google Account via Stormpath:
Client client = Clients.builder().build();
Application application = client.getResource(applicationHref, Application.class);
ProviderAccountRequest request = Providers.GOOGLE.account()
.setCode(code) //where code is the value we obtained in step 8
.build();
ProviderAccountResult result = application.getAccount(request);
System.out.println("Account Email: " + result.getAccount().getEmail());
ProviderData providerData = result.getAccount().getProviderData();
System.out.println("Access Token: " + ((GoogleProviderData)providerData).getAccessToken());
That's all...