Message Boards

Liferay 7 EXT module - extending LDAPUserImporterImpl

Jan Fleissig, modified 3 Years ago.

Liferay 7 EXT module - extending LDAPUserImporterImpl

New Member Posts: 2 Join Date: 1/16/13 Recent Posts
Hi,
I need modify code inside LDAPUserImporterImpl, which is in this OSGi module:
com.liferay.portal.security.ldap.impl:3.0.10
So I created ext module by this guide: https://help.liferay.com/hc/en-us/articles/360019074311-Modules-Ext-Template (gradle)
I put the original file from sources, put my changes and put dependencies in build.gradle.
Problem is, that I put new imports in LDAPUserImporterImpl:
import com.liferay.expando.kernel.exception.NoSuchTableException;


Build is OK, deployment fails:
Caused by: java.lang.ClassNotFoundException: com.liferay.expando.kernel.exception.NoSuchTableException cannot be found by com.liferay.portal.security.ldap.impl_3.0.10.ext
        at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:508)
        at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:419)
        at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:411)
        at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:151)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
        ... 70 more

build.gradle:

buildscript {
    dependencies {
        classpath group: "com.liferay", name: "com.liferay.gradle.plugins", version: "3.13.8"
    }    repositories {
        maven {
            url "https://repository-cdn.liferay.com/nexus/content/groups/public"
        }
    }
}
apply plugin: "com.liferay.osgi.ext.plugin"

dependencies {
    originalModule group: "com.liferay", name: "com.liferay.portal.security.ldap.impl", version: "3.0.10"
    
    compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "9.0.2"
    compileOnly group: "commons-lang", name: "commons-lang", version: "2.6"
    compileOnly group: "javax.portlet", name: "portlet-api", version: "3.0.1"
    compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations", version: "1.3.0"
    compileOnly group: "org.osgi", name: "osgi.core", version: "6.0.0"
    compileOnly group: "com.liferay", name: "com.liferay.petra.string", version: "4.0.2"
    compileOnly group: "com.liferay", name: "com.liferay.portal.security.exportimport.api", version: "5.0.4"
    compileOnly group: "com.liferay", name: "com.liferay.portal.security.ldap.api", version: "3.0.10"}repositories {
    maven {
        url "https://repository-cdn.liferay.com/nexus/content/groups/public"
    }
}

