Dynamic plugin - ClassNotFoundException for class com.dotmarketing.portlets.languagesmanager.business.LanguageAPI

265 views
Skip to first unread message

Udo.Ge...@gerhards.eu

unread,
Nov 30, 2013, 1:16:32 PM11/30/13
to dot...@googlegroups.com
Hello everyone,

i'm new to dotcms and i try to develop my first dynamic spring plugin. The plugin itself should provide some further services under a specific url. But at the moment i'm facing a strange error.After i copied my plugin to the "felix/load" folder, the plugin will be installed correctly but when call the plugin over the browser it will throw the following exception:

java.lang.ClassNotFoundException: com.dotmarketing.portlets.languagesmanager.business.LanguageAPI not found by eu.gerhards.dotcms.exports [7]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at org.apache.felix.framework.BundleWiringImpl.getClassByDelegation(BundleWiringImpl.java:1374)
at org.apache.felix.framework.BundleWiringImpl.searchImports(BundleWiringImpl.java:1553)
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1484)
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at eu.gerhards.dotcms.controller.SallydaleAccountController.createAccountByJson(SallydaleAccountController.java:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)

I had this exception already when i started to develop the plugin because i was not aware that i have first to export the needed packages via the fragment approach. But now i have written a second dynamic plugin which holds only a manifest file with all the source packages i want to export to my plugins from dotcms. The manifest of the fragement plugin which should export the necessary dotcms libs looks like follows:

Manifest-Version: 1.0
Bnd-LastModified: 1385832474772
Build-Jdk: 1.7.0_07
Built-By: Udo Gehards
Bundle-Category: system
Bundle-ManifestVersion: 2
Bundle-Name: exports
Bundle-SymbolicName: eu.gerhards.dotcms.exports
Bundle-Version: 2.5.1
Created-By: Apache Maven Bundle Plugin
Export-Package: com.dotmarketing.portlets.contentlet.business;version="2
 .5.1",com.dotmarketing.portlets.structure.model;version="2.5.1",com.dot
 marketing.cms.factories;version="2.5.1",com.dotmarketing.portlets.struc
 ture.factories;version="2.5.1",com.dotmarketing.cache;version="2.5.1",c
 om.dotmarketing.viewtools.content.util;version="2.5.1",com.dotmarketing
 .portlets.languagesmanager.model;version="2.5.1",com.dotmarketing.util;
 version="2.5.1",com.dotmarketing.exception;version="2.5.1",com.dotmarke
 ting.beans;version="2.5.1",com.dotmarketing.portlets.mailinglists.facto
 ries;version="2.5.1",com.dotmarketing.cms.login.factories;version="2.5.
 1",com.dotmarketing.portlets.contentlet.model;version="2.5.1",com.dotma
 rketing.portlets.mailinglists.model;version="2.5.1",com.dotmarketing.cm
 s.myaccount.action;version="2.5.1",com.dotmarketing.portlets.languagesm
 anager.business;version="2.5.1"
Fragement-Host: system.bundle; extension:=framework
Tool: Bnd-2.1.0.20130426-122213

and the manifest of my own plugin looks as posted here:

Manifest-Version: 1.0
Bnd-LastModified: 1385833299681
Build-Jdk: 1.7.0_07
Built-By: Udo Gehards
Bundle-Activator: eu.gerhards.dotcms.controller.Activator
Bundle-ClassPath: .,jackson-databind-2.3.0.jar,jackson-core-2.3.0.jar,ja
 ckson-annotations-2.3.0.jar,hibernate-validator-5.0.1.Final.jar,validat
 ion-api-1.1.0.Final.jar,jboss-logging-3.1.1.GA.jar,classmate-0.8.0.jar
