掲示板

Using @Reference (of OSGI) in portlet class

thumbnail
7年前 に Sravan Kumar Chalvadi によって更新されました。

Using @Reference (of OSGI) in portlet class

New Member 投稿: 22 参加年月日: 16/01/13 最新の投稿
Hi,

Using LR7 service builder, I have created remote services and for accessing I have used @Reference to a field in portlet class.
- Initially error was shown in class saying "The annotation @Reference is disallowed for this location". To fix it, I have removed "compile group: "org.osgi", name: "org.osgi.compendium", version: "5.0.0"" from build.gradle and added "compile group: "org.osgi", name: "org.osgi.service.component.annotations", version: "1.3.0"". It fixed the error.
-After deploying it to server, my portlet (i.e., web portlet) is not shown in "Applications" section to add it page. Am I missing something?

Note: If @Reference is removed for field, then portlet shows up in "Applications" section

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

RE: Using @Reference (of OSGI) in portlet class

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

RE: Using @Reference (of OSGI) in portlet class

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
BTW probably that reference isn't available too. Are you sure those services are available when that portlet is deployed?
thumbnail
7年前 に Sravan Kumar Chalvadi によって更新されました。

RE: Using @Reference (of OSGI) in portlet class

New Member 投稿: 22 参加年月日: 16/01/13 最新の投稿
Yes! services are deployed and available for portlet. (Checked under "App Manager" section on portal, they are active).
As per your suggestion, I have changed "compile" to "provided" then performed gradle refresh. Now I see below gradle build issue.

添付ファイル:

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

RE: Using @Reference (of OSGI) in portlet class

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
Pasting screenshots for error traces is probably one of the worst things to do.

Can you attach your gradle file?

Thanks.
thumbnail
7年前 に Sravan Kumar Chalvadi によって更新されました。

RE: Using @Reference (of OSGI) in portlet class

New Member 投稿: 22 参加年月日: 16/01/13 最新の投稿
Attached gradle file.

添付ファイル:

thumbnail
7年前 に Sravan Kumar Chalvadi によって更新されました。

RE: Using @Reference (of OSGI) in portlet class

New Member 投稿: 22 参加年月日: 16/01/13 最新の投稿
FYI, the same portlet working perfect in LR7 IDE and its server(community edition). But not in LR7 DXP and its server.
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: Using @Reference (of OSGI) in portlet class

Liferay Legend 投稿: 14916 参加年月日: 06/09/02 最新の投稿
You either need to change from "provided" to "compile" scope, or you need to apply the "nebula.provided-base" gradle plugin to your project.




Come meet me at the LSNA!
thumbnail
7年前 に Sravan Kumar Chalvadi によって更新されました。

RE: Using @Reference (of OSGI) in portlet class

New Member 投稿: 22 参加年月日: 16/01/13 最新の投稿
I am using "compile" in build.gradle

dependencies {
	compile group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "2.0.0"
	compile group: "com.liferay.portal", name: "com.liferay.util.taglib", version: "2.0.0"
	compile group: "javax.portlet", name: "portlet-api", version: "2.0"
	compile group: "javax.servlet", name: "servlet-api", version: "2.5"
	compile group: "jstl", name: "jstl", version: "1.2"
	compile group: "org.osgi", name: "org.osgi.compendium", version: "5.0.0"
}


bnd file
Bundle-Version: 1.0.0
-sources: true


MVC Porlet class code:

private RepairStatusService _repairStatusService;
	
	@Reference(unbind = "-")
	public void setRepairStatusService(RepairStatusService guestbookService) {
		_repairStatusService = guestbookService;
	}
	
	public RepairStatusService getRepairStatusService() {
		return _repairStatusService;
	}


Problem: My portlet is not available under "Applications" section. I have even checked in "App Manager" section, status is "Active".
Observation: If I remove "@Reference(unbind = "-")" from portlet class, then my portlet is shown under "Application" section.
Other information: If "@Reference(unbind = "-")" is added to portlet class of deployed portlet (which is added to a page ) then it shows "This portlet has been undeployed. Please redeploy it or remove it from the page." in portlet UI. Note: Still portlet state is "Active" in "App Manager".
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: Using @Reference (of OSGI) in portlet class

