vaadin / framework

Vaadin 6, 7, 8 is a Java framework for modern Java web applications.
http://vaadin.com/
Other
1.77k stars 729 forks source link

VaadinPortlet NoClassDefFoundError with Liferay #12575

Closed mikke-alekstra closed 1 year ago

mikke-alekstra commented 1 year ago

Liferay 7.4.3.22 Vaadin 8.19-SNAPSHOT vaadin-compatibility-client-compiled-8.19-20230105.135656-11.jar vaadin-compatibility-server-8.19-20230105.135536-12.jar vaadin-compatibility-shared-8.19-20230105.135446-12.jar vaadin-compatibility-themes-8.19-20230105.135708-11.jar vaadin-liferay-integration-8.19-20230105.135714-11.jar vaadin-osgi-integration-8.19-20230105.135718-11.jar vaadin-portlet-8.19-20230105.135304-12.jar vaadin-server-8.19-20230105.135253-12.jar vaadin-shared-8.19-20230105.135044-12.jar vaadin-themes-8.19-20230105.135438-12.jar

After deploying a portlet I get an error java.lang.NoClassDefFoundError: com/vaadin/server/VaadinPortlet

Please find attached the stack trace stack_trace.txt

Bundle information for vaadin-portlet

com.vaadin.portlet_8.19.0.202301051353 [1545]
  Id=1545, Status=ACTIVE      Data Root=/home/tomcat/liferay-ce-portal-7.4.3.22-ga22/osgi/state/org.eclipse.osgi/1545/data
  "No registered services."
  No services in use.
  Exported packages
    com.vaadin.osgi.resources; version="8.19.0"[exported]
  Imported packages
    com.liferay.portal.kernel.util; version="35.0.0" <org.eclipse.osgi_3.13.0.LIFERAY-PATCHED-11 [0]>
    com.vaadin.shared; version="8.19.0" <com.vaadin.shared_8.19.0.202301051350 [1512]>
    com.vaadin.shared.util; version="8.19.0" <com.vaadin.shared_8.19.0.202301051350 [1512]>
    com.vaadin.ui; version="8.19.0" <com.vaadin.server_8.19.0 [1529]>
    com.vaadin.util; version="8.19.0" <com.vaadin.server_8.19.0 [1529]>
    elemental.json; version="2.8.2" <com.vaadin.external.gwt_2.8.2.vaadin2 [1553]>
    javax.portlet; version="2.0.0" <org.eclipse.osgi_3.13.0.LIFERAY-PATCHED-11 [0]>
    javax.portlet.filter; version="2.0.0" <org.eclipse.osgi_3.13.0.LIFERAY-PATCHED-11 [0]>
    javax.servlet.http; version="3.1.0" <org.eclipse.osgi_3.13.0.LIFERAY-PATCHED-11 [0]>
    javax.xml.namespace; version="1.4.0" <org.eclipse.osgi_3.13.0.LIFERAY-PATCHED-11 [0]>
    org.osgi.framework; version="1.9.0" <org.eclipse.osgi_3.13.0.LIFERAY-PATCHED-11 [0]>
    org.osgi.service.http; version="1.2.1" <org.osgi.service.http_3.5.0.LIFERAY-PATCHED-2 [82]>
    org.osgi.util.tracker; version="1.5.2" <org.eclipse.osgi_3.13.0.LIFERAY-PATCHED-11 [0]>
    org.w3c.dom; version="1.0.0" <org.eclipse.osgi_3.13.0.LIFERAY-PATCHED-11 [0]>
  No fragment bundles
  No required bundles

For reference I copied bundle information for vaadin-liferay-integration, too

com.vaadin.liferay.integration_8.19.0 [1581]
  Id=1581, Status=ACTIVE      Data Root=/home/tomcat/liferay-ce-portal-7.4.3.22-ga22/osgi/state/org.eclipse.osgi/1581/data
  "No registered services."
  Services in use:
    {com.vaadin.osgi.resources.VaadinResourceService}={service.id=3882, service.bundleid=1512, service.scope=bundle, component.name=com.vaadin.osgi.resources.impl.VaadinResourceServiceImpl, component.id=9827}
    {org.osgi.service.log.LogService, org.osgi.service.log.LoggerFactory, org.eclipse.equinox.log.ExtendedLogService}={service.id=2, service.bundleid=0, service.scope=bundle}
  Exported packages
    com.vaadin.osgi.liferay; version="8.19.0"[exported]
  Imported packages
    com.vaadin.osgi.resources; version="8.19.0" <com.vaadin.shared_8.19.0.202301051350 [1512]>
    com.vaadin.server; version="8.19.0" <com.vaadin.server_8.19.0 [1529]>
    com.vaadin.shared; version="8.19.0" <com.vaadin.shared_8.19.0.202301051350 [1512]>
    com.vaadin.ui; version="8.19.0" <com.vaadin.server_8.19.0 [1529]>
    javax.portlet; version="2.0.0" <org.eclipse.osgi_3.13.0.LIFERAY-PATCHED-11 [0]>
    org.osgi.framework; version="1.9.0" <org.eclipse.osgi_3.13.0.LIFERAY-PATCHED-11 [0]>
    org.osgi.service.log; version="1.4.0" <org.eclipse.osgi_3.13.0.LIFERAY-PATCHED-11 [0]>
    org.osgi.util.tracker; version="1.5.2" <org.eclipse.osgi_3.13.0.LIFERAY-PATCHED-11 [0]>
  No fragment bundles
  No required bundles
