Understanding Hibernate: JDBCExceptionReporter | Invalid parameter index - java

I am getting the following error when ever I try update particular information in a database, I have been looking online for a good bit now but I have been unable to find anywhere that explains what exactly the error is and what causes this error
2012-06-29 14:50:02,193 [project] ERROR [http-8080-2] JDBCExceptionReporter | Invalid parameter index 57.
2012-06-29 14:50:02,209 [project] ERROR [http-8080-2] AbstractFlushingEventListener | Could not synchronize database state with session
org.hibernate.exception.SQLGrammarException: could not update: [com.company.project.PSDBusinessAssociate#18962]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2360)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2242)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2542)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:92)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:655)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:709)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:678)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:321)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:116)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:635)
at com.fexco.wuams.service.dwr.BusinessAssociateFormService$$EnhancerByCGLIB$$cb75a250.updateBusinessAssociate(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:740)
at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:744)
at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:593)
at org.directwebremoting.dwrp.BaseCallHandler.handle(BaseCallHandler.java:90)
at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:120)
at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:141)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:265)
at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:124)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:149)
at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:212)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:818)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:624)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.sql.SQLException: Invalid parameter index 57.
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.getParameter(JtdsPreparedStatement.java:255)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.setParameter(JtdsPreparedStatement.java:326)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.setLong(JtdsPreparedStatement.java:509)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.setLong(NewProxyPreparedStatement.java:703)
at org.hibernate.type.LongType.set(LongType.java:42)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:83)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:60)
at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:78)
at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:1932)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2306)
... 57 more
this appears in my error output on screen
could not update: [com.company.project.dataobject.PSDBusinessAssociate#18962]; nested exception is org.hibernate.exception.SQLGrammarException: could not update: [com.company.project.dataobject.PSDBusinessAssociate#18962]
so my question is what exactly does this error mean and what causes this error to occur?

This looks like the SQL that hibernate is generating isn't valid. This can often mean that your mappings are incorrect (such as incorrect column/table names). A good way to debug SQL Grammer exceptions is to set hibernate.show_sql=true and hibernate.format_sql=true in your SessionFactory. Hibernate will output generated sql to the console for you to verify.

Have you tried rebuilding your database through a Hibernate command? (I know Netbeans allows you to do this, dunno if it runs an ant script behind the scenes...) and seeing if it works?
Maybe someone edited the database manually without you knowing (or you yourself!) and Hibernate finds a table structure different than it is expecting when accessing the database...

Related

Hibernate with sql server retrieving data Encountered unexpected unknown token

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.

error when merge using hibernate 3 and ojdbc 7 [duplicate]

This question already has answers here:
java.lang.ArrayIndexOutOfBoundsException at oracle.jdbc.driver.T4CTTIrxd.readBitVector(T4CTTIrxd.java:135)
(2 answers)
Closed 5 years ago.
I get an error when I save my entity using the merge() method from EntityManager. This issue happens when I use Hibernate 3 combined with ojdbc7 12.1.0.2.0 JDBC 4.1, but if I change to ojdbc6 11.2.0.3.0 JDBC 4.0 this error will disappear. Can anyone help to resolve my problem, because I need to use ojdbc7.
>[2017-03-30 14:52:42.184]: ERROR - TransactionAspectSupport.completeTransactionAfterThrowing(408) | Application exception overridden by rollback exception
org.springframework.orm.jpa.JpaSystemException: org.hibernate.exception.GenericJDBCException: could not load an entity: [com.mycomp.casa.persistence.model.CustomerAccountOpening#554]; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not load an entity: [com.mycomp.casa.persistence.model.CustomerAccountOpening#554]
at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:321)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:404)
at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:58)
at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:163)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622)
Caused by: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not load an entity: [com.mycomp.casa.persistence.model.CustomerAccountOpening#554]
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1214)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1147)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1153)
at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:695)
at sun.reflect.GeneratedMethodAccessor915.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240)
at com.sun.proxy.$Proxy104.merge(Unknown Source)
Caused by: org.hibernate.exception.GenericJDBCException: could not load an entity: [com.mycomp.casa.persistence.model.CustomerAccountOpening#554]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.loadEntity(Loader.java:2041)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:86)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:76)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3293)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:496)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:477)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:227)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:285)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:152)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1090)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1038)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:630)
at org.hibernate.type.EntityType.resolve(EntityType.java:438)
at org.hibernate.type.EntityType.replace(EntityType.java:298)
at org.hibernate.type.AbstractType.replace(AbstractType.java:176)
at org.hibernate.type.TypeHelper.replace(TypeHelper.java:212)
at org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:600)
at org.hibernate.event.def.DefaultMergeEventListener.mergeTransientEntity(DefaultMergeEventListener.java:337)
at org.hibernate.event.def.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:303)
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:258)
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:84)
at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:867)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:851)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:855)
at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:686)
... 143 more
Caused by: java.sql.SQLException: Error
at org.jboss.jca.adapters.jdbc.WrappedConnection.checkException(WrappedConnection.java:1972)
at org.jboss.jca.adapters.jdbc.WrappedStatement.checkException(WrappedStatement.java:1446)
at org.jboss.jca.adapters.jdbc.WrappedResultSet.checkException(WrappedResultSet.java:5986)
at org.jboss.jca.adapters.jdbc.WrappedResultSet.next(WrappedResultSet.java:2693)
at org.hibernate.loader.Loader.doQuery(Loader.java:825)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
at org.hibernate.loader.Loader.loadEntity(Loader.java:2037)
... 167 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 128
at oracle.jdbc.driver.T4CTTIrxd.readBitVector(T4CTTIrxd.java:135)
at oracle.jdbc.driver.T4C8TTIrxh.unmarshalV10(T4C8TTIrxh.java:123)
at oracle.jdbc.driver.T4C8Oall.readRXH(T4C8Oall.java:678)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:436)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:257)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:587)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:225)
at oracle.jdbc.driver.T4CPreparedStatement.fetch(T4CPreparedStatement.java:1066)
at oracle.jdbc.driver.OracleStatement.fetchMoreRows(OracleStatement.java:3716)
at oracle.jdbc.driver.InsensitiveScrollableResultSet.fetchMoreRows(InsensitiveScrollableResultSet.java:1015)
at oracle.jdbc.driver.InsensitiveScrollableResultSet.absoluteInternal(InsensitiveScrollableResultSet.java:979)
at oracle.jdbc.driver.InsensitiveScrollableResultSet.next(InsensitiveScrollableResultSet.java:579)
at org.jboss.jca.adapters.jdbc.WrappedResultSet.next(WrappedResultSet.java:2689)
... 170 more
Had the same problem using the 12.1.0.2 driver with an Oracle 10g database. It happens apparently when the driver is performing a fetch - querying the database for more rows while scrolling through a ResultSet.
Looks like a nasty bug in the driver as #MarkRotteveel pointed out in his comment.
Incrementing the fetchSize property worked well as a temporary workaround to avoid the issue, forcing the driver to retrieve all results at once with no data left to fetch, but it is not a long-term solution and may have a large negative impact on performance/memory depending on the size and amount of data the query is retrieving.
If you're using Hibernate, try to identify the query that is raising the exception (use for instance hibernate.show_sql), check how many rows does it return and adjust the hibernate.jdbc.fetch_size property accordingly.
A non-zero value determines the JDBC fetch size (calls Statement.setFetchSize()).
Or try using a different version of the driver. This exception didn't happen with 12.1.0.1 if I remember correctly.
If you are using Oracle 12c, try using Oracle12cDialect for the dialect.

