• sdk4j exception

  • Do you want to create a native client or integrate with third party applications: webservices are the solution.
Do you want to create a native client or integrate with third party applications: webservices are the solution.
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.
 #28903  by aramesh
 
I am using sdk4j in my java web application.

when creating a document I get an exception of
type com.openkm.sdk4j.exception.UnknowException
with the folder as the message string (e.g "/okm:root/Documents/")

How can I find out what exactly happened.
I am looking for some message such as "Folder not found", "cannot overwrite" etc.

Thanks
-Anthony
 #28905  by jllort
 
The unknown exception should only appear in strange cases. The errors in rest goes into rest response and we save there from openkm side, but not always are set in openkm side, this are unexpected exceptions and we throw as UnknowException

Can you share with us the code you're using to import a document. And if your path exist or not, and if the user connected has or not privileges for doing this kind of actions. Also in catalina.log is shown any error message ?
 #28910  by aramesh
 
Using the sdk4j the following is the code I am using to save a document
where the function is returning the UUID of the created document.
The error situation is that the document with that name already exists.
Therefore this code works the first time around and not the second for the same value for "relPath"
Code: Select all
	public String saveDocumentTemplate(String documentContents, relPath) throws Exception {
		Document doc = new Document();
		doc.setAuthor("MyName");
		doc.setConvertibleToPdf(true);
		doc.setLocked(false);
		doc.setMimeType("text/html");
		doc.setPath("/okm:root/Documents/" + relPath);
		InputStream is = IOUtils.toInputStream(documentContents);

				return ws.createDocument(doc, is).getUuid();
			} catch (IOException | UnsupportedMimeTypeException
					| FileSizeExceededException | UserQuotaExceededException
					| VirusDetectedException | ItemExistsException
					| PathNotFoundException | AccessDeniedException
					| RepositoryException | DatabaseException
					| ExtensionException | AutomationException
					| UnknowException | WebserviceException e) {
				throw e;
			}
	}
This can throw any of multiple exceptions but I am getting only UnknownException, when I am expecting ItemExistsException

Excerpt from client side log
Code: Select all
com.openkm.sdk4j.exception.UnknowException  /okm:root/Documents/toSaveDoc.html
com.atlanticus.adms.DMS.AdmsException: Unable to save document
	at com.n2ms.OpenKMFacade.saveDocumentTemplate(OpenKMService.java:84)
	at com.n2ms.OpenKMServiceITest.testSaveDocumentTemplate(OpenKMServiceITest.java:39)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
	at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
	at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: com.openkm.sdk4j.exception.UnknowException:  /okm:root/Documents/fortiva/templates/creditAgreement/revolving.html
	at com.openkm.sdk4j.impl.DocumentImpl.createDocument(DocumentImpl.java:149)
	at com.openkm.sdk4j.OKMWebservice10.createDocument(OKMWebservice10.java:216)
	at com.atlanticus.adms.DMS.OpenKMService.saveDocumentTemplate(OpenKMService.java:76)
	... 30 more

Log Messages from server-side (OpenKM WebApp) - Catalina.log
Code: Select all
2014-06-10 13:00:00,122 [Thread-773] INFO  com.openkm.core.UserMailImporter - *** User mail importer activated ***
2014-06-10 13:30:00,083 [Thread-792] INFO  com.openkm.core.UserMailImporter - *** User mail importer activated ***
2014-06-10 14:00:00,060 [Thread-812] INFO  com.openkm.core.UserMailImporter - *** User mail importer activated ***
2014-06-10 14:20:01,933 [http-bio-0.0.0.0-8080-exec-7] WARN  org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper - WebApplicatio
nException has been caught :  /okm:root/Documents/toSaveDoc.html
2014-06-10 14:30:00,060 [Thread-831] INFO  com.openkm.core.UserMailImporter - *** User mail importer activated ***
2014-06-10 14:34:56,971 [http-bio-0.0.0.0-8080-exec-3] WARN  org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper - WebApplicatio
nException has been caught : /okm:root/Documents/toSaveDoc.html
Tomcat Access Log
Code: Select all
127.0.0.1 - - [10/Jun/2014:14:20:02 -0400] "POST /OpenKM/services/rest/document/create HTTP/1.1" 500 71
127.0.0.1 - - [10/Jun/2014:14:34:56 -0400] "POST /OpenKM/services/rest/document/create HTTP/1.1" 500 71
 #28931  by jllort
 
I've been testing with:
Code: Select all
try {
	OKMWebservices ws = OKMWebservicesFactory.newInstance("http://localhost:8080/OpenKM", "okmAdmin", "admin");
	InputStream is = new FileInputStream("/home/jllort/Escritorio/css_patch.txt");
	System.out.println(ws.createDocumentSimple("/okm:root/css_patch.txt", is).toString());
	System.out.println(ws.createDocumentSimple("/okm:root/css_patch.txt", is).toString());
	is.close();
} catch (ItemExistsException e) {
    System.out.println("correct");
	e.printStackTrace();
} catch (Exception e) {
	e.printStackTrace();
} 
And for me is going right.

I suggest use createSimple is not necessary create a document and fill all values, really only docPath will be used on document creation, the others initialized variables by you will take no effect.

Give me your feedback, in your source code I do not see anything wrong. But you get error 500 in your tomcat log, what I'm not getting. I've done the test with more newer version than 6.3 community confirm to me that you're continue getting the same problems and I will test in this version ( althought this part of source code is very similar or equal ).

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.