MANIFEST.MF of built JAR:
[code]
Manifest-Version: 1.0
Liferay-Releng-Portal-Required: true
Bundle-SymbolicName: com.liferay.portal.security.ldap.impl
Liferay-Releng-Marketplace: true
Liferay-Releng-Suite: foundation
Liferay-Releng-Support-Url: http://www.liferay.com
Bnd-LastModified: 1596847082013
Import-Package: com.liferay.admin.kernel.util;version="[2.0,3)",com.li
 feray.expando.kernel.model;version="[3.3,4)",com.liferay.expando.kern
 el.service;version="[1.5,2)",com.liferay.expando.kernel.util;version=
 "[2.0,3)",com.liferay.petra.lang;version="[1.2,2)",com.liferay.petra.
 string;version="[1.4,2)",com.liferay.portal.configuration.metatype.bn
 d.util;version="[2.0,3)",com.liferay.portal.configuration.persistence
 .listener;version="[1.1,2)",com.liferay.portal.instance.lifecycle;ver
 sion="[2.0,3)",com.liferay.portal.kernel.bean;version="[8.0,9)",com.l
 iferay.portal.kernel.cache;version="[9.1,10)",com.liferay.portal.kern
 el.exception;version="[9.2,10)",com.liferay.portal.kernel.language;ve
 rsion="[8.2,9)",com.liferay.portal.kernel.lock;version="[7.3,8)",com.
 liferay.portal.kernel.log;version="[7.0,8)",com.liferay.portal.kernel
 .messaging;version="[9.1,10)",com.liferay.portal.kernel.model;version
 ="[5.4,6)",com.liferay.portal.kernel.scheduler;version="[9.1,10)",com
 .liferay.portal.kernel.security.auth;version="[2.4,3)",com.liferay.po
 rtal.kernel.security.exportimport;version="[1.0,2)",com.liferay.porta
 l.kernel.security.ldap;version="[1.0,2)",com.liferay.portal.kernel.se
 curity.pwd;version="[2.0,3)",com.liferay.portal.kernel.service;versio
 n="[4.6,5)",com.liferay.portal.kernel.service.persistence;version="[6
 .0,7)",com.liferay.portal.kernel.transaction;version="[8.0,9)",com.li
 feray.portal.kernel.util;version="[10.6,11)",com.liferay.portal.secur
 ity.exportimport;version="[1.0,2)",com.liferay.portal.security.ldap;v
 ersion="[2.0,2.1)",com.liferay.portal.security.ldap.authenticator.con
 figuration;version="[1.0,2)",com.liferay.portal.security.ldap.configu
 ration;version="[2.0,3)",com.liferay.portal.security.ldap.constants;v
 ersion="[2.0,3)",com.liferay.portal.security.ldap.dummy;version="[1.0
 ,2)",com.liferay.portal.security.ldap.exportimport;version="[1.1,1.2)
 ",com.liferay.portal.security.ldap.exportimport.configuration;version
 ="[1.0,2)",com.liferay.portal.security.ldap.util;version="[1.2,2)",co
 m.liferay.portal.security.ldap.validator;version="[1.1,2)",com.lifera
 y.portal.verify,javax.naming,javax.naming.directory,javax.naming.ldap
 ,javax.swing,javax.swing.event,javax.swing.tree,org.apache.commons.la
 ng.time;version="[2.6,3)",org.osgi.framework;version="[1.8,2)",org.os
 gi.service.cm;version="[1.5,2)"