Bundle-ManifestVersion: 2
Bundle-Name: CreateAccount
Bundle-SymbolicName: eu.gerhards.dotcms.CreateAccount
Bundle-Version: 0.0.1.SNAPSHOT
Created-By: Apache Maven Bundle Plugin
DynamicImport-Package: *
Embed-Dependency: *;scope=compile|runtime;inline=false
Embed-Transitive: true
Embedded-Artifacts: jackson-databind-2.3.0.jar;g="com.fasterxml.jackson.
 core";a="jackson-databind";v="2.3.0",jackson-core-2.3.0.jar;g="com.fast
 erxml.jackson.core";a="jackson-core";v="2.3.0",jackson-annotations-2.3.
 0.jar;g="com.fasterxml.jackson.core";a="jackson-annotations";v="2.3.0",
 hibernate-validator-5.0.1.Final.jar;g="org.hibernate";a="hibernate-vali
 dator";v="5.0.1.Final",validation-api-1.1.0.Final.jar;g="javax.validati
 on";a="validation-api";v="1.1.0.Final",jboss-logging-3.1.1.GA.jar;g="or
 g.jboss.logging";a="jboss-logging";v="3.1.1.GA",classmate-0.8.0.jar;g="
 com.fasterxml";a="classmate";v="0.8.0"
Export-Package: eu.gerhards.dotcms.controller;uses:="com.dotmarketing.bu
 siness,com.dotmarketing.exception,com.dotmarketing.osgi,com.dotmarketin
 g.portlets.contentlet.business,com.dotmarketing.portlets.contentlet.mod
 el,eu.gerhards.dotcms.data,org.osgi.framework";version="0.0.1.SNAPSHOT"
 ,eu.gerhards.dotcms.data;uses:="com.dotmarketing.portlets.contentlet.mo
 del";version="0.0.1.SNAPSHOT"
Import-Package: com.dotmarketing.osgi,org.apache.felix.http.api;version=
 "[2.0,3)",org.osgi.framework;version="[1.7,2)",com.dotmarketing.beans,c
 om.dotmarketing.business,com.dotmarketing.cache,com.dotmarketing.cms.fa
 ctories,com.dotmarketing.cms.login.factories,com.dotmarketing.cms.myacc
 ount.action,com.dotmarketing.exception,com.dotmarketing.filters,com.dot
 marketing.portlets.contentlet.business,com.dotmarketing.portlets.conten
 tlet.model,com.dotmarketing.portlets.languagesmanager.business,com.dotm
 arketing.portlets.languagesmanager.model,com.dotmarketing.portlets.mail
 inglists.factories,com.dotmarketing.portlets.mailinglists.model,com.dot
 marketing.portlets.structure.factories,com.dotmarketing.portlets.struct
 ure.model,com.dotmarketing.util,com.dotmarketing.viewtools.content.util
Tool: Bnd-2.1.0.20130426-122213

The fragement plugin exports the "com.dotmarketing.portlets.languagesmanager.business"-package where my own plugin imports it. But it still cannot be found. 

If you have look at the exception above and as far as i understand, the osgi tries to handle the search for the package to my fragment plugin, but it will not find the requested package. 

Does anyone have an idea how i can resolve this issue and how i can get access to the libs of dotcms and their respective classes?

Kind regards

Udo Gerhards

Udo Gerhards

unread,
Dec 1, 2013, 7:01:47 AM12/1/13
to dot...@googlegroups.com
Hello everyone,

the problem is solved and i just want to point out the solution to help everyone who is new to dotcms and gets similar exceptions. The solutions is quite simple, in the backend change to 

System > Dynamic Plugins

and open the export packages dialog by clicking "Exported Packages" and enter the package name of the class which throws the exception when you try to access it. This "exports" the package to OSGI and you can use it in your own classes.

What i was wondering is, that i also tried the fragment paradigm which should export the packages via a own dynamic plugin, but it seemed not to work. It would be nice, if someone could give a small example of such a dynamic plugin which implements this paradigm and exports the needed packages in typical osgi-way.

Thanks a lot

Udo

Jason Tesser

unread,
Dec 1, 2013, 7:06:30 AM12/1/13
to dot...@googlegroups.com


--
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To post to this group, send email to dot...@googlegroups.com.
Visit this group at http://groups.google.com/group/dotcms.
For more options, visit https://groups.google.com/groups/opt_out.

Udo Gerhards

unread,
Dec 2, 2013, 4:19:10 PM12/2/13
to dot...@googlegroups.com
Hello LORDs_diakonos,

thanks for the link. This was the example from the source code i used to get my own dynamic "export" plugin. But my plugin had some problems to export the packages ... but, could also have been because of an error of me. As i have seen that the exports work, i did not develop further on it. Maybe to a later time. :)

Regarding my dynamic plugin with the spring servlet, yesterday i had some success, but now i'm facing again a strang behavior. As is reported, i was able to start my dynamic plugin successfully and also i could make some restful requests to the servlet with soap.

