掲示板

JSON Web Services not showing up

7年前 に Andrea Maschio によって更新されました。

JSON Web Services not showing up

New Member 投稿: 14 参加年月日: 16/07/27 最新の投稿
Since I'm trying to understand if this is a bug or something wrong by my side, I'm going to report here what I am doing with the goal to find a method published in the JSON Webservices of Liferay 7.

Here's what I did (I read the documentation, and I'm aware of how service builder works, but I'm new to Liferay development so bear with me if there is something obvious that I am missing (I hope there is)

- Setup a new project in Eclipse.

- New Liferay Workspace
- New Liferay Module (template service builder)
- Checked that the entity Foo has remote-service set to true
- Added a new public method to FooServiceImpl:


public String HelloWorld(String name){
		
		return "Hello, " + name;
	}


- Built service
- Checked that FooService has this method:

@AccessControlled
@JSONWebService
@OSGiBeanProperties(property =  {
	"json.web.service.context.name=foo", "json.web.service.context.path=Foo"}, service = FooService.class)
@ProviderType
@Transactional(isolation = Isolation.PORTAL, rollbackFor =  {
	PortalException.class, SystemException.class})
public interface FooService extends BaseService {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this interface directly. Always use {@link FooServiceUtil} to access the foo remote service. Add custom service methods to {@link com.officina.service.impl.FooServiceImpl} and rerun ServiceBuilder to automatically copy the method declarations to this interface.
	 */
	public java.lang.String HelloWorld(java.lang.String name);
}


At this point I deployed Myservice-api and Myservice-service and checked http://localhost:8080/api/jsonws.

I expected to see foo between the context names, which I didn't. I am probably missing something but I'm not sure what.

Can you help me understand why I can't see my method exposed in the JSON web services?

Thanks
thumbnail
7年前 に Juan Gonzalez によって更新されました。

RE: JSON Web Services not showing up

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
7年前 に Andrea Maschio によって更新されました。

RE: JSON Web Services not showing up

New Member 投稿: 14 参加年月日: 16/07/27 最新の投稿
Juan Gonzalez:
Can you try if this fixes the issue?:

https://web.liferay.com/community/forums/-/message_boards/message/78393499#_19_message_78393499



I can confirm that simply changing compileOnly to compile completely fixes my problem.

Thank you
7年前 に Robert Meissner によって更新されました。

RE: JSON Web Services not showing up

Junior Member 投稿: 76 参加年月日: 15/02/26 最新の投稿
yes, i can confirm. This seems to be necessary for the service-module only. The same works if the db-tables / sql scripts were not created / executed by liferay, but i couldn't find out, how the two are linked together in this process..
thumbnail
7年前 に Juan Gonzalez によって更新されました。

RE: JSON Web Services not showing up

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
Robert Meissner:
yes, i can confirm. This seems to be necessary for the service-module only. The same works if the db-tables / sql scripts were not created / executed by liferay, but i couldn't find out, how the two are linked together in this process..


It's linked as service module MANIFEST is created with some missing required parameters, which causes all service builder initialization process for your service to not be triggered (JSON endpoint creation as one of those).
7年前 に Andrea Maschio によって更新されました。

RE: JSON Web Services not showing up

New Member 投稿: 14 参加年月日: 16/07/27 最新の投稿
Juan Gonzalez:

It's linked as service module MANIFEST is created with some missing required parameters, which causes all service builder initialization process for your service to not be triggered (JSON endpoint creation as one of those).


Is it something that is going to be fixed at a tool level, or once updated to gradle v3 shouldn't happen anymore?
thumbnail
7年前 に Juan Gonzalez によって更新されました。

RE: JSON Web Services not showing up

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
Andrea Maschio:
Juan Gonzalez:

It's linked as service module MANIFEST is created with some missing required parameters, which causes all service builder initialization process for your service to not be triggered (JSON endpoint creation as one of those).


Is it something that is going to be fixed at a tool level, or once updated to gradle v3 shouldn't happen anymore?


Yes, for that to happen another version of liferay workspace plugin should be released. Liferay IDE team is aware of that and are preparing it.

In the meantime, just remember changing that file if you create another workspace from scratch.

Thanks ;-).
7年前 に Andrea Maschio によって更新されました。

RE: JSON Web Services not showing up

New Member 投稿: 14 参加年月日: 16/07/27 最新の投稿
Juan Gonzalez:

In the meantime, just remember changing that file if you create another workspace from scratch.

Thanks ;-).


I will remind it, since I am on a learning path it could happen very soon. Thanks to you! you saved my day (even if I lost one day to acknowledge it was a bug and not my fault emoticon )
thumbnail
7年前 に Juan Gonzalez によって更新されました。

RE: JSON Web Services not showing up

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
Andrea Maschio:
Juan Gonzalez:

In the meantime, just remember changing that file if you create another workspace from scratch.

Thanks ;-).