Require-Capability: osgi.extender;filter:="(&(osgi.extender=osgi.compo
 nent)(version>=1.3.0)(!(version>=2.0.0)))",osgi.service;filter:="(obj
 ectClass=com.liferay.admin.kernel.util.Omniadmin)";effective:=active,
 osgi.service;filter:="(objectClass=com.liferay.expando.kernel.service
 .ExpandoValueLocalService)";effective:=active,osgi.service;filter:="(
 objectClass=com.liferay.portal.kernel.cache.SingleVMPool)";effective:
 =active,osgi.service;filter:="(objectClass=com.liferay.portal.kernel.
 lock.LockManager)";effective:=active,osgi.service;filter:="(objectCla
 ss=com.liferay.portal.kernel.messaging.Destination)";effective:=activ
 e,osgi.service;filter:="(objectClass=com.liferay.portal.kernel.messag
 ing.DestinationFactory)";effective:=active,osgi.service;filter:="(obj
 ectClass=com.liferay.portal.kernel.scheduler.SchedulerEngineHelper)";
 effective:=active,osgi.service;filter:="(objectClass=com.liferay.port
 al.kernel.scheduler.TriggerFactory)";effective:=active,osgi.service;f
 ilter:="(objectClass=com.liferay.portal.kernel.security.ldap.Attribut
 esTransformer)";effective:=active,osgi.service;filter:="(objectClass=
 com.liferay.portal.kernel.security.ldap.LDAPSettings)";effective:=act
 ive,osgi.service;filter:="(objectClass=com.liferay.portal.kernel.secu
 rity.pwd.PasswordEncryptor)";effective:=active,osgi.service;filter:="
 (objectClass=com.liferay.portal.kernel.service.CompanyLocalService)";
 effective:=active,osgi.service;filter:="(objectClass=com.liferay.port
 al.kernel.service.GroupLocalService)";effective:=active,osgi.service;
 filter:="(objectClass=com.liferay.portal.kernel.service.ImageLocalSer
 vice)";effective:=active,osgi.service;filter:="(objectClass=com.lifer
 ay.portal.kernel.service.ListTypeService)";effective:=active,osgi.ser
 vice;filter:="(objectClass=com.liferay.portal.kernel.service.Membersh
 ipRequestLocalService)";effective:=active,osgi.service;filter:="(obje
 ctClass=com.liferay.portal.kernel.service.RoleLocalService)";effectiv
 e:=active,osgi.service;filter:="(objectClass=com.liferay.portal.kerne
 l.service.UserGroupLocalService)";effective:=active,osgi.service;filt
 er:="(objectClass=com.liferay.portal.kernel.service.UserLocalService)
 ";effective:=active,osgi.service;filter:="(objectClass=com.liferay.po
 rtal.kernel.service.persistence.ContactPersistence)";effective:=activ
 e,osgi.service;filter:="(objectClass=com.liferay.portal.kernel.servic
 e.persistence.UserPersistence)";effective:=active,osgi.service;filter
 :="(objectClass=com.liferay.portal.kernel.util.PrefsProps)";effective
 :=active,osgi.service;filter:="(objectClass=com.liferay.portal.kernel
 .util.Props)";effective:=active,osgi.service;filter:="(objectClass=co
 m.liferay.portal.security.exportimport.UserExporter)";effective:=acti
 ve,osgi.service;filter:="(objectClass=com.liferay.portal.security.exp
 ortimport.UserImporter)";effective:=active,osgi.service;filter:="(obj
 ectClass=com.liferay.portal.security.ldap.SafePortalLDAP)";effective:
 =active,osgi.service;filter:="(objectClass=com.liferay.portal.securit
 y.ldap.configuration.ConfigurationProvider)";effective:=active,osgi.s
 ervice;filter:="(objectClass=com.liferay.portal.security.ldap.configu
 ration.ConfigurationProvider)";effective:=active;resolution:=optional
 ;cardinality:=multiple,osgi.service;filter:="(objectClass=com.liferay
 .portal.security.ldap.exportimport.LDAPToPortalConverter)";effective:
 =active,osgi.service;filter:="(objectClass=com.liferay.portal.securit
 y.ldap.exportimport.LDAPUserImporter)";effective:=active,osgi.service
 ;filter:="(objectClass=com.liferay.portal.security.ldap.exportimport.
 PortalToLDAPConverter)";effective:=active,osgi.service;filter:="(obje
 ctClass=com.liferay.portal.security.ldap.validator.LDAPFilterValidato
 r)";effective:=active,osgi.service;filter:="(objectClass=org.osgi.ser
 vice.cm.ConfigurationAdmin)";effective:=active,osgi.ee;filter:="(&(os
 gi.ee=JavaSE)(version=1.8))"
Liferay-Releng-Suite-Title: Liferay Foundation
Service-Component: OSGI-INF/com.liferay.portal.security.ldap.internal.
 DefaultAttributesTransformer.xml,OSGI-INF/com.liferay.portal.security
 .ldap.internal.DefaultLDAPSettings.xml,OSGI-INF/com.liferay.portal.se
 curity.ldap.internal.DefaultPortalLDAP.xml,OSGI-INF/com.liferay.porta
 l.security.ldap.internal.SafePortalLDAPImpl.xml,OSGI-INF/com.liferay.
 portal.security.ldap.internal.authenticator.LDAPAuth.xml,OSGI-INF/com
 .liferay.portal.security.ldap.internal.authenticator.configuration.LD
 APAuthConfigurationProviderImpl.xml,OSGI-INF/com.liferay.portal.secur
 ity.ldap.internal.configuration.LDAPConfigurationListener.xml,OSGI-IN
 F/com.liferay.portal.security.ldap.internal.configuration.LDAPServerC
 onfigurationProviderImpl.xml,OSGI-INF/com.liferay.portal.security.lda
 p.internal.configuration.SystemLDAPConfigurationProviderImpl.xml,OSGI
 -INF/com.liferay.portal.security.ldap.internal.configuration.persiste
 nce.listener.UserImportMessageListener.xml,OSGI-INF/com.liferay.porta
 l.security.ldap.internal.exportimport.DefaultLDAPToPortalConverter.xm
 l,OSGI-INF/com.liferay.portal.security.ldap.internal.exportimport.Def
 aultPortalToLDAPConverter.xml,OSGI-INF/com.liferay.portal.security.ld
 ap.internal.exportimport.LDAPUserExporterImpl.xml,OSGI-INF/com.lifera
 y.portal.security.ldap.internal.exportimport.LDAPUserImporterImpl.xml
 ,OSGI-INF/com.liferay.portal.security.ldap.internal.exportimport.conf
 iguration.LDAPExportConfigurationProviderImpl.xml,OSGI-INF/com.lifera
 y.portal.security.ldap.internal.exportimport.configuration.LDAPImport
 ConfigurationProviderImpl.xml,OSGI-INF/com.liferay.portal.security.ld
 ap.internal.instance.lifecycle.LDAPPortalInstanceLifecycleListener.xm
 l,OSGI-INF/com.liferay.portal.security.ldap.internal.messaging.config
 .MessagingConfigurator.xml,OSGI-INF/com.liferay.portal.security.ldap.
 internal.model.listener.ContactModelListener.xml,OSGI-INF/com.liferay
 .portal.security.ldap.internal.model.listener.UserGroupModelListener.
 xml,OSGI-INF/com.liferay.portal.security.ldap.internal.model.listener
 .UserModelListener.xml,OSGI-INF/com.liferay.portal.security.ldap.inte
 rnal.validator.LDAPFilterValidatorImpl.xml,OSGI-INF/com.liferay.porta
 l.security.ldap.internal.verify.LDAPPropertiesVerifyProcess.xml