After i have seen that the requests also work, i tried to bring in the hibernate validator (newest version) for validating the requests. But as soon as defined the validator bean in the spring-context file the plugin fails with some more dependency error about "javax.validation.ValidatorFactory". 

After that i added the maven dependency for the "javax.validation"-package to maven to get it packet to my plugin. But now the plugin will be deployed and regognized by osgi but the call to 

...
ServiceReference sRef = context.getServiceReference( ExtHttpService.class.getName() );
if ( sRef != null ) {
...

returns me only "null" which causes the if-statement not to execute the contained code which registers my servlet. 

Because of this error, i tried to remove the spring bean definition for the hibernate validator as well as the maven dependency for the javax.validation-package, but it still returns me "null" when i do a "mvn clean package".

This is quite strange because the same code worked before without any problems. Do you have any ideas, what could be the cause for that. It must have something to do with the added and removed maven dependency for the javax.validation-package, because before everything worked fine.

I tried to install the dynamic plugin as well in dotcms 2.5 as well as in the current version which is available from git hub. 

Kind regards

Udo



Jason Tesser

unread,
Dec 3, 2013, 8:41:53 AM12/3/13
to dot...@googlegroups.com
not really sure what is happening.  I know you can do all the things you are looking to do. 

It sounds to me like your build process is messing things up. Maybe your manifest generation or something. 

If you look in our master branch in github we are now using Gradle to build these plugins.  Maybe that will help you. 

Other then that work with your Import-Package which is where I think most of your issues lie with.  That and the extra packages we expose to the OSGi Context. In the master-2.5 branch you can get it to build the osgi packages out of the box of you 

On Mon, Dec 2, 2013 at 4:19 PM, Udo Gerhards <udo.ge...@gerhards.eu> wrote:
thanks for the link. This was the example from the source code i used to get my own dynamic "export" plugin. But my plugin had some problems to export the packages ... but, could also have been because of an error of me. As i have seen that the exports work, i did not develop further on it. Maybe to a later time. :)



Thanks,
Jason S. Tesser
Director, Product Development, Lead Engineer  
dotcms, Inc.
T: 305.858.1422 x7003
http://twitter.com/dotCMS
www.dotcms.com

Udo Gerhards

unread,
Dec 4, 2013, 7:51:30 AM12/4/13
to dot...@googlegroups.com
Hello Jason,

I'm not sure, but it has to be something to do with the manifest generation from maven. In parallel i tried on monday to port the spring-example from the osgi-examples to a maven build. I've written everything new except the pom. I copied my pom to this test project and deleted all unnecessary dependencies. The result is nearly the same.

...

ServiceReference sRef = context.getServiceReference( ExtHttpService.class.getName() );
if ( sRef != null ) {
...

gives me also "null" in this new project.

What i'm currently pretending is, that it is an ordering problem of the imports which causes the classloader not to load the necessary package so that the ExtHttpService.class is not right available when the above call will be processed. I will do some more testings this evenning and see, if the order of the imported packages is important. If not, then i have really no clue, where it depends on and i will switch to gradle.

Kind regards


Udo

Am Samstag, 30. November 2013 19:16:32 UTC+1 schrieb Udo Gerhards:

Maarten Daalder

unread,
Dec 4, 2013, 8:23:30 AM12/4/13
to dot...@googlegroups.com
Hi Udo,

Did you call initializeServices(context) at the top of the start method of your Activator?
Otherwise you can use a service listener to get the ExtHttpService at a later moment.

With kind regards,
Maarten Daalder
ISAAC

Udo Gerhards

unread,
Dec 4, 2013, 8:41:59 AM12/4/13
to dot...@googlegroups.com
Hello Maarten,

yes the context will be initialized in a first step. When i debug the activator, the context looks fine to me.
The listener solution sounds great. Is there an example in the dotcms source code available? If so, i would also try this way.


Kind regards

Udo

Am Samstag, 30. November 2013 19:16:32 UTC+1 schrieb Udo Gerhards:

Maarten Daalder

unread,
Dec 4, 2013, 8:55:52 AM12/4/13
to dot...@googlegroups.com
Hi Udo,

There is example code (though pre-generics) in the Apache Felix documentation:

Although, I haven't needed that since I noticed I forgot the call to initializeServices.

With kind regards,
Maarten Daalder
ISAAC

Udo Gerhards

unread,
Dec 4, 2013, 4:45:04 PM12/4/13
to dot...@googlegroups.com
Hello everyone,

i got it working now with the above approach and maven!!!!

But i had to reset everything. I've deleted my dotcms installation as well as the database. I guess it was a problem in the database. Because, as i mentioned i tried it in dotcms 2.5.1 and the current version available from the git hub, but, the database was quite the same every time. 

I realized this, as i already deleted my previous dotcms 2.5.1 version. So, some entry in the database prevented me from successfully installing the dynamic plugin. I think it was because of a problem which occured during the ClassNotFoundException when i tried to integration the javax.validation.ValidatorFactory. 

So far so good ... thanks to everyone who supported me in this thread. I think its closed now! :)