TatuLund commented 1 year ago

This is follow-up to https://github.com/vaadin/framework/issues/12569

TatuLund commented 1 year ago

Vaadin 8.19-SNAPSHOT as bnd.bnd to vaadin-portlet and it should be used as OSGi module now.

At PortletUIServiceTrackerCustomizer.java:114 there is "new OsgiVaadinPortlet()". Something goes wrong with OSGi, as based on the stacktrace Osgi class loader fails to find VaadinPortlet.

at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:151) ~[org.eclipse.osgi.jar:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[?:?]
at com.vaadin.osgi.liferay.PortletUIServiceTrackerCustomizer.registerPortlet(PortletUIServiceTrackerCustomizer.java:114) ~[?:?]

So to me the problem looks like that vaadin-portlet is not activated yet. Did you start it with blade before vaadin-liferay-integration?

TatuLund commented 1 year ago

We found a typo in bnd.bnd, which may explain the problem. We will release 8.19.1 soon, which hopefully has correctly formed bnd.bnd.

mikke-alekstra commented 1 year ago

Thanks for the info, Tatu.

I just re-tested my test Liferay portlet in 7.4.3.22 / 8.17.0 and the portlet appeared fine. I then moved to 7.4.3.22 / 8.19-SNAPSHOT and got the VaadinPortlet class not found error. The test portlets are exactly the same except for Vaadin version and dependency addition for vaadin-portlet in pom.xml.

I will test more with 8.19.1 (or 8.19-SNAPSHOT) when available.

mikke-alekstra commented 1 year ago

I made some tests in my Liferay+Vaadin test bench and I think I got latest Liferay version (7.4.3.60) to work with latest Vaadin 8 version (8.19.0) by customizing vaadin-portlet and vaadin-liferay-integration.

I downloaded the sources for the two above libraries and made the following modifications:

vaadin-portlet

vaadin-liferay-integration

TatuLund commented 1 year ago

Thanks for your effort and good input. This finding is aligned with our own analysis.

thevaadinman commented 1 year ago

I'm making these modifications to Vaadin 8; I'll give you an extra update once a new 8.20 snapshot is available so that you can verify that the modifications work for you as well. Since these changes necessitate code changes for users, the next Vaadin version released will be 8.20.0.

thevaadinman commented 1 year ago

Hi, @mikke-alekstra I've been unable to reach you through Expert Chat; could you try the latest 8.20-SNAPSHOT to check if deployment works?

mikke-alekstra commented 1 year ago

Hi, @thevaadinman. You can reach me now in Expert Chat. Vaadin-portlet does not start probably because there is a typo in the manifest. com.liferay.portal.kernel;resultion:=optional;version="[7.0.0,93.0.0)"

thevaadinman commented 1 year ago

@mikke-alekstra.. yes, of course a typo managed to sneak its way into the commit. :) The typo has been fixed and a new snapshot build was triggered. It should now be available.

mikke-alekstra commented 1 year ago

@thevaadinman no luck. The problem might relate to vaadin-portlet.jar that contains com.vaadin.server stuff. When I tested this I had only com.vaadin.portlet classes in vaadin-portlet.jar. All com.vaadin.server classes were taken from vaadin-server.jar.

 ERROR: Unable to start bundle: file:/home/tomcat/liferay-ce-portal-7.4.3.60-ga60/osgi/modules/vaadin-liferay-integration-8.20-20230214.140030-7.jar