Liferay Legend 投稿: 14916 参加年月日: 06/09/02 最新の投稿
Where is the repair status service dependency in build.gradle?

@Reference is only used for injecting services that are not part of the current module. If something is in your module, it doesn't get injected from @Reference, you should be using a spring bean injection or something.





Come meet me at the LSNA!
thumbnail
7年前 に Sravan Kumar Chalvadi によって更新されました。

RE: Using @Reference (of OSGI) in portlet class

New Member 投稿: 22 参加年月日: 16/01/13 最新の投稿
Thanks for your reply.

I have added repair status service dependency and deployed it. No luck with that. FYI, I have added the complete structure of my module. Please have a look and suggest if I have to go with spring bean injection way.

|----repairstatus-portlet
|
|----repairstatus-portlet-api (generated using "service builder" of LR7 Developer Studio)
|
|----repairstatus-portlet-service (generated using "service builder" of LR7 Developer Studio, here service.xml is
used to generate only remote services
i.e.,<entity local-service="false" name="RepairStatus" remote-service="true" />)
|
|----repairstatus-portlet-web (generated using LR7 Developer Studio)

Note: I have tested the same with simple MVC portlet with out any service builder code, I see same issue with @Reference.
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: Using @Reference (of OSGI) in portlet class

Liferay Legend 投稿: 14916 参加年月日: 06/09/02 最新の投稿
Okay, so you're assuming that both the API and service modules have deployed and started successfully.

Are they? You can check in gogo to see if both of the modules are started. If they are not started, try starting them and see if they can start.





Come meet me at the LSNA!
thumbnail
7年前 に Sravan Kumar Chalvadi によって更新されました。

RE: Using @Reference (of OSGI) in portlet class

New Member 投稿: 22 参加年月日: 16/01/13 最新の投稿
They are "active", I have checked in "GoGo shell" and in "App Manager". No idea what is messing up for portlet no show in "Applications" section.

Other Info: Tools and versions on my machine
-Liferay Developer Studio --------Version: 3.0.0.201606202116-ga1
-Eclipse Buildship---------version 1.0.15.v20160425-1638
-Bndtools---------------version 3.2.0
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: Using @Reference (of OSGI) in portlet class

Liferay Legend 投稿: 14916 参加年月日: 06/09/02 最新の投稿
Okay, in gogo when you try to start your portlet module, what does it report?




Come meet me at the LSNA!
thumbnail
7年前 に Sravan Kumar Chalvadi によって更新されました。

RE: Using @Reference (of OSGI) in portlet class

New Member 投稿: 22 参加年月日: 16/01/13 最新の投稿
Resulted an error, by executing "start [ID]" on gogo for my api, service and portlet.
org.osgi.framework.BundleException: Error reading bundle content.
        at org.eclipse.osgi.internal.framework.BundleContextImpl.installBundle(BundleContextImpl.java:149)
        at org.eclipse.osgi.internal.framework.BundleContextImpl.installBundle(BundleContextImpl.java:139)
        at org.apache.felix.gogo.command.Basic.start(Basic.java:724)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.felix.gogo.runtime.Reflective.invoke(Reflective.java:137)
        at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:82)
        at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:477)
        at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:403)
        at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
        at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)
        at org.apache.felix.gogo.shell.Console.run(Console.java:62)
        at org.apache.felix.gogo.shell.Shell.console(Shell.java:203)
        at org.apache.felix.gogo.shell.Shell.gosh(Shell.java:128)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.felix.gogo.runtime.Reflective.invoke(Reflective.java:137)
        at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:82)
        at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:477)
        at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:403)
        at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
        at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)
        at org.eclipse.equinox.console.telnet.TelnetConnection.run(TelnetConnection.java:94)
