Zirui Wang
Zirui Wang

Reputation: 259

Should general entity classes be put under service or api module in Liferay 7.4?

I have a general entity class ProductFilter, which encloses the input parameters of a JSONWS POST end point. After building services, where should I put this class, under module api or module service?

First I put it under service, then an interface in api complained ProductFilter could not be found.

C:\Users\Zirui\projects\nongzi\code\nongzi-gradle2\modules\db\db-api\src\main\java\com\toptoken\core\service\ProductService.java:26: error: package com.toptoken.core.domain.page does not exist
import com.toptoken.core.domain.page.ProductFilter;
                                    ^

Then I put it under api, but deployment of service threw an exception that service could not find ProductFilter although service depends on api.

2023-08-22 08:13:26.489 ERROR [fileinstall-directory-watcher][DirectoryWatcher:1173] Unable to start bundle: file:/C:/Users/Zirui/projects/web3/test/gradle-wsdd/bundles/osgi/modules/com.toptoken.core.service-1.0.0.jar com.liferay.portal.kernel.log.LogSanitizerException: org.osgi.framework.BundleException: Could not resolve module: com.toptoken.core.service [1627]_ Unresolved requirement: Import-Package: com.toptoken.core.domain.page_ [Sanitized]

Then finally I put ProductFilter under both api and service, but deployment gave an error:

java.lang.LinkageError: loader constraint violation: loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @5c03e79e (instance of org.eclipse.osgi.internal.loader.EquinoxClassLoader, child of com.liferay.shielded.container.internal.ShieldedContainerClassLoader @3fc9dfc5 com.liferay.shielded.container.internal.ShieldedContainerClassLoader) wants to load class com.toptoken.core.domain.page.ProductFilter. A different class with the same name was previously loaded by org.eclipse.osgi.internal.loader.EquinoxClassLoader @38c9a210 (instance of org.eclipse.osgi.internal.loader.EquinoxClassLoader, child of com.liferay.shielded.container.internal.ShieldedContainerClassLoader @3fc9dfc5 com.liferay.shielded.container.internal.ShieldedContainerClassLoader).

Under which module, api or service, should I put ProductFilter?

Upvotes: 0

Views: 53

Answers (1)

Zirui Wang
Zirui Wang

Reputation: 259

As the request body of a POST endpoint, I have to use HashMap<String, Object>. No more general entity classes.

Upvotes: 0

Related Questions