• NullPointerException using OKMDocument move

  • We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #28377  by matt81
 
Hi,
From a workflow I am trying to move a document in Openkm, using the following code:
OKMDocument.getInstance().move(token, "/okm:root/bla", "/okm:root/da");

However i am getting the following error:
Code: Select all
ERROR com.openkm.servlet.frontend.WorkflowServlet - 
com.openkm.core.WorkflowException
	at com.openkm.module.common.CommonWorkflowModule.runProcessDefinition(CommonWorkflowModule.java:286)
Caused by: java.lang.NullPointerException
	at com.openkm.module.db.DbDocumentModule.move(DbDocumentModule.java:1056)
	at com.openkm.api.OKMDocument.move(OKMDocument.java:292)
	at com.openkm.workflow.assignment.ConvertDoc.assign(ConvertDoc.java:118)
	at org.jbpm.taskmgmt.exe.TaskMgmtInstance.performAssignmentDelegation(TaskMgmtInstance.java:320)
	at org.jbpm.taskmgmt.exe.TaskMgmtInstance.performAssignment(TaskMgmtInstance.java:274)
Do you know what the problem could be.

Thanks
 #28423  by matt81
 
Well that's the line where it is throwing the error, prior to that I am just parsing strings and converting it to PDF like the following code:
Code: Select all
pathName = extFile.substring(0, slashName);
DocumentServlet cm = new DocumentServlet();
cm.convertToPdf(openkmPath);
Please note if I place the code in try catch, the error code is not thrown but I just need to know why this is happening.

Thanks
 #28461  by matt81
 
OK here it is:
Code: Select all
public void assign(Assignable arg0, ExecutionContext exec) throws Exception {
		
		//Get UUID, token and nodepath
		String uuid = (String) exec.getContextInstance().getVariable("uuid");
		String token = exec.getToken().toString();
		String openkmPath = OKMRepository.getInstance().getNodePath(token, uuid);

//convert to PDF in openkm
		DocumentServlet cm = new DocumentServlet();
		cm.convertToPdf(openkmPath);

DocumentModule dr = ModuleManager.getDocumentModule();
			dr.move(token, pathName + "/" + deleteFile, "/okm:trash");

//move to next task node automatically
		exec.getToken().signal();
}
Please let me know.
 #28479  by jllort
 
A lot of strange things here:
Use servlet for conversion seems not good idea, why you do not use DocConverter.java class ?
What's is the pathName and deleteFile values ? I've not seen initialized anyware ?
If you want to delete a file should use OKMDocument.getInstance(token, pathFile to delete), should be deleted in user trash. Or if you want to store always in some place the idea should be create a folder called /okm:trash/workflow but not move files to /okm:trash, that seems not good idea.
 #28487  by matt81
 
Thanks for the reply.
Well why would you say strange, it does the job.
I have tried all the other classes and I cannot achieve what I need. With DocConverter.java if I use the following two methods, I have to supply them with a FILE paramenter. How can I pass a File parameter when the file is located within openkm itself, I can only pass a string, hence why I cannot use them.
Code: Select all
DocConverter.getInstance().convert(File arg0, mimetype, File arg2);
DocConverter.getInstance().doc2pdf(File arg0, mimetype, File arg2);
I have tried to delete a file using the following code as well, as you suggested previously but it gave me the same error "Null pointer exception", and also a pop up sating that you cannot delete documents from workflows, hence why I used the move function to the trash folder.
Code: Select all
DocConverter.getInstance().delete(token, path);
The pathName and deleteFile values are initialised I just forgot to include them, so that's all good.
Everything has been tried hence why that solution works for me, aprt fromt he fact that it throws an error if it's not in try and catch block.

Thanks

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.