Icefaces and Tomcat Crash

I have an application made with ICEfaces and ran on Tomcat 6. When I try to access one of the pages where I select users, if gives me this error. The weird thing is, after I get the error, I refresh the page, and it normally goes to where ever I needed it to go to.
Does anyone know what the error actually means, because the lines of code that are highlighted are closing of a DB connection, a comment line (weird lol), and some other syntax stuff that can't have errors in it.
exception
java.lang.RuntimeException: wrapped Exception: java.lang.NullPointerException
com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:156)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
com.icesoft.faces.webapp.xmlhttp.BlockingServlet.service(BlockingServlet.java:56)
root cause
java.lang.NullPointerException
crm.CRM_SA_enter.reload_Fees(CRM_SA_enter.java:3591)
crm.CRM_SA_enter.gradeEval(CRM_SA_enter.java:3844)
crm.CRM_SA_enter.apply_dropDown(CRM_SA_enter.java:3265)
crm.CRM_SA_enter.load_function2(CRM_SA_enter.java:2314)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.apache.el.parser.AstValue.invoke(AstValue.java:191)
org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
com.sun.faces.application.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
javax.faces.component.UICommand.broadcast(UICommand.java:380)
com.icesoft.faces.component.panelseries.UISeries$RowEvent.broadcast(UISeries.java:617)
com.icesoft.faces.component.panelseries.UISeries.broadcast(UISeries.java:285)
com.icesoft.faces.component.panelseries.UISeries$RowEvent.broadcast(UISeries.java:617)
com.icesoft.faces.component.panelseries.UISeries.broadcast(UISeries.java:285)
com.icesoft.faces.component.paneltabset.PanelTabSet.broadcast(PanelTabSet.java:320)
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475)
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:756)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
com.icesoft.faces.webapp.http.core.JsfLifecycleExecutor.apply(JsfLifecycleExecutor.java:18)
com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.renderCycle(ReceiveSendUpdates.java:132)
com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.service(ReceiveSendUpdates.java:74)
com.icesoft.faces.webapp.http.core.RequestVerifier.service(RequestVerifier.java:31)
com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer.service(PathDispatcherServer.java:24)
com.icesoft.faces.webapp.http.servlet.BasicAdaptingServlet.service(BasicAdaptingServlet.java:16)
com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:23)
com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:53)
com.icesoft.faces.webapp.http.servlet.SessionVerifier.service(SessionVerifier.java:26)
com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:23)
com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:131)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
com.icesoft.faces.webapp.xmlhttp.BlockingServlet.service(BlockingServlet.java:56)
crm.CRM_SA_enter.reload_Fees(CRM_SA_enter.java:3591)
Has the NPE. Doesn't look like IceFaces code at all, probably what you are building.

