Liferay 7 和 Vaadin 8:Vaadin Shared 未激活

Posted

技术标签:

【中文标题】Liferay 7 和 Vaadin 8:Vaadin Shared 未激活【英文标题】:Liferay 7 and Vaadin 8: Vaadin Shared is not active 【发布时间】:2019-02-05 20:44:24 【问题描述】:

我正在尝试使用 vaadin portlet 安装模块。捆绑包启动时会引发以下异常。

有谁知道如何检查 Vaadin Liferay 集成是否处于活动状态?还是我的模块需要自动激活?

谢谢

2018-08-30 17:45:07.745 INFO  [Refresh Thread: Equinox Container: b06cd3dd-72ac-0018-1cb3-ebc69224d879][BundleStartStopLogger:35] STARTED com.smart.services.vaadin.test_1.0.0.SNAPSHOT [979]
2018-08-30 17:45:07.755 ERROR [Refresh Thread: Equinox Container: b06cd3dd-72ac-0018-1cb3-ebc69224d879][com_smart_services_vaadin_test:97] [com.vaadin.osgi.liferay.VaadinPortletProvider(3827)] The activate method has thrown an exception 
com.vaadin.osgi.resources.OsgiVaadinResources$ResourceBundleInactiveException: Vaadin Shared is not active!
    at com.vaadin.osgi.resources.OsgiVaadinResources.getService(OsgiVaadinResources.java:66)
    at com.vaadin.osgi.liferay.VaadinPortletProvider.activate(VaadinPortletProvider.java:53)
    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.scr.impl.inject.BaseMethod.invokeMethod(BaseMethod.java:224)
    at org.apache.felix.scr.impl.inject.BaseMethod.access$500(BaseMethod.java:39)
    at org.apache.felix.scr.impl.inject.BaseMethod$Resolved.invoke(BaseMethod.java:617)
    at org.apache.felix.scr.impl.inject.BaseMethod.invoke(BaseMethod.java:501)
    at org.apache.felix.scr.impl.inject.ActivateMethod.invoke(ActivateMethod.java:302)
    at org.apache.felix.scr.impl.inject.ActivateMethod.invoke(ActivateMethod.java:294)
    at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:297)
    at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:108)
    at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:906)
    at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:879)
    at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:748)
    at org.apache.felix.scr.impl.manager.AbstractComponentManager.enableInternal(AbstractComponentManager.java:674)
    at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:429)
    at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.enableComponents(ConfigurableComponentHolder.java:657)
    at org.apache.felix.scr.impl.BundleComponentActivator.initialEnable(BundleComponentActivator.java:341)
    at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:403)
    at org.apache.felix.scr.impl.Activator.access$200(Activator.java:54)
    at org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:278)
    at org.apache.felix.utils.extender.AbstractExtender.createExtension(AbstractExtender.java:259)
    at org.apache.felix.utils.extender.AbstractExtender.modifiedBundle(AbstractExtender.java:232)
    at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:482)
    at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:1)
    at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232)
    at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444)
    at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:905)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
    at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
    at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:165)
    at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:75)
    at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:67)
    at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:102)
    at org.eclipse.osgi.container.Module.publishEvent(Module.java:461)
    at org.eclipse.osgi.container.Module.start(Module.java:452)
    at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:454)
    at org.eclipse.osgi.container.ModuleContainer.applyDelta(ModuleContainer.java:717)
    at org.eclipse.osgi.container.ModuleContainer.resolveAndApply(ModuleContainer.java:491)
    at org.eclipse.osgi.container.ModuleContainer.resolve(ModuleContainer.java:437)
    at org.eclipse.osgi.container.ModuleContainer.refresh(ModuleContainer.java:955)
    at org.eclipse.osgi.container.ModuleContainer$ContainerWiring.dispatchEvent(ModuleContainer.java:1336)
    at org.eclipse.osgi.container.ModuleContainer$ContainerWiring.dispatchEvent(ModuleContainer.java:1)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)

我添加了部分代码。