Kind regards

Udo

santosh yadav

unread,
Aug 7, 2019, 6:26:22 AM8/7/19
to dotCMS User Group
Hello everyone,

I have develop a plugin it's working on version 4.2.2 but it's not working on 5.1.5 it's given following error.


D:\BelFuseDotCMS-2018\dotcms\dynamic-plugins\utils\src\main\java\com\belfuse\site\utils\parametricsearch\ProductSeriesMarshaller.java:12: error: package com.dotmarketing.viewtools.content does
not exist
import com.dotmarketing.viewtools.content.ContentMap;
                                         ^
D:\BelFuseDotCMS-2018\dotcms\dynamic-plugins\utils\src\main\java\com\belfuse\site\utils\parametricsearch\ProductSeriesMarshaller.java:13: error: package com.dotmarketing.viewtools.content does
not exist
import com.dotmarketing.viewtools.content.FileAssetMap;
                                         ^
D:\BelFuseDotCMS-2018\dotcms\dynamic-plugins\utils\src\main\java\com\belfuse\site\utils\ProductSeriesViewTool.java:12: error: package com.dotmarketing.viewtools.content does not exist
import com.dotmarketing.viewtools.content.ContentMap;
                                         ^
D:\BelFuseDotCMS-2018\dotcms\dynamic-plugins\utils\src\main\java\com\belfuse\site\utils\UtilsViewTool.java:10: error: package com.dotcms.repackage.org.apache.hadoop.fs.s3 does not exist
import com.dotcms.repackage.org.apache.hadoop.fs.s3.INode;
                                                   ^
4 errors
4 warnings
:dotcms:dynamic-plugins:utils:compileJava FAILED
:dotcms:dynamic-plugins:utils:processResources UP-TO-DATE
:dotcms:dynamic-plugins:utils:processTestResources UP-TO-DATE

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':dotcms:dynamic-plugins:utils:compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 30.281 secs


Thanks 
Santosh Yadav  

Nathan Keiter

unread,
Aug 7, 2019, 7:54:01 AM8/7/19
to dot...@googlegroups.com
This can be expected. Plugins are not compatible across different dotCMS versions.


Eclipse, or any properly configured IDE can help you figure out why. It's usually import package path changes.

https://dotcms.com/docs/latest/developing-from-source


Nathan I. Keiter | Lead Network Applications Programmer | Benefits Advisory Council Member | I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993
https://www.gettysburg.edu
________________________________
From: dot...@googlegroups.com <dot...@googlegroups.com> on behalf of santosh yadav <az.san...@gmail.com>
Sent: Wednesday, August 7, 2019 6:26 AM
To: dotCMS User Group
Subject: [dotcms] Re: Dynamic plugin - ClassNotFoundException for class com.dotmarketing.portlets.languagesmanager.business.LanguageAPI

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
________________________________
Hello everyone,

I have develop a plugin it's working on version 4.2.2 but it's not working on 5.1.5 it's given following error.


