Message Boards

RE: java.lang.ClassNotFoundException: com.liferay.util.ContentUtil

Sudhanshu Kumar Shukla, modified 3 Years ago.

java.lang.ClassNotFoundException: com.liferay.util.ContentUtil

Junior Member Posts: 35 Join Date: 8/29/16 Recent Posts
Hi Develoeprs,


I Am Facing

java.lang.ClassNotFoundException: com.liferay.util.ContentUtil And PortletProps

Below is my build.gradle file

dependencies {
	compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "2.0.0"
	compileOnly group: "com.liferay.portal", name: "com.liferay.util.taglib", version: "2.0.0"
	compileOnly group: "com.liferay.portal", name: "com.liferay.util.java", version: "2.0.0"
	compileOnly group: 'com.liferay', name: 'com.liferay.content.util', version: '1.0.1'
	compileOnly group: 'com.liferay.portal', name: 'com.liferay.util.bridges', version: '2.0.1'
	compileOnly group: "com.liferay.portal", name: "com.liferay.portal.impl", version: "2.0.0"
	compileOnly group: "javax.portlet", name: "portlet-api", version: "2.0"
	compileOnly group: "javax.servlet", name: "javax.servlet-api", version: "3.0.1"
	compileOnly group: "jstl", name: "jstl", version: "1.2"
	compileOnly group: "org.osgi", name: "osgi.cmpn", version: "6.0.0"
	compileOnly group: 'javax.mail', name: 'mail', version: '1.4.7'
	compileOnly project(":modules:BI_Enquiry-services:BI_Enquiry-services-api")
	compileOnly project(":modules:BI_Enquiry-services:BI_Enquiry-services-service")
}



Here Is My bnd.bnd file


Bundle-Name: BI_Enquiry-web
Bundle-SymbolicName: com.bumerguard.international
Bundle-Version: 1.0.0
Export-Package: com.bumerguard.international.constants
Import-Package: \
				!com.liferay.util; version="[7.0.0,8.0.0)",\
				!com.liferay.util.mail; version="[7.0.0,8.0.0)",\
				*



Can Anybody Point Me where i am going wrong and what to do for using the utilites api's of liferay in dxp

i know osgi provide all the dependencies at the run time but still i am getting this error.

I am going wrong or is there any other way to use those dependencies.

Thanks In Advanced.
thumbnail
Kyle Joseph Stiemann, modified 3 Years ago.

Moved to general Liferay Portal Development forums.

Liferay Master Posts: 760 Join Date: 1/14/13 Recent Posts
Moved to Home » Liferay Portal » English » 3. Development.
thumbnail
Eddie Chow, modified 3 Years ago.

RE: java.lang.ClassNotFoundException: com.liferay.util.ContentUtil

Junior Member Posts: 53 Join Date: 8/28/13 Recent Posts
Can you try removing the Imports from the bnd.bnd file. Those should be taken care of by Gradle since we have them declared as dependencies. Let me know if this works.
Sudhanshu Kumar Shukla, modified 3 Years ago.

RE: java.lang.ClassNotFoundException: com.liferay.util.ContentUtil

Junior Member Posts: 35 Join Date: 8/29/16 Recent Posts
Eddie Chow:
Can you try removing the Imports from the bnd.bnd file. Those should be taken care of by Gradle since we have them declared as dependencies. Let me know if this works.



Thanks Now It's Working

And I have done One More Change In build.gradle file which I think I need to share
Chaged Code

compile group: "com.liferay.portal", name: "com.liferay.portal.impl", version: "2.0.0"


I have Changed CompileOnly to Compile.

Because from CompileOnly it will make the jar available for source code but at runtime, it is not including the classes.

Finally My Working bnd.bnd File is

Bundle-Name: BI_Enquiry-web
Bundle-SymbolicName: com.bumerguard.international
Bundle-Version: 1.0.0
Export-Package: com.bumerguard.international.constants;
Import-Package: \
				!com.swabunga.spell.engine,\
				!com.swabunga.spell.*,\
				!net.fortuna.ical4j.model,\
				!net.fortuna.ical4j.*,\
				!org.apache.axis.tools.ant.wsdl,\
				!org.apache.*,\
				*
Bundle-ClassPath:\
				 .,\
				 lib/com.liferay.util.java-2.0.0.jar
-includeresource:\
				 lib/com.liferay.util.java-2.0.0.jar=com.liferay.util.java-2.0.0.jar



And build.gradle file is

dependencies {
	compile group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "2.0.0"
	compile group: "com.liferay.portal", name: "com.liferay.util.taglib", version: "2.0.0"
	compile group: "com.liferay.portal", name: "com.liferay.util.java", version: "2.0.0"
	compile group: "com.liferay.portal", name: "com.liferay.portal.impl", version: "2.0.0"
	compile group: "javax.portlet", name: "portlet-api", version: "2.0"
	compile group: "javax.servlet", name: "javax.servlet-api", version: "3.0.1"
	compile group: "jstl", name: "jstl", version: "1.2"
	compile group: "org.osgi", name: "osgi.cmpn", version: "6.0.0"
	compile group: 'javax.mail', name: 'mail', version: '1.4.7'
	compileOnly project(":modules:BI_Enquiry-services:BI_Enquiry-services-api")
	compileOnly project(":modules:BI_Enquiry-services:BI_Enquiry-services-service")
}


May This will help For Someone.

If I have done wrong anywhere please let me know.

Thanksemoticonemoticonemoticonemoticonemoticon
Rafał Pyyniak, modified 1 Year ago.

RE: java.lang.ClassNotFoundException: com.liferay.util.ContentUtil

New Member Posts: 5 Join Date: 6/26/20 Recent Posts
Hello,
in case someone had such problem in Liferay 7.2 (maybe also in 7.1 - didn't check that) - it seems that that has been changed and now to access ContentUtil class you have to add following dependency in build.gradle: compileOnly group: "com.liferay", name: "com.liferay.petra.content"