Liferay-Releng-Restart-Required: true
Provide-Capability: osgi.service;objectClass:List<string>="com.liferay
&nbsp;.portal.configuration.persistence.listener.ConfigurationModelListener
&nbsp;,com.liferay.portal.security.ldap.internal.configuration.persistence.
&nbsp;listener.UserImportMessageListener";uses:="com.liferay.portal.configu
&nbsp;ration.persistence.listener,com.liferay.portal.security.ldap.internal
&nbsp;.configuration.persistence.listener",osgi.service;objectClass:List<st  ring>="com.liferay.portal.instance.lifecycle.PortalInstanceLifecycleL
&nbsp;istener";uses:="com.liferay.portal.instance.lifecycle",osgi.service;o
&nbsp;bjectClass:List<string>="com.liferay.portal.kernel.model.ModelListene
&nbsp;r";uses:="com.liferay.portal.kernel.model",osgi.service;objectClass:L
&nbsp;ist<string>="com.liferay.portal.kernel.security.auth.Authenticator";u
&nbsp;ses:="com.liferay.portal.kernel.security.auth",osgi.service;objectCla
&nbsp;ss:List<string>="com.liferay.portal.kernel.security.ldap.AttributesTr
&nbsp;ansformer";uses:="com.liferay.portal.kernel.security.ldap",osgi.servi
&nbsp;ce;objectClass:List<string>="com.liferay.portal.kernel.security.ldap.
&nbsp;LDAPSettings";uses:="com.liferay.portal.kernel.security.ldap",osgi.se
&nbsp;rvice;objectClass:List<string>="com.liferay.portal.security.exportimp
&nbsp;ort.UserExporter";uses:="com.liferay.portal.security.exportimport",os
&nbsp;gi.service;objectClass:List<string>="com.liferay.portal.security.expo
&nbsp;rtimport.UserImporter,com.liferay.portal.security.ldap.exportimport.L
&nbsp;DAPUserImporter";uses:="com.liferay.portal.security.exportimport,com.
&nbsp;liferay.portal.security.ldap.exportimport",osgi.service;objectClass:L
&nbsp;ist<string>="com.liferay.portal.security.ldap.PortalLDAP";uses:="com.
&nbsp;liferay.portal.security.ldap",osgi.service;objectClass:List<string>="
&nbsp;com.liferay.portal.security.ldap.SafePortalLDAP";uses:="com.liferay.p
&nbsp;ortal.security.ldap",osgi.service;objectClass:List<string>="com.lifer
&nbsp;ay.portal.security.ldap.configuration.ConfigurationProvider";uses:="c
&nbsp;om.liferay.portal.security.ldap.configuration",osgi.service;objectCla
&nbsp;ss:List<string>="com.liferay.portal.security.ldap.exportimport.LDAPTo
&nbsp;PortalConverter";uses:="com.liferay.portal.security.ldap.exportimport
&nbsp;",osgi.service;objectClass:List<string>="com.liferay.portal.security.
&nbsp;ldap.exportimport.PortalToLDAPConverter";uses:="com.liferay.portal.se
&nbsp;curity.ldap.exportimport",osgi.service;objectClass:List<string>="com.
&nbsp;liferay.portal.security.ldap.validator.LDAPFilterValidator";uses:="co
&nbsp;m.liferay.portal.security.ldap.validator",osgi.service;objectClass:Li
&nbsp;st<string>="com.liferay.portal.verify.VerifyProcess";uses:="com.lifer
&nbsp;ay.portal.verify",osgi.service;objectClass:List<string>="org.osgi.ser
&nbsp;vice.cm.ConfigurationListener";uses:="org.osgi.service.cm"
Liferay-Releng-Category: Utility
Bundle-Name: Liferay Portal Security LDAP Implementation
Javac-Debug: on
Liferay-Releng-Public: false
Liferay-Releng-App-Title: Liferay Portal Security
Bundle-ManifestVersion: 2
Liferay-Releng-Supported: true
Bundle-Vendor: Liferay, Inc.
Liferay-Releng-Deprecated: false
Javac-Deprecation: off
Javac-Encoding: UTF-8
Tool: Bnd-4.3.0.201909301554
Liferay-Releng-Labs: false
Bundle-Version: 3.0.10.ext
Liferay-Releng-Fix-Delivery-Method: core
Private-Package: antlr,antlr.ASdebug,antlr.actions.cpp,antlr.actions.c
&nbsp;sharp,antlr.actions.java,antlr.actions.python,antlr.build,antlr.colle
&nbsp;ctions,antlr.collections.impl,antlr.debug,antlr.debug.misc,antlr.prep
&nbsp;rocessor,com.liferay.portal.security.ldap.internal,com.liferay.portal
&nbsp;.security.ldap.internal.authenticator,com.liferay.portal.security.lda
&nbsp;p.internal.authenticator.configuration,com.liferay.portal.security.ld
&nbsp;ap.internal.configuration,com.liferay.portal.security.ldap.internal.c
&nbsp;onfiguration.persistence.listener,com.liferay.portal.security.ldap.in
&nbsp;ternal.constants,com.liferay.portal.security.ldap.internal.exportimpo
&nbsp;rt,com.liferay.portal.security.ldap.internal.exportimport.configurati
&nbsp;on,com.liferay.portal.security.ldap.internal.instance.lifecycle,com.l
&nbsp;iferay.portal.security.ldap.internal.messaging.config,com.liferay.por
&nbsp;tal.security.ldap.internal.model.listener,com.liferay.portal.security
&nbsp;.ldap.internal.validator,com.liferay.portal.security.ldap.internal.va
&nbsp;lidator.parser,com.liferay.portal.security.ldap.internal.verify,org.a
&nbsp;ntlr,org.antlr.analysis,org.antlr.codegen,org.antlr.codegen.templates
&nbsp;,org.antlr.codegen.templates.C,org.antlr.codegen.templates.CSharp,org
&nbsp;.antlr.codegen.templates.Java,org.antlr.codegen.templates.ObjC,org.an
&nbsp;tlr.codegen.templates.Python,org.antlr.codegen.templates.Ruby,org.ant
&nbsp;lr.codegen.templates.cpp,org.antlr.misc,org.antlr.runtime,org.antlr.r
&nbsp;untime.debug,org.antlr.runtime.misc,org.antlr.runtime.tree,org.antlr.
&nbsp;stringtemplate,org.antlr.stringtemplate.language,org.antlr.stringtemp
&nbsp;late.misc,org.antlr.stringtemplate.test,org.antlr.tool,org.antlr.tool
&nbsp;.templates,org.antlr.tool.templates.dot,org.antlr.tool.templates.mess
&nbsp;ages.formats,org.antlr.tool.templates.messages.languages
Liferay-Releng-Bundle: true
Liferay-Releng-Suite-Description: Apps and Features: System Settings,&nbsp;
&nbsp;Web Content Editors, Web Content Template Languages, Theme Tools, Mob
&nbsp;ile Device Rules, Facebook Authentication, LDAP Authentication, NTLM&nbsp;
&nbsp;Authentication, OpenID Authentication, OpenSSO Authentication, Remote
&nbsp; Authentication (AuthVerifiers), SSO-based Authentication, Token-base
&nbsp;d Authentication, Portal Scripting, Elasticsearch Support, Solr Suppo
&nbsp;rt, Documents and Media Store Implementations, and more.<br><br>T
&nbsp;he Foundation suite provides applications and features that extend th
&nbsp;e functionality provided by Liferay's core. Much of the functionality
&nbsp; that belonged to Liferay's core prior to Liferay 7 has been extracte
&nbsp;d into the modules of the Foundation suite. The authentication module
&nbsp;s provide a variety of mechanisms for allowing users and remote appli
&nbsp;cations to authenticate to Liferay. The LDAP Authentication module al
&nbsp;lows administrators to establish connections to one or more LDAP dire
&nbsp;ctories from which users can be imported or exported. The SSO modules
&nbsp; allow users to authenticate to Liferay using a variety of single-sig
&nbsp;n on solutions. The Token-based Authentication module allows users or
&nbsp; remote applications to authenticate to Liferay without a password. T
&nbsp;he Scripting modules allow scripts to be written to invoke Liferay's&nbsp;
&nbsp;API in several languages including Groovy, BeanShell, Python, Ruby, a
&nbsp;nd JavaScript.<br><br>This suite is available in the Liferay bund
&nbsp;le.
Created-By: 1.8.0_121 (Oracle Corporation)
</string></string></string></string></string></string></string></string></string></string></string></string></string></string></st></string>
I suppose that problem is, that package "com.liferay.expando.kernel.exception" IS NOT in "Import-Package" of MANIFEST.MF.
But how to put it? I tried to provide bnd file, but it does not work.
Thanks for any help.
thumbnail
Olaf Kock, modified 3 Years ago.