Exception in beginTransaction

I am using hibernate in my web application,when I am getting exception while:
Transaction tx=session.beginTransaction();
It gives exception once in a while, I am reloading SessionFactory while catching the exception and then it runs fine.
It is working when I am reloading the SessionFactory again.
This is my code snippet:
session = HibernateFactory.openSession(0);//Passing 0 uses the existing sessionFactory
if(session.isConnected() && session.isOpen() && session!=null)
{
try{
tx = session.beginTransaction();
logger.info("Transaction is begin successfully--Transaction is--"+tx);
}catch(Exception e){
logger.info("Could not start the transaction--Transaction is--"+tx);
session = HibernateFactory.openSession(1);//passing 1 is creating new //--SessionFactory
tx = session.beginTransaction();//now this runs fine
logger.info("Inside catch--Obtained session--"+session+"and transaction--"+tx);
e.printStackTrace();
logger.error("e.getCause(): "+e.getCause());
logger.error("e.getClass(): "+e.getClass());
// throw new HibernateException(e.getMessage());
}
}
This is the stackTrace of the exception I am getting.
org.hibernate.exception.JDBCConnectionException: Cannot open connection
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:74)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:426)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:119)
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326)
at com.arosys.hibernateDao.AbstractDao.startOperation(AbstractDao.java:184)
at com.arosys.hibernateDao.AbstractDao.findAll(AbstractDao.java:150)
at com.arosys.beansDao.JobHierarchyDao.findAll(JobHierarchyDao.java:20)
at org.ArosysLogin.server.GWTJobImpl.getJobHierarchy(GWTJobImpl.java:416)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:861)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1584)
at java.lang.Thread.run(Thread.java:662)
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
Last packet sent to the server was 0 ms ago.
Just guessing since there isn't enough information (type and message of the exception):
Connection fails due to flaky database/network connection
do you commit your transactions? I'm not sure, but Hibernate might complain if you try to start a transaction twice.
UPDATE based on the call stack.
This seems to be a problem with the database. check out the various results for googling "com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure"
This one might help: https://serverfault.com/questions/89955/unable-to-connect-to-mysql-through-jdbc-connector-through-tomcat-or-externally
Are you sure your connections get closed after usage? I can imagine the database denying access after so many connections are opened. Checking the logs of your database might help as well.
Set ValidateConnectionOnBorrow to true
and add a validation query for SQLForValidateConnection
Set autoReconnect to true for jdbc URL
either by Server connection pool configuration or connection pool configuration.
I assume(from the stack trace) that you are using MySQL,Hibernate with either JBoss or Tomcat.
Let me know in case you face any problem, I faced the same long ago.