I will remind it, since I am on a learning path it could happen very soon. Thanks to you! you saved my day (even if I lost one day to acknowledge it was a bug and not my fault emoticon )


Very happy to save someone's day emoticon.

Yep, due to Liferay's complexity you are never sure if it is a misconfiguration issue, bad usage, or a bug.
thumbnail
7年前 に Juan Gonzalez によって更新されました。

RE: JSON Web Services not showing up

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
Andrea Maschio:
Juan Gonzalez:

It's linked as service module MANIFEST is created with some missing required parameters, which causes all service builder initialization process for your service to not be triggered (JSON endpoint creation as one of those).


Is it something that is going to be fixed at a tool level, or once updated to gradle v3 shouldn't happen anymore?


Andrea please read this for the final fix: https://web.liferay.com/community/forums/-/message_boards/message/78836905#_19_message_78836905
thumbnail
7年前 に Aristide Cittadino によって更新されました。

RE: JSON Web Services not showing up

New Member 投稿: 5 参加年月日: 13/10/16 最新の投稿
I had the same problem in my case was the blade client: I was trying to update the client using the command "blade update" but - i don't know why- it was pointing to an old repository.
Launching blade update with this command "sudo jpm install -f com.liferay.blade.cli" and recreating the worspace and portlet solved my problem.
7年前 に Evan Thomas によって更新されました。

RE: JSON Web Services not showing up

New Member 投稿: 3 参加年月日: 16/10/04 最新の投稿
Hello,

first post. I've working hard to learn LR but progress is slow.

I'm getting what seems to be the identical problem however using an updated plugin library does not fix it for me.

My setting.gradle

buildscript {
	dependencies {
		classpath group: "com.liferay", name: "com.liferay.gradle.plugins.workspace", version: "1.0.40"
	}

	repositories {
		maven {
			url "https://cdn.lfrs.sl/repository.liferay.com/nexus/content/groups/public"
		}
	}
}

apply plugin: "com.liferay.workspace"


My build.gradle for the service:
dependencies {
	compile group: "biz.aQute.bnd", name: "biz.aQute.bndlib", version: "3.1.0"
	compile group: "com.liferay", name: "com.liferay.osgi.util", version: "3.0.0"
	compile group: "com.liferay", name: "com.liferay.portal.spring.extender", version: "2.0.0"
	compile group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "2.6.0"
	compile project(":modules:members-choice:members-choice-api")
}

buildService {
	apiDir = "../members-choice-api/src/main/java"
	osgiModule = true
	propsUtil = "club.camberwellcamera.memberschoice.service.util.PropsUtil"
}


compile or compileOnly makes no difference.

The service class looks like this:

@AccessControlled
@JSONWebService
@OSGiBeanProperties(property =  {
	"json.web.service.context.name=memberschoice", "json.web.service.context.path=CompetitionEntry"}, service = CompetitionEntryService.class)
@ProviderType
@Transactional(isolation = Isolation.PORTAL, rollbackFor =  {
	PortalException.class, SystemException.class})
public interface CompetitionEntryService extends BaseService {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this interface directly. Always use {@link CompetitionEntryServiceUtil} to access the Competition Entry remote service. Add custom service methods to {@link club.camberwellcamera.memberschoice.service.impl.CompetitionEntryServiceImpl} and rerun ServiceBuilder to automatically copy the method declarations to this interface.
	 */
	@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
	public java.lang.String getDuck();

	/**
	* Returns the OSGi service identifier.
	*
	* @return the OSGi service identifier
	*/
	public java.lang.String getOSGiServiceIdentifier();

	public java.lang.String greetDuck(java.lang.String with);
}


and the Impl like this:
@JSONWebService
@ProviderType
public class CompetitionEntryServiceImpl extends CompetitionEntryServiceBaseImpl {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never reference this class directly. 
	 * Always use {@link club.camberwellcamera.memberschoice.service.CompetitionEntryServiceUtil}
	 *  to access the competition entry remote service.
	 */
	
	public String greetDuck(String with) {
		return "duck " + with;
	}
	
	public String getDuck() {
		return "duck";
	}
}


Here is the relevant bit of service.xml

	<entity local-service="true" name="CompetitionEntry" remote-service="true" uuid="true" trash-enabled="true" human-name="Competition Entry" table="CompetitionEntry">

		<!-- PK fields -->

		<column name="competitionEntryId" primary="true" type="long" />

		<!-- Audit fields -->

		<column name="competitionId" type="long" />
		<column name="title" type="String" />
		<column name="memberNumber" type="long" />
		<column name="createDate" type="Date" />
		<column name="modifiedDate" type="Date" />

		<!-- Order -->
        <column name="image" type="Blob"></column>
        <column name="userId" type="long"></column>

		<order by="asc">
			<order-column name="competitionEntryId" />
		</order>

		<!-- Finder methods -->

		<finder name="title" return-type="Collection">
			<finder-column name="title" />
		</finder>

	</entity>