Caused by: java.net.MalformedURLException: no protocol: [660]
        at java.net.URL.<init>(URL.java:593)
        at java.net.URL.<init>(URL.java:490)
        at java.net.URL.<init>(URL.java:439)
        at org.eclipse.osgi.storage.Storage.createURL(Storage.java:461)
        at org.eclipse.osgi.storage.Storage.getContentConnection(Storage.java:441)
        at org.eclipse.osgi.storage.Storage.getContentConnection(Storage.java:417)
        at org.eclipse.osgi.internal.framework.BundleContextImpl.installBundle(BundleContextImpl.java:145)
        ... 30 more
java.net.MalformedURLException: no protocol: [660]</init></init></init>
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: Using @Reference (of OSGI) in portlet class

Liferay Legend 投稿: 14916 参加年月日: 06/09/02 最新の投稿
wow, those are new ones for me...

What was the full command you gave for start?





Come meet me at the LSNA!
thumbnail
7年前 に Sravan Kumar Chalvadi によって更新されました。

RE: Using @Reference (of OSGI) in portlet class

New Member 投稿: 22 参加年月日: 16/01/13 最新の投稿
start [660]. Here 660 is the bundle ID.

I am following "https://dev.liferay.com/develop/reference/-/knowledge_base/7-0/using-the-felix-gogo-shell" for commands.

Fyi, I am using "gogo" shell which is available in LR7 Developer Studio.
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: Using @Reference (of OSGI) in portlet class

Liferay Legend 投稿: 14916 参加年月日: 06/09/02 最新の投稿
Don't put in brackets, just use "start 660" as the command.







Come meet me at the LSNA!
thumbnail
7年前 に Sravan Kumar Chalvadi によって更新されました。

RE: Using @Reference (of OSGI) in portlet class

New Member 投稿: 22 参加年月日: 16/01/13 最新の投稿
well! using without brackets does not return anything.

g! start 661
g!
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: Using @Reference (of OSGI) in portlet class

Liferay Legend 投稿: 14916 参加年月日: 06/09/02 最新の投稿
As well it shouldn't. When you lb again, you should see that 661 is now in the started state.






Come meet me at the LSNA!
thumbnail
7年前 に Sravan Kumar Chalvadi によって更新されました。

RE: Using @Reference (of OSGI) in portlet class

New Member 投稿: 22 参加年月日: 16/01/13 最新の投稿
still 661 is in "Active" state. Looks like Active is nothing but started.

I have also tested it with "Stop" command, then lb showed it as "resolved". Later "start" command, then lb showed it in "Active" state.
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: Using @Reference (of OSGI) in portlet class

Liferay Legend 投稿: 14916 参加年月日: 06/09/02 最新の投稿
sorry, my bad, "active" is right. Do all 3 of your modules report as active?






Come meet me at the LSNA!
thumbnail
7年前 に Sravan Kumar Chalvadi によって更新されました。

RE: Using @Reference (of OSGI) in portlet class

New Member 投稿: 22 参加年月日: 16/01/13 最新の投稿
yes! All 3 are active.

Note: As I said earlier, I have tested the same with simple MVC portlet with out any service builder code, I see same issue with @Reference.
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: Using @Reference (of OSGI) in portlet class

Liferay Legend 投稿: 14916 参加年月日: 06/09/02 最新の投稿
if you add the @Reference, then the portlet doesn't show as active? Or does it show as active in gogo?

Often times the first challenge is just making sure all of the modules are active. This part is done in gogo. If they are not active, it will report the error as to why they cannot start.

Other things to look at are the logs - are there any errors in the logs related to deployment or runtime failures.

Things don't just fail w/o leaving some sort of trace, there's gotta be something in there pointing to why they are not working.







Come meet me at the LSNA!
thumbnail
7年前 に Sravan Kumar Chalvadi によって更新されました。

RE: Using @Reference (of OSGI) in portlet class

New Member 投稿: 22 参加年月日: 16/01/13 最新の投稿
with and without @Reference, portlet is always active. And all source and dependent modules are active too.