Axis 2 generated code in "Expanded Mode"

I'm having some problems understanding how to send a request to a web service that I have deployed. I have followed the following tutorial:
http://wso2.org/library/1719
Which I have successfully applied, and it worked well. The tutorial was straightforward, and I have easily generated a web service client. All I did was creating "request" objects from the exposed web service method, set its arguments, and then using the web service stub, I have passed the request object to the exposed web service method, and got a response.
Now, I have received a WSDL file from which I'm supposed to build a web service client as well. The problem is that the generated files from the WSDL differ greatly from that of the tutorial I followed. I learned later on that when generating clients using ADB, there is a mode called "Expanded Mode" that generates " a class for each of the outer elements and the named complex types " (http://axis.apache.org/axis2/java/core/docs/adb/adb-howto.html#gen_modes). The problem is that I'm unable to understand how to create a request object and get a response from the web service from the generated classes. My best shot was as follows:
GetMfrInventoryProductItemsListE wrapper = new GetMfrInventoryProductItemsListE();
GetMfrInventoryProductItemsList request = new GetMfrInventoryProductItemsList();
request.setArg0(deviceId);
request.setArg1(macAddresses);
request.setArg2(mfrKey);
wrapper.setGetMfrInventoryProductItemsList(request);
GetMfrInventoryProductItemsListResponseE wrapperResponse = wmService.getMfrInventoryProductItemsList(wrapper);
GetMfrInventoryProductItemsListResponse response = wrapperResponse.getGetMfrInventoryProductItemsListResponse();
return response.get_return();
In the above code getGetMfrInventoryProductItemsList is the name of my exposed web service method, and wmService is my stub.
The result was the following stack Trace :
org.apache.axis2.AxisFault: Read timed out
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:197)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:404)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:231)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:443)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:406)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at wavemark.wmservice.soap.WMServiceStub.getMfrInventoryProductItemsList(WMServiceStub.java:3275)
at wavemark.linkserver.supplierconnect.controller.WsStub.getMfrInventoryProductItemsList(WsStub.java:107)
at wavemark.linkserver.supplierconnect.controller.WsManager.getProductItems(WsManager.java:384)
at wavemark.linkserver.supplierconnect.webservices.SupplierConnect.getProductItems(SupplierConnect.java:396)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:212)
at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:117)
at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:110)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:181)
at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:172)
at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:146)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read(BufferedInputStream.java:235)
at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:78)
at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:106)
at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1116)
at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.readLine(MultiThreadedHttpConnectionManager.java:1413)
at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1973)
at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735)
at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:621)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:193)
... 42 more
After trying to debug the problem, I have found out that this is the line that is throwing the exception:
GetMfrInventoryProductItemsListResponseE wrapperResponse = wmService.getMfrInventoryProductItemsList(wrapper);
I just want you guys to tell me if the way I'm using the request/response objects is correct.Your help is much appreciated.
Finally, I figured out how to solve the problem. Apparently the web service call that I was making, was taking a lot of time that it was timing out as the stack trace shows. So I added the following to my code to the section where I was instantiating my client stub:
wmService = new WMServiceStub();
Options options = new Options();
EndpointReference epr = new EndpointReference(url);
options.setTo(epr);
options.setProperty(HTTPConstants.SO_TIMEOUT, new Integer(300000));
wmService._getServiceClient().setOptions(options);
This results in increasing the Axis 2 web services' socket timeout to 5 minutes, which should be more than enough to most web service calls. I hope that this will be helpful for some developers out there.

Categories