error in creating a portlet module using preferences

thumbnail
Rajesh Chaurasia, modified 6 Years ago. Regular Member Posts: 183 Join Date: 8/18/11 Recent Posts
Hi All,

I created a portlet module using maven and mvcportlet api but i am getting the below error even after my module works correctly.

Caused by: java.lang.ClassNotFoundException: com.liferay.portal.kernel.portlet.DefaultConfigurationAction cannot be found by dynamic-carousel_1.0.0.201904060912
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:508)
thumbnail
Nader Jafari, modified 6 Years ago. Junior Member Posts: 84 Join Date: 8/24/11 Recent Posts
Hi Rajesh
How create your module ?
I think this is a dependency issue please diff your pom.xml by this : https://github.com/vernaillen/liferay7-springmvc-portlet/blob/master/pom.xml

is there this section in your pom.xml :

<dependency>
            <groupId>com.liferay.portal</groupId>
            <artifactId>com.liferay.portal.kernel</artifactId>
            <version>2.3.0</version>
            <scope>provided</scope>
</dependency>

i hope this info can help you
thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
Just some additional notes.
​​​​​​​
It's definitely a kernel dependency issue, but be careful which version you reference and teh version of Liferay matters. 2.6.0 is fine for a 7 series module but if you are using 7.1 then it should be 3.0.0 ... and anything after that of course, 7.2, etc would also change. Best to get a hold of the source code for the version (of Liferay) you are using to make sure you reference the correct version. Otherwise, you may get your compile time to work, but your runtime will still be broken.
thumbnail
Christoph Rabel, modified 6 Years ago. Liferay Legend Posts: 1555 Join Date: 9/24/09 Recent Posts
I have to add something here:
You should always try to use the minimum version you need in your compile time dependencies. You only update your compile time dependencies when something is added to the interface you need or if the major version changes.

That way, you will be compatible to most versions. This is a bit unusual, since in "normal" projects people usually try to use the newest version or at least the exact version you need in their maven or gradle files. But in OSGI, these dependencies are provided by the runtime. And even if you compile against 2.3 the runtime might provide 2.17.
Note: The osgi video in liferay university by Olaf is pretty good, it pays of to watch it.