D:\BelFuseDotCMS-2018\dotcms\dynamic-plugins\utils\src\main\java\com\belfuse\site\utils\parametricsearch\ProductSeriesMarshaller.java:12<https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fProductSeriesMarshaller.java%3a12&c=E,1,-4WLVgwE9_MDB-ePpu8t6lqYEe_mfoEwQ2cqSe_odLkDbeIhGqZtMgHpgEhuhRiLV07l4TsHGu8TQSS0QqCCjTBqrVDTxfsuLCrR0eQhvSpXHpfVHlpMJl4U&typo=1>: error: package com.dotmarketing.viewtools.content does
not exist
import com.dotmarketing.viewtools.content.ContentMap;
^
D:\BelFuseDotCMS-2018\dotcms\dynamic-plugins\utils\src\main\java\com\belfuse\site\utils\parametricsearch\ProductSeriesMarshaller.java:13<https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fProductSeriesMarshaller.java%3a13&c=E,1,SkMdDCC4ZeTENiUjDGtBxFBeR2B-nLEajkzWZuoYBgPcX4iicUOqp1FBI19H5UQNX6MRr3mM-V_zWHmWcQhq5vOOGWNJI61zXw4YIX7DAOOFcfG5hg,,&typo=1>: error: package com.dotmarketing.viewtools.content does
not exist
import com.dotmarketing.viewtools.content.FileAssetMap;
^
D:\BelFuseDotCMS-2018\dotcms\dynamic-plugins\utils\src\main\java\com\belfuse\site\utils\ProductSeriesViewTool.java:12<https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fProductSeriesViewTool.java%3a12&c=E,1,7hoU56g_7xR9QsdQb34NollIeSQb2Wz-fBZbvVga8Ps7YSC9bfpZUkSRTT4clfRccQv8aGE2k2RwS4at1h3dpXh17jr1g5NUJiq4DEIoSv0,&typo=1>: error: package com.dotmarketing.viewtools.content does not exist
import com.dotmarketing.viewtools.content.ContentMap;
^
D:\BelFuseDotCMS-2018\dotcms\dynamic-plugins\utils\src\main\java\com\belfuse\site\utils\UtilsViewTool.java:10<https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fUtilsViewTool.java%3a10&c=E,1,H7HOQOfDfi6d62APUSeLV3hUepv1p6ah4RLbohoZLDrtiJkHRjy6IXORqyr0ANgGDo_5vKO7ocoVtQ2Yu0q9vFHsbJF28VcTuGSB-Be7tk-s&typo=1>: error: package com.dotcms.repackage.org.apache.hadoop.fs.s3 does not exist
import com.dotcms.repackage.org.apache.hadoop.fs.s3.INode;
^
4 errors
4 warnings
:dotcms:dynamic-plugins:utils:compileJava FAILED
:dotcms:dynamic-plugins:utils:processResources UP-TO-DATE
:dotcms:dynamic-plugins:utils:processTestResources UP-TO-DATE

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':dotcms:dynamic-plugins:utils:compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 30.281 secs


Thanks
Santosh Yadav

--
http://dotcms.com<https://linkprotect.cudasvc.com/url?a=http%3a%2f%2fdotcms.com&c=E,1,9HBS_2XteVu1S6CvavFPkBl7XBRhXlHJYtnkp3xTJw-zDWlBG9h6q70OR8apeC36b96SeWvTNdyLx4KWr0adBnEOeM65FZogtoaGncNOfbfJ2Q,,&typo=1> - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com<mailto:dotcms+un...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/495b09ba-e0a3-4df4-9e6b-e3943380bb23%40googlegroups.com<https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fgroups.google.com%2fd%2fmsgid%2fdotcms%2f495b09ba-e0a3-4df4-9e6b-e3943380bb23%2540googlegroups.com%3futm_medium%3demail%26utm_source%3dfooter&c=E,1,h6oIpOwmUQEvaWsWOCwIONmM5D1bGOsuo1B3dBWUgNBoluXoARG4TeOcfHZFU_sdVyhWmwbwFe6kqRJpEyxluAyDcDX273uLdXr1if2IjbxeFdVjdVldIA,,&typo=1>.

Will Ezell

unread,
Aug 7, 2019, 8:31:21 AM8/7/19
to dot...@googlegroups.com
The class ContentMap and all velocity classes have been repackaged to live under

com.dotcms.rendering.velocity.*  

so

com.dotmarketing.viewtools.content.ContentMap
becomes

com.dotcms.rendering.velocity.viewtools.content.ContentMap


As Nathan and Chris have mentioned, if your IDE is configured properly, it should be able to auto-suggest the imports of repackaged classes for you.




--
http://dotcms.com - Open Source Java Content Management

---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/1565178837922.7417%40gettysburg.edu.


--



3059 Grand Avenue
Suite 410-B
Miami FL 33133
Main: 
305-900-2001 | Direct: 978.294.9429

   
Reply all
Reply to author
Forward
0 new messages