我的 pom.xml 看起来像:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>PruebaLiferay7-modules</artifactId>
        <groupId>PruebaLiferay7</groupId>
        <version>1.0.0</version>
    </parent>
    <groupId>com.smart.services.vaadin.portlet.reports.active.agent</groupId>
    <artifactId>fielder-tracking-osgi-test</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>com.fielder</groupId>
            <artifactId>api-fielder</artifactId>
            <version>3.1-migration</version>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-server</artifactId>
            <version>8.5.1</version>
        </dependency>
        <dependency>
            <groupId>com.liferay.portal</groupId>
            <artifactId>com.liferay.portal.kernel</artifactId>
            <version>3.26.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.liferay.portal</groupId>
            <artifactId>com.liferay.util.taglib</artifactId>
            <version>3.3.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.portlet</groupId>
            <artifactId>portlet-api</artifactId>
            <version>2.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>osgi.cmpn</artifactId>
            <version>6.0.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-liferay-integration</artifactId>
            <version>8.5.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-osgi-integration</artifactId>
            <version>8.5.1</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <archive>
                        <manifestFile>$project.build.outputDirectory/META-INF/MANIFEST.MF</manifestFile>
                    </archive>
                    <excludes>
                        <exclude>**/META-INF/resources/**/.sass-cache/</exclude>
                    </excludes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>biz.aQute.bnd</groupId>
                <artifactId>bnd-maven-plugin</artifactId>
                <version>4.0.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>bnd-process</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>biz.aQute.bnd</groupId>
                        <artifactId>biz.aQute.bndlib</artifactId>
                        <version>4.0.0</version>
                    </dependency>
                    <dependency>
                        <groupId>com.liferay</groupId>
                        <artifactId>com.liferay.ant.bnd</artifactId>
                        <version>2.0.54</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
</project>

我的 bdn.bnd

Bundle-Name: fielder-tracking-osgi-test
Bundle-SymbolicName: com.smart.services.vaadin.test
Bundle-Version: 1.0.0-SNAPSHOT

Import-Package: !com.liferay.portal.kernel.util,\
!com.google.*,\
!com.smart.service.api.*,\
!com.smart.service.portal.*,\
!com.vaadin.*,\
!com.googlecode.gentyref.*,\
!com.ibm.icu.text.*,\
!com.amazonaws.services.dynamodbv2.model.*,\
!com.amazonaws.services.kinesis.model.*,\
!com.amazonaws.services.s3.event.*,\
!com.squareup.okhttp.*,\
!com.sun.mail.util.*,\
!com.sun.xml.fastinfoset.sax.*,\
!com.sun.xml.fastinfoset.stax.*,\
!com.vaadin.addon.charts.model.style.*,\
!com.vaadin.data.util.converter.*,\
!com.vaadin.sass.internal.*,\
!com.vaadin.server.data.*,\
!elemental.*,\
!javax.inject.*,\
!libcore.io.*,\
!lombok.*,\
!okio.*,\
!org.antlr.stringtemplate.*,\
!com.beust.jcommander.*,\
!com.conversantmedia.*,\
!com.fasterxml.jackson.*,\
!com.ibm.uvm.*,\
!com.lmax.*,\
!com.sun.*,\
!javax.*,\
!org.apache.*,\
!org.atmosphere.*,\
!org.checkerframework.*,\
!org.fusesource.*,\
!org.jctools.*,\
!org.joda.*,\
!org.json.*,\
!org.jsoup.*,\
!org.jvnet.*,\
!org.zeromq.*,\
!scala.*,\
*
Export-Package: com.smart.services.vaadin.portlet.reports.active.agent.constants
-jsp: *.jsp,*.jspf
-plugin.jsp: com.liferay.ant.bnd.jsp.JspAnalyzerPlugin
-plugin.resourcebundle: com.liferay.ant.bnd.resource.bundle.ResourceBundleLoaderAnalyzerPlugin
-plugin.sass: com.liferay.ant.bnd.sass.SassAnalyzerPlugin
-sass: *
-includeresource: api-fielder-3.1-migration.jar, fielder-util-api-3.1-migration.jar,\

Bundle-ClassPath:\
  .,\
  api-fielder-3.1-migration.jar.jar,\
  fielder-util-api-3.1-migration.jar,\
  portlet-api.jar,\

我的 vaadin portlet:

@Component(service = UI.class, property =  "com.liferay.portlet.display-category=category.fielder",
        "javax.portlet.name=" + PortletPortletKeys.Portlet, "javax.portlet.display-name=Fielder Tutorial Portlet",
        "javax.portlet.security-role-ref=power-user,user",
        "com.vaadin.osgi.liferay.portlet-ui=true" , scope = ServiceScope.PROTOTYPE)