com.liferay.portal.kernel.log.LogSanitizerException: org.osgi.framework.BundleException: Could not resolve module: com.vaadin.liferay.integration [1697]_  Bundle was not resolved because of a uses contraint violation._  org.osgi.service.resolver.ResolutionException: Uses constraint violation. Unable to resolve resource com.vaadin.liferay.integration [osgi.identity; osgi.identity="com.vaadin.liferay.integration"; type="osgi.bundle"; version:Version="8.20.0"] because it is exposed to package 'com.vaadin.server' from resources com.vaadin.portlet [osgi.identity; osgi.identity="com.vaadin.portlet"; type="osgi.bundle"; version:Version="8.20.0"] and com.vaadin.server [osgi.identity; osgi.identity="com.vaadin.server"; type="osgi.bundle"; version:Version="8.20.0"] via two dependency chains.__Chain 1:_  com.vaadin.liferay.integration [osgi.identity; osgi.identity="com.vaadin.liferay.integration"; type="osgi.bundle"; version:Version="8.20.0"]_    import: (&(osgi.wiring.package=com.vaadin.server)(&(version>=8.20.0)(version<=8.20.0)))_     |_    export: osgi.wiring.package: com.vaadin.server_  com.vaadin.portlet [osgi.identity; osgi.identity="com.vaadin.portlet"; type="osgi.bundle"; version:Version="8.20.0"]__Chain 2:_  com.vaadin.liferay.integration [osgi.identity; osgi.identity="com.vaadin.liferay.integration"; type="osgi.bundle"; version:Version="8.20.0"]_    import: (&(osgi.wiring.package=com.vaadin.ui)(&(version>=8.20.0)(version<=8.20.0)))_     |_    export: osgi.wiring.package: com.vaadin.ui; uses:=com.vaadin.server_    export: osgi.wiring.package=com.vaadin.server_  com.vaadin.server [osgi.identity; osgi.identity="com.vaadin.server"; type="osgi.bundle"; version:Version="8.20.0"] [Sanitized]
at org.eclipse.osgi.container.Module.start(Module.java:444) ~[org.eclipse.osgi.jar:?]
at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:428) ~[org.eclipse.osgi.jar:?]
at com.liferay.portal.file.install.internal.DirectoryWatcher._startBundle(DirectoryWatcher.java:1156) [bundleFile:?]
at com.liferay.portal.file.install.internal.DirectoryWatcher._startBundles(DirectoryWatcher.java:1189) [bundleFile:?]
at com.liferay.portal.file.install.internal.DirectoryWatcher._process(DirectoryWatcher.java:1046) [bundleFile:?]
at com.liferay.portal.file.install.internal.DirectoryWatcher.run(DirectoryWatcher.java:247) [bundleFile:?]
thevaadinman commented 1 year ago

Then there's something still going wrong with the packaging, as the actual portlet subproject contains no com.vaadin.server classes.

thevaadinman commented 1 year ago

Ok, I've tweaked the build and manifest a bit and confirmed that vaadin-portlet package no longer contains any com.vaadin.server classes. Latest 8.20-SNAPSHOT should be live.

mikke-alekstra commented 1 year ago

It went further but when deploying my Vaadin widgetset library I got the error java.lang.ClassNotFoundException: com.vaadin.osgi.resources.OsgiVaadinWidgetset

Noticed that my library tries to access com.vaadin.osgi.resources classes from vaadin-portlet because vaadin-portlet exports that package (there are no such classes in vaadin-portlet). This probably is an unnecessary export. Could you try to remove com.vaadin.osgi.resources from vaadin-portlet export packages?

Here is a part from current vaadin-portlet manifest:

Export-Package: com.vaadin.portlet;uses:="com.vaadin.server,javax.port
 let,javax.portlet.filter";version="8.20.0",com.vaadin.portlet.communi
 cation;uses:="com.vaadin.server,com.vaadin.server.communication";vers
 ion="8.20.0",com.vaadin.osgi.resources;version="8.20.0"
thevaadinman commented 1 year ago

I suspect you're correct, it appears to be an accidental holdover.

thevaadinman commented 1 year ago

New snapshot has been released.

mikke-alekstra commented 1 year ago

It is getting closer. When I deploy a portlet I get ClassNotFoundException: com.vaadin.util.CurrentInstance cannot be found by com.vaadin.portlet_8.20.0

I think you should add (at least) com.vaadin.util to vaadin-portlet's Import Packages. Probably also com.vaadin.ui, com.vaadin.shared.util (not sure but there is an import from there in vaadin-portlet source code).

thevaadinman commented 1 year ago

@mikke-alekstra, I tweaked the imports to include com.vaadin.util, com.vaadin.ui and com.vaadin.shared. New build is live, give it a try.

mikke-alekstra commented 1 year ago

It went further again. Unfortunately ClassNotFoundException: javax.servlet.http.HttpServletRequest cannot be found by com.vaadin.portlet_8.20.0

We probably need these four more imports as there packages are imported in vaadin-portlet's java code: elemental.json javax.servlet.http javax.xml.namespace org.w3c.dom

thevaadinman commented 1 year ago

@mikke-alekstra, imports added, new snapshot build is live.

mikke-alekstra commented 1 year ago

@thevaadinman, thank you!

After some initial tests I am successfully running a few weeks old Liferay 7.4.3.60-ga60 release with current Vaadin 8.20-SNAPSHOT. Liferay started well, there are no Vaadin errors in startup and after a few random tests portlets function well, producing no errors.

thevaadinman commented 1 year ago

@mikke-alekstra thank you for your patience and assistance in getting this tweaked! I'll roll this into the upcoming Vaadin 8.20.0.

I've understood that a gift is about to be sent your way. :)

mikke-alekstra commented 1 year ago

You are welcome and thanks! I will keep this snapshot running in our lab switch over to 8.20.0 as soon as it is released.

thevaadinman commented 1 year ago

8.20.0 release is in progress; closing ticket. If problems persist, open another ticket. :)

mikke-alekstra commented 1 year ago

Quick tested with official 8.20.0. Still looking good.