REST -> application/json -> No message body writer has been found for response class FolderList.

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.
flip
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: Wed Oct 21, 2015 9:21 am

REST -> application/json -> No message body writer has been found for response class FolderList.

Post by flip » Wed Oct 21, 2015 9:32 am

Whenever I try to make a REST request without a specified "accept" header, I get XML as result.
However, when I set the "accept" header to "application/json" I get 500 Server Error and "No message body writer has been found for response class FolderList."

Steps to reproduce:
-> download newest OpenKM Community Version (6.3.1)
-> start, add few documents and folders
-> http://localhost:8080/OpenKM/services/r ... xxxxxxxxxx
-> add header "accept: application/json"

Is there any workaround or am I doing something wrong?

sochoa
Junior Boarder
Junior Boarder
Posts: 30
Joined: Thu May 02, 2013 3:26 am

Re: REST -> application/json -> No message body writer has been found for response class FolderList.

Post by sochoa » Wed Oct 21, 2015 7:27 pm

I advise you to use the SDK became increasingly SDK method is exemplified

NEW SDK VERSIONS FOR JAVA, PHP AND .NET RELEASED

More information about SDK for Java.
http://docs.openkm.com/kcenter/view/sdk4j/

More information about SDK for PHP.
http://docs.openkm.com/kcenter/view/sdk4php/

More information about SDK for .NET.
http://docs.openkm.com/kcenter/view/sdk4net/

but will review the issue because no returns JSON

Greetings

jllort
Moderator
Moderator
Posts: 9590
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: REST -> application/json -> No message body writer has been found for response class FolderList.

Post by jllort » Thu Oct 22, 2015 5:47 pm

As sochoa suggested to you we encourage using one of the SDK.

However you can check with curl command line

Code: Select all

$ curl -u okmAdmin:admin -H "Accept: application/json" \
   http://localhost:8080/OpenKM/services/rest/folder/getChildren?fldId=3492d662-b58e-417c-85b6-930ad0c6c3cf

Catscratch
Platinum Boarder
Platinum Boarder
Posts: 329
Joined: Wed Feb 16, 2011 10:35 am

Re: REST -> application/json -> No message body writer has been found for response class FolderList.

Post by Catscratch » Wed Nov 11, 2015 7:58 am

Edit: I solved the problem. Indeed it was a CXF dependency problem. I documented the solution in JIRA:
http://jira.openkm.com/browse/OCM-6
Would be nice if you can modify community sources as described.

- old post -
Hi,

using SDK is not a solution. Because SDK is only available for Java and PHP. I got the same problem when trying to communicate via Javascript. Seems you forgot some annotations in the code or an own object wrapper for JSON. Thats a common issue when you try to return a whole own object (like FolderList) instead of some primitive objects like Map or List.

Here is the backend log:

Code: Select all

2015-11-10 16:59:02,350 [http-bio-0.0.0.0-18080-exec-175] WARN  org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor- No message body writer has been found for response class FolderList.
Besides, it's the same for every own object you return. Like (folder, document, ...):

Code: Select all

2015-11-10 16:55:04,825 [http-bio-0.0.0.0-18080-exec-131] WARN  org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor- No message body writer has been found for response class Folder.
My OpenKM installation:
- OpenKM Community 6.3.1 on Tomcat 7, Debian x64, 8GB RAM, Postgresql, LDAP, Only https

jllort
Moderator
Moderator
Posts: 9590
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: REST -> application/json -> No message body writer has been found for response class FolderList.

Post by jllort » Fri Nov 13, 2015 7:21 am

Thanks, usually us we're using XML an we had not detected it. As soon as possible we will solve it on source code.

pavila
Moderator
Moderator
Posts: 3031
Joined: Tue Dec 11, 2007 6:02 pm
Location: Alicante, Spain
Contact:

Re: REST -> application/json -> No message body writer has been found for response class FolderList.

Post by pavila » Tue Dec 29, 2015 10:19 am

Does this command line work without the modification?

Code: Select all

curl -u okmAdmin:admin -H "Accept: application/json" http://localhost:8080/OpenKM/services/rest/test/getComplex

Catscratch
Platinum Boarder
Platinum Boarder
Posts: 329
Joined: Wed Feb 16, 2011 10:35 am

Re: REST -> application/json -> No message body writer has been found for response class FolderList.

Post by Catscratch » Mon Jan 18, 2016 11:04 am

This is working.

Answer:
{
"author": "Kiko",
"date": "2016-01-18T12:04:16.072+01:00",
"path": "/one/path",
"text": "Test content message"
}
My OpenKM installation:
- OpenKM Community 6.3.1 on Tomcat 7, Debian x64, 8GB RAM, Postgresql, LDAP, Only https

pavila
Moderator
Moderator
Posts: 3031
Joined: Tue Dec 11, 2007 6:02 pm
Location: Alicante, Spain
Contact:

Re: REST -> application/json -> No message body writer has been found for response class FolderList.