public class ReportServiceAgentPortlet extends UI 

    /** Defines serial version UID. */
    private static final long   serialVersionUID    = 1L;
    /** Class logger. */
    private static final Logger LOGGER              = LogManager.getLogger(ReportServiceAgentPortlet.class);
...

【问题讨论】:

是一个 OSGi Portlet(例如@Component)还是一个 WAR 风格的 portlet(例如它有一个 portlet.xml)?请添加代码以使其成为MCVE。您使用的是什么确切版本的 Liferay 和 Vaadin?还要添加次要版本号。 是的,它是一个 OSGI Portlet,我使用的是 Liferay 7.1 和 Vaadin 8.5.1。我在下面添加了一部分代码。 【参考方案1】:

问题详细描述here。

该修复已包含在 Vaadin 8.9 和更新版本中,因此今天最简单的方法就是更新 Vaadin 版本。

对于旧版,我开发了a fix,它只是等到 Vaadin Shared 处于活动状态,然后再完成 Vaadin Liferay 集成启动。这样就解决了问题。

只需克隆修复程序,更新 V​​aadin 版本并执行 maven 构建。

【讨论】:

感谢您的回答,我下载了 vaadin 集成的修复程序,使用 vaadin 8.5.1 构建它并上传到 Liferay App Manager。但我仍然有这个问题。所以我下载了github.com/ctliv/vaadin-portlet-sample,试图找出我做错了什么。 我更新了 pom vaadin-portley-sample 以使用 vaadin 8.5.1 和 liferay 内核 3.26.0 和 osgi 版本 7.0.0。捆绑包编译得很好,然后我将 de jar 上传到 Liferay,当我尝试激活应用程序时抛出错误:未解决的要求:导入包:com.liferay.portal.kernel.exception; version="[7.4.0,8.0.0)"_ [Sanitized] 在 pom 我有 ... com.liferay.portal.*, com.liferay.portal.kernel.exception.*;版本="[7.4.0,8.0.0)", 你好。 Vaadin-portlet-sample 是在 Liferay 7.1 之前开发的,并且导入包版本控制不正确。现在它已修复(使用 Vaadin 8.2.0 测试)。关于 Vaadin-liferay-integration-fix,我认为您遇到了不同的问题。 Vaadin Server(也是 8.5.1 版)导入包 com.liferay.portal.kernel.util,版本为“[7.0,8)”,但 Liferay 7.1 导出该包的 8.0.0 版。所以 Vaadin Server 没有启动(所以 Vaadin Liferay 集成)。您应该为 Vaadin 服务器构建和使用此修复程序:github.com/ctliv/osgi-bundles/tree/master/vaadin-server-fix 感谢您的回答,我在 Liferay 7.0 和 vaadin 8.5.1 中部署了示例 portlet,但没有出现错误。在 bnd 文件中,我添加了 -includeresource: lib/com.liferay.portal.kernel.jar=com.liferay.portal.kernel-[0-9]*.jar;lib:=true,\ Bundle-ClassPath:\ 。 ,\ lib/com.liferay.portal.kernel.jar,\ 好像 Liferay 7.1 的 vaadin 有一些问题 谢谢,无论如何 您不必在捆绑包中包含任何 liferay jar。这会与现有的 Liferay 库产生冲突。我确认 Vaadin 可以在 Liferay 7.1 上运行,但 Vaadin Server(最高 8.5.1)需要我所做的修复(以及 Vaadin Liferay 集成)。我会看看我是否可以制作更详细的指南,但无论如何我需要时间。【参考方案2】:

也许有人仍然有这个问题并正在寻找答案...... 根据我的经验,它已通过 Vaadin 8.9.0 修复

【讨论】:

以上是关于Liferay 7 和 Vaadin 8:Vaadin Shared 未激活的主要内容,如果未能解决你的问题,请参考以下文章

<vaadin-horizo​​ntal-layout> 是垂直的,而不是水平的

带有 MySQL Server 5.6 的 Liferay 7 未启动

我在Vaadin8迁移后需要Widgetset编译错误

在 Vaadin Flow 中的布局中居中小部件

Grails、Vaadin 7 和 SpringSecurity:授权不起作用

Liferay 7:Liferay内部博客地址