Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VaadinPortlet NoClassDefFoundError with Liferay #12575

Closed
mikke-alekstra opened this issue Jan 17, 2023 · 25 comments
Closed

VaadinPortlet NoClassDefFoundError with Liferay #12575

mikke-alekstra opened this issue Jan 17, 2023 · 25 comments
Milestone

Comments

@mikke-alekstra
Copy link

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
@mikke-alekstra mikke-alekstra changed the title VaadinPortlet NoClassDefFoundError with Liferay 7.4.3.22 and Vaadin 8.19-SNAPSHOT VaadinPortlet NoClassDefFoundError with Liferay 7.4.3.22 Jan 17, 2023
@mikke-alekstra mikke-alekstra changed the title VaadinPortlet NoClassDefFoundError with Liferay 7.4.3.22 VaadinPortlet NoClassDefFoundError with Liferay Jan 17, 2023
@TatuLund
Copy link
Contributor

This is follow-up to #12569

@TatuLund
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Author

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
Copy link
Author

mikke-alekstra commented Feb 6, 2023

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

  • changed base package com.vaadin.server -> com.vaadin.server.portlet
  • removed LegacyVaadinPortlet.java as I don't need it and it did have a dependency to possibly a protected class in vaadin-server
  • added dependencies:
    com.liferay.portal (com.liferay.portal.kernel) version 93.0.0,
    javax.portlet (portlet-api) version 2.0,
    javax.servlet (javax.servlet-api) version 3.1.0,
    com.vaadin (vaadin-server) version 8.19.0
  • added imports:
    com.bea.portlet.container;resolution:="optional",
    com.ibm.ws.portletcontainer.portlet;resolution:="optional",
    *
  • added exports
    com.vaadin.server.portlet.*
  • modified source code:
    all vaadin-portlet related imports com.vaadin.server -> com.vaadin.server.portlet

vaadin-liferay-integration

  • added dependencies:
    javax.portlet (portlet-api) version 2.0,
    javax.servlet (javax.servlet-api) version 3.1.0,
    org.osgi (org.osgi.core) version ,
    org.osgi (osgi.cmpn) version ,
    com.vaadin (vaadin-server) version 8.19.0,
    my custom vaadin-portlet
  • added imports:
    *
  • added exports
    com.vaadin.osgi.liferay.*
  • modified source code:
    all vaadin-portlet related imports com.vaadin.server -> com.vaadin.server.portlet

@TatuLund
Copy link
Contributor

TatuLund commented Feb 7, 2023

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

@thevaadinman
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Author

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
Copy link
Contributor

@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
Copy link
Author

@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
Copy link
Contributor

thevaadinman commented Feb 15, 2023

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

@thevaadinman
Copy link
Contributor

thevaadinman commented Feb 15, 2023

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
Copy link
Author

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
Copy link
Contributor

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

@thevaadinman
Copy link
Contributor

New snapshot has been released.

@mikke-alekstra
Copy link
Author

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
Copy link
Contributor

@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
Copy link
Author

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
Copy link
Contributor

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

@mikke-alekstra
Copy link
Author

@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
Copy link
Contributor

@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
Copy link
Author

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 thevaadinman added this to the 8.20.0 milestone Feb 21, 2023
@thevaadinman
Copy link
Contributor

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

@mikke-alekstra
Copy link
Author

Quick tested with official 8.20.0. Still looking good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants