After successfully connecting to the MongoDB database, I'm receiving this exception when trying to go through a DBCursor :
Exception in thread "main" com.mongodb.MongoInternalException: couldn't get next element
at com.mongodb.DBCursor.hasNext(DBCursor.java:448)
Here is the code, the line with the while condition is the one raising the exception :
DBCollection upages = db.getCollection("upages");
DBCursor pageviewedbyuser = upages.find();
while (pageviewedbyuser.hasNext()) {
etc etc
}
When accessing the upages collection from the Mongo shell, it seems clear that it's not empty. The DBCursor seems to be successfully loaded because there is this line in the error log :
SEVERE: MyPort.error called
java.io.IOException: finished reading objects but still have: 19553 bytes to read!'
Has anybody run into this error before? Any idea?
Related
I have a java back-end web application that just started throwing an error after some sort of database update.
I've been able to isolate the code to a single line in which a Session variable is being flushed:
Session session=getSession();
session.saveOrUpdate(parm);
session.flush(); //This is where it errors
And it throws this error:
ERROR AbstractFlushingEventListener Could not synchronize database state with session
org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 1 actual row count: 0 expected: 1
The code hasn't changed in over a year; it just started throwing this error.
Any suggestions?
Thanks
This error usually caused when the hibernate can't find all the rows it needs to update. Meaning that when you try to update some objects that were pulled from the DB they don't really exist anymore (or never existed in the first place).
It might be because another thread is deleting them or that the DB's isolation mode is set to read_uncommited and so rows that were created by another transaction failed to save (due to a transaction failure) and don't exist anymore.
ref: https://stackoverflow.com/questions/21625059/org-hibernate-stalestateexception-batch-update-returned-unexpected-row-count-fr
I am getting a strange exception thrown every time I call CFSEARCH on my collection
Code:
<cfsearch
name="qCollectionSearch_docs"
collection="mydocuments"
criteria="#LCase(Trim(LOCAL.Criteria))#"
contextPassages="1"
contextHighlightBegin=""
contextHighlightEnd="" />
Exception:
Detail: Error executing query : Unexpected EOF; was expecting a close tag for element
Message: There was a problem while attempting to perform a search.
StackTrace: coldfusion.tagext.search.SearchTag$SearchProblemException: There was a problem while attempting to perform a search.
at coldfusion.tagext.search.SolrUtils.formatSearchResult(SolrUtils.java:2022)
at coldfusion.tagext.search.SolrUtils.getSearchResult(SolrUtils.java:2516)
at coldfusion.tagext.search.SearchTag.doSolrSearch(SearchTag.java:394)
at coldfusion.tagext.search.SearchTag.doSearch(SearchTag.java:243)
at coldfusion.tagext.search.SearchTag.doStartTag(SearchTag.java:185)
at coldfusion.runtime.CfJspPage._emptyTcfTag(CfJspPage.java:2991)
This code has worked without incident in the past, but suddenly started throwing this exception on every request.
The collection is built with the following code:
<cfindex
query="LOCAL.qDocuments"
collection="mydocuments"
action="refresh"
type="file"
key="DocumentFile"
custom1="SKU"
custom2="Status" />
...where LOCAL.qDocuments is a SQL query that retrieves the SKU and Status values from a database and DocumentFile is a path to a PDF document (i.e. C:\PDFs\document1.pdf).
The server is a virtual server running:
OS: Windows Server 2012 with all of the latest updates
IIS: 8.5
ColdFusion: 11 with all of the latest updates
Java: JRE 8 v111
I have tried restarting the ColdFusion 11 Application Server service and the ColdFusion 11 Add-on Services service, but this did not help.
Pass the value of the key, rather than the word 'documentFile':
<cfindex
key="#documentFile#"
/>
While working in a web application I have some issues with generating the excel sheet based on the result. This excel sheet data should be independent for each request. As of now I have implemented in the following way:
Created a xml file for excel configuration
spring-excel-views.xml
<bean id="excelView" class="com.test.service.excelService"
I have configure this xml in the servlet configuration file
<bean class="xmlReolver> //Mentioned clearly in the code but not here
<property name="location>
<value>bin/spring-excel-views.xml</value>
</property>
</bean>
Now I have controller class as well as an Utility class
UtiilityClass: computes the results and send back to the Controller
Controller: model.addAttribute("result", result); //Assuming result is coming for Utility class
Now in excelService.java coded as follows:
class ExcelService implements AbstractExcelView{
#overridden
protected void buildExcelDocument(Map model,HttpServletRequest req, HTTPServletResponse res){
Map m = model.getResults("results"); // Picking this from Controller
for(Map.Entry<Integer,String> entry: m.entrySet()){ -->Exception is throwing
//excel sheet logiic
}
//iteration logic ----> Exception thrown here
}
}
Here sometimes excel sheet is generating successfully and sometimes it is throwing Nullpointerexception before starting the iteration. Also this excel data is overriding with some other requests data. Displayed result is good but I'm having the problem with the excel sheet data.
Help me out to resolve this issue.
Exception Stack trace
Exception Report:
type Exception report
message Request processing failed; nested exception is java.lang.NullPointerException
description: The server encountered an internal error that prevented it from fulfilling this request.
exception:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.
org. springframework. web. servlet. FrameworkServlet . processRequest (FrarneworkServlet. java: 932)
org.springframework.web.servlet.FrameworkServlet.doGet(Frameworkservlet.java:816)
javax.servlet.http.HttpServlet.service (HttpServlet.java: 620)
org.springframework.web.servlet.FrameworkServlet.service (FrameworkServlet.java:801)
javax.servlet.http.Httpservlet.service(Httpservlet.java:727)
root cause
java.lang.NullPointerException
com. hello. services.ExcelService.buildExcelDocument (Excelservice.java:34)
org. springframework.web.servlet.view.document.AbstractExcelView.renderMergedoutputModel (AbstractE
org.springfranework.web.servlet.view.AbstractView.render (AbstractView.java:264)
org.springframework.web.servlet.DispatcherServlet.render (Dispatcherservlet.java: 1208)
org. springframework . web . serviet . DispatcherServlet . processDispatchResult (DispatcherServlet . java: 1208
org. springframework. web. servlet . DispatcherServlet . doDispatch (DispatcherServlet . java: 939)
org. springframework.web.servlet.DispatcherServlet.doService (DispatcherServlet.java:856)
org. springframework.web.servlet.FrameworkServlet.processRequest (FrameworkServlet.java: 920)
org. springframework.web.servlet.FrameworkServlet.doGet (FrameeworkServlet.java:816)
javax.servlet.http.Httpservlet.service(Httpservlet.java: 620)
org.springframework.web.servlet.FrameworkServlet.service (FraneworkServlet.java:801)
javax.servlet.http.HttpServlet.service(Httpservlet.java:727)
As you pointed out that exception is throwing in the below line
for(Map.Entry entry: m.entrySet()){ -->Exception is throwing
You are getting this exception because model.getResults("results") is returning null.Thus your m is assigned null and doing m.entrySet() this on null reference is throwing null pointer exception.
So you'll have to figure out why model.getResults("results") is returning null and fix it. If there can occur situation where there will be no excel sheet generated and model.getResults("results") will return nulll. Then you'll have to provide appropriate checking in your code.Below is a checking but it may not be sufficient as you may to handle some more stuffs.
if(m!=null){
for(Map.Entry<Integer,String> entry: m.entrySet()){ -->Exception is throwing
//excel sheet logiic
}
//iteration logic ----> Exception thrown here
}
Regarding you question about Thread safe it completely depends how you have designed your class and using it which is very difficult to answer just by looking at the few lines. However this may not be an issue of Thread safe.
I get a
org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException.
SQL state [51002]; error code [-805]; DB2 SQL Error: SQLCODE=-805, SQLSTATE=51002, SQLERRMC=NULLID.SYSLH203 0X5359534C564C3031, DRIVER=3.65.102; nested exception is com.ibm.db2.jcc.am.SqlException: DB2 SQL Error: SQLCODE=-805, SQLSTATE=51002, SQLERRMC=NULLID.SYSLH203 0X5359534C564C3031, DRIVER=3.65.102
for the following sql:
SELECT REF_TBL_ENTY_KEY, LTRIM(RTRIM(REF_TBL_ID)) AS REF_TBL_ID, LTRIM(RTRIM(COMP_ID1)) AS COMP_ID1, LTRIM(RTRIM(LOW_VAL1)) AS LOW_VAL1, LTRIM(RTRIM(HI_VAL1)) AS HI_VAL1, LTRIM(RTRIM(COMP_ID2)) AS COMP_ID2, LTRIM(RTRIM(LOW_VAL2)) AS LOW_VAL2, LTRIM(RTRIM(HI_VAL2)) AS HI_VAL2, LTRIM(RTRIM(COMP_ID3)) AS COMP_ID3, LTRIM(RTRIM(LOW_VAL3)) AS LOW_VAL3, LTRIM(RTRIM(HI_VAL3)) AS HI_VAL3, LTRIM(RTRIM(COMP_ID4)) AS COMP_ID4, LTRIM(RTRIM(LOW_VAL4)) AS LOW_VAL4, LTRIM(RTRIM(HI_VAL4)) AS HI_VAL4, LTRIM(RTRIM(COMP_ID5)) AS COMP_ID5, LTRIM(RTRIM(LOW_VAL5)) AS LOW_VAL5, LTRIM(RTRIM(HI_VAL5)) AS HI_VAL5, LTRIM(RTRIM(COMP_ID6)) AS COMP_ID6, LTRIM(RTRIM(LOW_VAL6)) AS LOW_VAL6, LTRIM(RTRIM(HI_VAL6)) AS HI_VAL6 FROM TBL_CODE WHERE DOM_NBR = ? AND REF_TBL_ID = ? AND EFF_DT <= ? AND END_DT >= ? AND LOW_VAL1 <= 'ABX' AND HI_VAL1 >= 'ABX' ORDER BY REF_TBL_ID, LOW_VAL1, HI_VAL1, LOW_VAL2, HI_VAL2, LOW_VAL3, HI_VAL3, LOW_VAL4, HI_VAL4, LOW_VAL5, HI_VAL5, LOW_VAL6, HI_VAL6, EFF_DT
I am using this sql in jdbcTemplate queryForList and am passing the required number of parameters. This error doesn't happen at all times.
This sql is being run as part of a long running batch job processing application. The application is single threaded. The application code DOES NOT open or close any connections explicitly.
I am using commons Dbcp(version 1.4) for connection pooling and spring JDBC(version 3.2.8) for data access. I have tried running it with BasicDataSource maxActive = 50 and maxActive=8(default for BasicDataSource) and I receive error in both cases.
In researching this issue I came accross this link from IBM website - http://www-01.ibm.com/support/docview.wss?rs=71&uid=swg21208123
The previous version of the application which used an in-house connection pooling framework and managed its own data access did not throw this exception. I want to make sure that the application code is fine before I request the DBA to create more packages on the server.
Any help will be greatly appreciated.
I'm having trouble understanding what is happening and why my loop doesn't continue. I'm creating a dashboard for all open activiti tasks. Now the trouble i am having is when someone closes a task while the dashboard is being created.
The code is like this:
List<Task> approvalTasks = taskQueryApproval.list();
for (Task task : approvalTasks) {
try {
ActivitiApplicationRequest activitiRequest = (ActivitiApplicationRequest) taskService
.getVariable(task.getId(), ACTIVITIREQUEST);
if (!dashboardValues.containsKey(activitiRequest.getGlobalRequestId())) {
GlobalRequest globalRequest = globalRequestDao
.findMinimalGlobalRequestForDashboardBySyscode(activitiRequest.getGlobalRequestId());
if (globalRequest != null) {
DashboardValueObject vo = new DashboardValueObject(globalRequest);
vo.setHasApproval(true);
dashboardValues.put(activitiRequest.getGlobalRequestId(), vo);
}
}
} catch (ActivitiException ex) {
LOGGER.debug("Approval already done, skipping activititask");
}
}
The trouble I'm having is I know when the task doesn't exist Activiti is going to throw an exception, that's why I placed a try-catch inside the for loop.
What I'm expecting is that when the error is catched it just continues with the rest of the list. While debugging I even saw the catch being done. But the loop still breaks and the application stops. With these exceptions :
SEVERE: Error while closing command context org.activiti.engine.ActivitiException: task 203039 doesn't exist
at org.activiti.engine.impl.cmd.GetTaskVariableCmd.execute(GetTaskVariableCmd.java:55)
at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:42)
9-nov-2012 14:45:42 org.activiti.engine.impl.interceptor.CommandContext close
SEVERE: Error while closing command context
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: com.atomikos.jdbc.AtomikosSQLException: The transaction has timed out - try increasing the timeout if needed
### The error may exist in org/activiti/db/mapping/entity/Task.xml
### The error may involve org.activiti.engine.impl.persistence.entity.TaskEntity.selectTask
### The error occurred while executing a query
### SQL: select * from ACT_RU_TASK where ID_ = ?
### Cause: com.atomikos.jdbc.AtomikosSQLException: The transaction has timed out - try increasing the timeout if needed
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:81)
What am I doing wrong?