logs: There are some errors reported at server starting which might be related to OSGI.

Attached log files.
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: Using @Reference (of OSGI) in portlet class

Liferay Legend 投稿: 14916 参加年月日: 06/09/02 最新の投稿
The errors are all lock errors for the Equinox container. Are you trying to test a cluster? How is the cluster configured?

I think you've been trying to solve the wrong thing. The dependency, the @Reference usage, ... I think those may all be symptoms of something larger.







Come meet me at the LSNA!
thumbnail
7年前 に Sravan Kumar Chalvadi によって更新されました。

RE: Using @Reference (of OSGI) in portlet class

New Member 投稿: 22 参加年月日: 16/01/13 最新の投稿
I do not know what cluster is in LR. And I am not trying to test it.

All I want to do is to create a module with (*-api, *-service, *-web) structure. And use services of *-service in my portlet class of *-web.
thumbnail
7年前 に Juan Gonzalez によって更新されました。

RE: Using @Reference (of OSGI) in portlet class

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
Seems you're using Liferay DXP (not Liferay 7 CE).

Did you installed latest available fixpack from https://web.liferay.com/group/customer/dxp/downloads/digital-enterprise/fix-packs? There had been many issues fixed since DXP initial release.

I think it would be great if you can provide some simple bundles so we can check why it isn't showing as a portlet that could be added to a page.

Thanks!
thumbnail
7年前 に Sravan Kumar Chalvadi によって更新されました。

RE: Using @Reference (of OSGI) in portlet class

New Member 投稿: 22 参加年月日: 16/01/13 最新の投稿
yes! I am using LR7 DXP.

Tried accessing the link, it says "We're sorry, the page you requested was not found."

Attached simple test moudle

添付ファイル:

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

RE: Using @Reference (of OSGI) in portlet class

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
Hi Shravar.

I think your sample portlet isn't related to the problem. You added there a reference to a String (which doesn't make sense) instead of a service. As far as I recall, it was your actual problem.

We've found the problem and a workaround. Whenever having a better fix will come back here. Hopefully in few days.
thumbnail
7年前 に Juan Gonzalez によって更新されました。

RE: Using @Reference (of OSGI) in portlet class

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
Hi again Sravan.

So, I've got some steps in order to fix the unavailability of a service made in ServiceBuilder. This is happening just for old Liferay blade workspaces. Seems current liferay workspace version doesn't include newest grade plugins, so ServiceAnalyzer isn't adding some needed headers in MANIFEST to make this service available. Final fix will be a new workspace plugin version, but here we have a workaround in the meantime. Follow these steps:

* In the root directory on your blade workspace, edit settings gradle:
[indent]Change
classpath group: "com.liferay", name: "com.liferay.gradle.plugins.workspace", version: "1.0.29"
to
classpath group: "com.liferay", name: "com.liferay.gradle.plugins.workspace", version: "1.0.37"
[/indent]
* Enter the service builder module, edit build.gradle changing all "compileOnly" to "compile".
* Optional: if using an old gradle version and see some errors when building service again, you probably should update your wrapper by doing:
gradle wrapper --gradle-version=3.0


Then try to rerun buildService and now it should be available, and your MVC portlet refering to it should show up.

Let me know if that fixed your issue after deploying your services again.

Thanks!
6年前 に Ramchand Gururajan によって更新されました。

RE: Using @Reference (of OSGI) in portlet class

Junior Member 投稿: 33 参加年月日: 16/04/05 最新の投稿
Juan Gonzalez:
Hi again Sravan.

So, I've got some steps in order to fix the unavailability of a service made in ServiceBuilder. This is happening just for old Liferay blade workspaces. Seems current liferay workspace version doesn't include newest grade plugins, so ServiceAnalyzer isn't adding some needed headers in MANIFEST to make this service available. Final fix will be a new workspace plugin version, but here we have a workaround in the meantime. Follow these steps:

* In the root directory on your blade workspace, edit settings gradle:
[indent]Change
classpath group: "com.liferay", name: "com.liferay.gradle.plugins.workspace", version: "1.0.29"
to
classpath group: "com.liferay", name: "com.liferay.gradle.plugins.workspace", version: "1.0.37"
[/indent]
* Enter the service builder module, edit build.gradle changing all "compileOnly" to "compile".
* Optional: if using an old gradle version and see some errors when building service again, you probably should update your wrapper by doing:
gradle wrapper --gradle-version=3.0


Then try to rerun buildService and now it should be available, and your MVC portlet refering to it should show up.

Let me know if that fixed your issue after deploying your services again.

Thanks!



Hi,
Can you please let me know how this can be fixed in MAVEN environment . We are using MAVEN & not using liferay workspace , we have landed on this same issue. Portlets are not showing when @Reference is used for injecting the services.

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

RE: Using @Reference (of OSGI) in portlet class

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
So I think we now have the final fix for this.

Please, within your blade workspace root directory, in settings.gradle, change version of:

com.liferay.gradle.plugins.workspace


to 1.0.40, and try to rebuild service. Of course you should revert your service project gradle changes (compileOnly instead of compile)

Let me know if you find any problem.

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

RE: Using @Reference (of OSGI) in portlet class

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


Please, within your blade workspace root directory, in settings.gradle, change version of:

com.liferay.gradle.plugins.workspace


to 1.0.40, and try to rebuild service. Of course you should revert your service project gradle changes (compileOnly instead of compile)


I changed the parameters, changed a method, rebuilt services and redeployed the module, and it seems to be working. Thanks! Could you please point me to a link where I could understand what exactly is the difference between compile and compileOnly, or what are the work in progress on the subject of the liferay workspace plugin?

Thanks
7年前 に pawan kumar によって更新されました。

RE: Using @Reference (of OSGI) in portlet class

New Member 投稿: 14 参加年月日: 13/02/07 最新の投稿
Hi,

Just want to get clear,In liferay 7 we have two directory serviceBuilder-api and serviceBuilder-service,which we have to deploy into liferay server.
thumbnail
6年前 に Suresh Yadagiri によって更新されました。

RE: Using @Reference (of OSGI) in portlet class

Junior Member 投稿: 29 参加年月日: 14/03/24 最新の投稿
i tried with latest version(1.5.1) and the versions suggested here 1.037. tried with compile and compileOnly . I still dont see context name when I go to /api/jsonws/ ... Remote services are not available. Using 7.0 CE GA 3 tomcat bundle.
thumbnail
6年前 に Christoph Rabel によって更新されました。

RE: Using @Reference (of OSGI) in portlet class

Liferay Legend 投稿: 1554 参加年月日: 09/09/24 最新の投稿
Just for reference:
The issue of Mr. Suresh Yadagiri was continued here, please don't answer in this thread:
https://web.liferay.com/de/community/forums/-/message_boards/message/83050041
6年前 に Ketan Solanki によって更新されました。

RE: Using @Reference (of OSGI) in portlet class

Junior Member 投稿: 63 参加年月日: 14/05/28 最新の投稿
@Sravan: Did you resolve the issue?

I am doing something similar. I have a project which builds a module for QuerySuggester with my implementation.

@Component(
        immediate = true, property = {"search.engine.impl=LiferayElasticsearchCluster"},
        service = QuerySuggester.class, name = "bookmarkQuerySuggester"
)
public class BookmarkQuerySuggester extends BaseQuerySuggester {


Have exported this package in bnd.bnd file and this module is running just fine. I can say that by seeing the STARTED message in the log

In another portlet module application, I am trying to refer above BookmarkQuerySuggester in the portlet class by @Reference annotation! However if I do so , portlet doesn't start at all, other portlets do start in the same jar file but not the one where I am referring by @Reference!

I guess I am facing same issue and I am using Liferay CE 7.0. Please let me know if you had found any solution

Thanks in advance