RE: Liferay 7 EXT module - extending LDAPUserImporterImpl

Liferay Legend Posts: 6403 Join Date: 9/23/08 Recent Posts
Jan Fleissig:

I need modify code inside LDAPUserImporterImpl, which is in this OSGi module:
com.liferay.portal.security.ldap.impl:3.0.10
So I created ext module by this guide: https://help.liferay.com/hc/en-us/articles/360019074311-Modules-Ext-Template (gradle)
I put the original file from sources, put my changes and put dependencies in build.gradle.
Problem is, that I put new imports in LDAPUserImporterImpl:
import com.liferay.expando.kernel.exception.NoSuchTableException;

You ask about version 7.0, which is quite old now, but let me start by stepping a couple of steps back:
"I need to modify code inside ...Impl" is a solution that you came up with, not a problem. If you state the underlying problem, we might be able to come up with a better solution that involves a standard extension point, so that you don't need to create a hard-to-maintain ext module. And even if we end up with the decision that your solution is actually the best way to solve this problem, now everyone is aware of such an extension need, and a standard extension point can be built for future versions.
Until then, this smells like an x-y-problem - just to let you know
Jan Fleissig:

I suppose that problem is, that package "com.liferay.expando.kernel.exception" IS NOT in "Import-Package" of MANIFEST.MF.
But how to put it? I tried to provide bnd file, but it does not work.


AFAIK Expando code is in Kernel, so I'd expect it to be imported and available. However, I've not validated the version numbers you use, and if they match your installation. You might want to validate if there is a mismatch between the compiletime and runtime versions that trigger this.
On the other hand I wonder why bnd didn't pick up this reference in the manifest. Are you actually referencing that exception somewhere in your code, explicitly? (other than in the import)