Post by pavila » Wed Jan 27, 2016 6:35 pm

Wonderful :)

Petr_Valenta
Senior Boarder
Senior Boarder
Posts: 45
Joined: Mon Mar 06, 2017 9:10 am

Re: REST -> application/json -> No message body writer has been found for response class FolderList.

Post by Petr_Valenta » Mon Mar 06, 2017 9:22 am

Hello

I have downloaded a Development environment Openkm-6.3-community-portable-dev-1.0 (Windows) on 1.3.2017.

I face the same problem with OpenKM/services/rest/document/createSimple. When I create a document, I receive a message mentioned here.

But I have the same problem with OpenKM/services/rest/test/getComplex. It ends up with the same message.

If I use XML, it seems ok. But I need a json.

Could you hlep me please?

Thanks a lot in advance

jllort
Moderator
Moderator
Posts: 9590
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: REST -> application/json -> No message body writer has been found for response class FolderList.

Post by jllort » Wed Mar 08, 2017 7:38 pm

Take a look here:
https://docs.openkm.com/kcenter/view/sd ... #Jarsample

If when you execute from eclipse will going right, but when you exeucte a jar fails, then probably you have a wrong pom.xml ( it's a problem while creating jar file, exists two dependences with same file name, and the files by default are not merging, are overwritten, the sample pom.xml in the documentation solves it ).

Petr_Valenta
Senior Boarder
Senior Boarder
Posts: 45
Joined: Mon Mar 06, 2017 9:10 am

Re: REST -> application/json -> No message body writer has been found for response class FolderList.

Post by Petr_Valenta » Thu Mar 09, 2017 3:56 am

Hello

Thank you very much for your answer.

But there is no construction in the pom.xml distributed within "Openkm-6.3-community-portable-dev-1.0 (Windows)" using "maven-assembly-plugin" or "maven-shade-plugin" (as mentioned in the link above). Should I add it into pom.xml? If yes - where?

As for pom.xml - it is unchanged version, I'm using your pom.xml. And it does not look like having any problem. The result seems functional except for the problem described here.

Any suggestion what to to do next?

jllort
Moderator
Moderator
Posts: 9590
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: REST -> application/json -> No message body writer has been found for response class FolderList.

Post by jllort » Thu Mar 09, 2017 9:46 pm

You are using REST outside OpenKM has not sense using REST webservices from OpenKM.war file, from OpenKM.war you must use the API ( https://docs.openkm.com/kcenter/view/ok ... ption.html ). Portable edition comes with several project, one is the build of OpenKM source code where has not sense using from there the webservices.

Petr_Valenta
Senior Boarder
Senior Boarder
Posts: 45
Joined: Mon Mar 06, 2017 9:10 am

Re: REST -> application/json -> No message body writer has been found for response class FolderList.

Post by Petr_Valenta » Fri Mar 10, 2017 3:28 am

Hello

I'm afraid we don't understand each other.

I have 3rd party application on the customer's site and I need to communicate from it with OpenKM by REST. And I need to extend services by my own.

I have built OpenKM by means of Openkm-6.3-community-portable-dev-1.0 (Windows). When I test both original and custom services with application/xml, they work with no problem. But when I use application/json (which is the required way), both sets of services fail.

What do I need to change in your sources to be able to communicate by application/json?

jllort
Moderator
Moderator
Posts: 9590
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: REST -> application/json -> No message body writer has been found for response class FolderList.

Post by jllort » Fri Mar 10, 2017 7:41 am

It fails only in creation document or in any method ?
About the remote application, how are you creating the client ( it's a war application and you are creating from there, or you are creating a third-party-application -> man-in-the-middle -> what does it ? )

Petr_Valenta
Senior Boarder
Senior Boarder
Posts: 45
Joined: Mon Mar 06, 2017 9:10 am

Re: REST -> application/json -> No message body writer has been found for response class FolderList.

Post by Petr_Valenta » Fri Mar 10, 2017 8:10 am

There is failing the return of creating a document - from both the original service and from my custom service. The document itself is created in both cases, but the final status of the call is an error.

The third party application is assembling a JSON request "manually" and sends it through a middleware network layer to OpenKM.

As for other commands

curl -u okmAdmin:admin -H "Accept: application/json" -X POST -H "Content-Type: application/json" -d '/okm:root/newfolder' http://localhost:8080/OpenKM/services/r ... eateSimple --> RepositoryException: Invalid path: '/okm:root/newfolder'
This is not working for any tested path.

curl -u okmAdmin:admin -H "Accept: application/json" -X GET http://localhost:8080/OpenKM/services/r ... word=santo
No message body writer has been found for response class QueryResultList.

curl -u okmAdmin:admin -H "Accept: application/json" http://localhost:8080/OpenKM/services/r ... 85fdf6330a
No message body writer has been found for response class FolderList.

I did not test every service but it looks like a problem across all of them.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest